]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg/TcgPei: Use updated Tpm12CommandLib APIs
authorMichael Kinney <michael.d.kinney@intel.com>
Thu, 21 Jan 2016 19:30:14 +0000 (19:30 +0000)
committermdkinney <mdkinney@Edk2>
Thu, 21 Jan 2016 19:30:14 +0000 (19:30 +0000)
Use the following new APIs in Tpm12CommandLib and remove duplicate
code from TcgPei and TcgDxe:
  Tpm12Extend()
  Tpm12PhysicalPresence()
  Tpm12ContinueSelfTest()
  Tpm12GetCapabilityFlagPermanent()
  Tpm12GetCapabilityFlagVolatile()

Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19728 6f19259b-4bc3-4df7-8a09-765794883524

SecurityPkg/Tcg/TcgPei/TcgPei.c
SecurityPkg/Tcg/TcgPei/TcgPei.inf
SecurityPkg/Tcg/TcgPei/TpmComm.c [deleted file]
SecurityPkg/Tcg/TcgPei/TpmComm.h [deleted file]

index b3ca64273d6d63e603d5b2e5b6aafe780e8498cd..25724a6812e7c411dd05344661059b3718771cb1 100644 (file)
@@ -38,8 +38,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/BaseLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/ReportStatusCodeLib.h>\r
-\r
-#include "TpmComm.h"\r
+#include <Library/Tpm12DeviceLib.h>\r
+#include <Library/Tpm12CommandLib.h>\r
+#include <Library/BaseCryptLib.h>\r
 \r
 BOOLEAN                 mImageInMemory  = FALSE;\r
 \r
@@ -197,6 +198,40 @@ EndofPeiSignalNotifyCallBack (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+Single function calculates SHA1 digest value for all raw data. It\r
+combines Sha1Init(), Sha1Update() and Sha1Final().\r
+\r
+@param[in]  Data          Raw data to be digested.\r
+@param[in]  DataLen       Size of the raw data.\r
+@param[out] Digest        Pointer to a buffer that stores the final digest.\r
+\r
+@retval     EFI_SUCCESS   Always successfully calculate the final digest.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TpmCommHashAll (\r
+  IN  CONST UINT8       *Data,\r
+  IN        UINTN       DataLen,\r
+  OUT       TPM_DIGEST  *Digest\r
+  )\r
+{\r
+  VOID   *Sha1Ctx;\r
+  UINTN  CtxSize;\r
+\r
+  CtxSize = Sha1GetContextSize ();\r
+  Sha1Ctx = AllocatePool (CtxSize);\r
+  ASSERT (Sha1Ctx != NULL);\r
+\r
+  Sha1Init (Sha1Ctx);\r
+  Sha1Update (Sha1Ctx, Data, DataLen);\r
+  Sha1Final (Sha1Ctx, (UINT8 *)Digest);\r
+\r
+  FreePool (Sha1Ctx);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   Do a hash operation on a data buffer, extend a specific TPM PCR with the hash result,\r
   and build a GUIDed HOB recording the event which will be passed to the DXE phase and\r
@@ -242,8 +277,7 @@ HashLogExtendEvent (
     }\r
   }\r
 \r
-  Status = TpmCommExtend (\r
-             PeiServices,\r
+  Status = Tpm12Extend (\r
              &NewEventHdr->Digest,\r
              NewEventHdr->PCRIndex,\r
              NULL\r
@@ -540,12 +574,11 @@ PhysicalPresencePpiNotifyCallback (
   )\r
 {\r
   EFI_STATUS                        Status;\r
+  TPM_PERMANENT_FLAGS               TpmPermanentFlags;\r
   PEI_LOCK_PHYSICAL_PRESENCE_PPI    *LockPhysicalPresencePpi;\r
-  BOOLEAN                           LifetimeLock;\r
-  BOOLEAN                           CmdEnable;\r
   TPM_PHYSICAL_PRESENCE             PhysicalPresenceValue;\r
 \r
-  Status = TpmCommGetCapability (PeiServices, NULL, &LifetimeLock, &CmdEnable);\r
+  Status = Tpm12GetCapabilityFlagPermanent (&TpmPermanentFlags);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -553,7 +586,7 @@ PhysicalPresencePpiNotifyCallback (
   //\r
   // 1. Set physicalPresenceLifetimeLock, physicalPresenceHWEnable and physicalPresenceCMDEnable bit by PCDs.\r
   //\r
-  if (PcdGetBool (PcdPhysicalPresenceLifetimeLock) && !LifetimeLock) {\r
+  if (PcdGetBool (PcdPhysicalPresenceLifetimeLock) && !TpmPermanentFlags.physicalPresenceLifetimeLock) {\r
     //\r
     // Lock TPM LifetimeLock is required, and LifetimeLock is not locked yet. \r
     //\r
@@ -561,10 +594,10 @@ PhysicalPresencePpiNotifyCallback (
 \r
     if (PcdGetBool (PcdPhysicalPresenceCmdEnable)) {\r
       PhysicalPresenceValue |= TPM_PHYSICAL_PRESENCE_CMD_ENABLE;\r
-      CmdEnable = TRUE;\r
+      TpmPermanentFlags.physicalPresenceCMDEnable = TRUE;\r
     } else {\r
       PhysicalPresenceValue |= TPM_PHYSICAL_PRESENCE_CMD_DISABLE;\r
-      CmdEnable = FALSE;\r
+      TpmPermanentFlags.physicalPresenceCMDEnable = FALSE;\r
     }\r
 \r
     if (PcdGetBool (PcdPhysicalPresenceHwEnable)) {\r
@@ -573,8 +606,7 @@ PhysicalPresencePpiNotifyCallback (
       PhysicalPresenceValue |= TPM_PHYSICAL_PRESENCE_HW_DISABLE;\r
     }      \r
      \r
-    Status = TpmCommPhysicalPresence (\r
-               PeiServices,\r
+    Status = Tpm12PhysicalPresence (\r
                PhysicalPresenceValue\r
                );\r
     if (EFI_ERROR (Status)) {\r
@@ -590,8 +622,8 @@ PhysicalPresencePpiNotifyCallback (
     return EFI_SUCCESS;\r
   }\r
 \r
-  if (!CmdEnable) {\r
-    if (LifetimeLock) {\r
+  if (!TpmPermanentFlags.physicalPresenceCMDEnable) {\r
+    if (TpmPermanentFlags.physicalPresenceLifetimeLock) {\r
       //\r
       // physicalPresenceCMDEnable is locked, can't change.\r
       //\r
@@ -602,8 +634,7 @@ PhysicalPresencePpiNotifyCallback (
     // Enable physical presence command\r
     // It is necessary in order to lock physical presence\r
     //\r
-    Status = TpmCommPhysicalPresence (\r
-               PeiServices,\r
+    Status = Tpm12PhysicalPresence (\r
                TPM_PHYSICAL_PRESENCE_CMD_ENABLE\r
                );\r
     if (EFI_ERROR (Status)) {\r
@@ -614,8 +645,7 @@ PhysicalPresencePpiNotifyCallback (
   //\r
   // Lock physical presence\r
   // \r
-  Status = TpmCommPhysicalPresence (\r
-              PeiServices,\r
+  Status = Tpm12PhysicalPresence (\r
               TPM_PHYSICAL_PRESENCE_LOCK\r
               );\r
   return Status;\r
@@ -631,19 +661,18 @@ PhysicalPresencePpiNotifyCallback (
 \r
 **/\r
 BOOLEAN\r
-EFIAPI\r
 IsTpmUsable (\r
-  IN      EFI_PEI_SERVICES          **PeiServices\r
+  VOID\r
   )\r
 {\r
-  EFI_STATUS                        Status;\r
-  BOOLEAN                           Deactivated;\r
+  EFI_STATUS           Status;\r
+  TPM_PERMANENT_FLAGS  TpmPermanentFlags;\r
 \r
-  Status = TpmCommGetCapability (PeiServices, &Deactivated, NULL, NULL);\r
+  Status = Tpm12GetCapabilityFlagPermanent (&TpmPermanentFlags);\r
   if (EFI_ERROR (Status)) {\r
     return FALSE;\r
   }\r
-  return (BOOLEAN)(!Deactivated); \r
+  return (BOOLEAN)(!TpmPermanentFlags.deactivated);\r
 }\r
 \r
 /**\r
@@ -682,7 +711,7 @@ PeimEntryMP (
     return Status;\r
   }\r
 \r
-  if (IsTpmUsable (PeiServices)) {\r
+  if (IsTpmUsable ()) {\r
     if (PcdGet8 (PcdTpmScrtmPolicy) == 1) {\r
       Status = MeasureCRTMVersion (PeiServices);\r
     }\r
@@ -759,7 +788,11 @@ PeimEntryMA (
     }\r
 \r
     if (PcdGet8 (PcdTpmInitializationPolicy) == 1) {\r
-      Status = TpmCommStartup ((EFI_PEI_SERVICES**)PeiServices, BootMode);\r
+      if (BootMode == BOOT_ON_S3_RESUME) {\r
+        Status = Tpm12Startup (TPM_ST_STATE);\r
+      } else {\r
+        Status = Tpm12Startup (TPM_ST_CLEAR);\r
+      }\r
       if (EFI_ERROR (Status) ) {\r
         goto Done;\r
       }\r
@@ -769,7 +802,7 @@ PeimEntryMA (
     // TpmSelfTest is optional on S3 path, skip it to save S3 time\r
     //\r
     if (BootMode != BOOT_ON_S3_RESUME) {\r
-      Status = TpmCommContinueSelfTest ((EFI_PEI_SERVICES**)PeiServices);\r
+      Status = Tpm12ContinueSelfTest ();\r
       if (EFI_ERROR (Status)) {\r
         goto Done;\r
       }\r
index cdee0ab2ecbacc40b3ca0ee27eb549e48b875a3d..9a44d8fbda51f4dad25323f6ddf3acdf9da603ff 100644 (file)
@@ -34,8 +34,6 @@
 \r
 [Sources]\r
   TcgPei.c\r
-  TpmComm.c\r
-  TpmComm.h\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
@@ -57,6 +55,7 @@
   PcdLib\r
   MemoryAllocationLib\r
   ReportStatusCodeLib\r
+  Tpm12CommandLib\r
 \r
 [Guids]\r
   gTcgEventEntryHobGuid                                               ## PRODUCES               ## HOB\r
diff --git a/SecurityPkg/Tcg/TcgPei/TpmComm.c b/SecurityPkg/Tcg/TcgPei/TpmComm.c
deleted file mode 100644 (file)
index 1a2156c..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-/** @file\r
-  Utility functions used by TPM PEI driver.\r
-  \r
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution.  The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "TpmComm.h"\r
-\r
-/**\r
-  Send TPM_Startup command to TPM.\r
-\r
-  @param[in] PeiServices        Describes the list of possible PEI Services.\r
-  @param[in] BootMode           Boot mode.\r
\r
-  @retval EFI_SUCCESS           Operation completed successfully.\r
-  @retval EFI_TIMEOUT           The register can't run into the expected status in time.\r
-  @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.\r
-  @retval EFI_DEVICE_ERROR      Unexpected device behavior.\r
-\r
-**/\r
-EFI_STATUS\r
-TpmCommStartup (\r
-  IN      EFI_PEI_SERVICES          **PeiServices,\r
-  IN      EFI_BOOT_MODE             BootMode\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  TPM_STARTUP_TYPE                  TpmSt;\r
-  UINT32                            TpmRecvSize;\r
-  UINT32                            TpmSendSize;\r
-  TPM_CMD_START_UP                  SendBuffer;\r
-  UINT8                             RecvBuffer[20];\r
-\r
-  TpmSt = TPM_ST_CLEAR;\r
-  if (BootMode == BOOT_ON_S3_RESUME) {\r
-    TpmSt = TPM_ST_STATE;\r
-  }\r
-  //\r
-  // send Tpm command TPM_ORD_Startup\r
-  //\r
-  TpmRecvSize               = 20;\r
-  TpmSendSize               = sizeof (TPM_CMD_START_UP);\r
-  SendBuffer.Hdr.tag        = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r
-  SendBuffer.Hdr.paramSize  = SwapBytes32 (TpmSendSize);\r
-  SendBuffer.Hdr.ordinal    = SwapBytes32 (TPM_ORD_Startup);\r
-  SendBuffer.TpmSt          = SwapBytes16 (TpmSt);\r
-  Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, RecvBuffer);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Send TPM_ContinueSelfTest command to TPM.\r
-\r
-  @param[in] PeiServices        Describes the list of possible PEI Services.\r
-\r
-  @retval EFI_SUCCESS           Operation completed successfully.\r
-  @retval EFI_TIMEOUT           The register can't run into the expected status in time.\r
-  @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.\r
-  @retval EFI_DEVICE_ERROR      Unexpected device behavior.\r
-\r
-**/\r
-EFI_STATUS\r
-TpmCommContinueSelfTest (\r
-  IN      EFI_PEI_SERVICES          **PeiServices\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  UINT32                            TpmRecvSize;\r
-  UINT32                            TpmSendSize;\r
-  TPM_CMD_SELF_TEST                 SendBuffer;\r
-  UINT8                             RecvBuffer[20];\r
-\r
-  //\r
-  // send Tpm command TPM_ORD_ContinueSelfTest\r
-  //\r
-  TpmRecvSize               = 20;\r
-  TpmSendSize               = sizeof (TPM_CMD_SELF_TEST);\r
-  SendBuffer.Hdr.tag        = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r
-  SendBuffer.Hdr.paramSize  = SwapBytes32 (TpmSendSize);  \r
-  SendBuffer.Hdr.ordinal    = SwapBytes32 (TPM_ORD_ContinueSelfTest);\r
-  Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, RecvBuffer);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Get TPM capability flags.\r
-\r
-  @param[in]  PeiServices       Describes the list of possible PEI Services.\r
-  @param[out] Deactivated       Returns deactivated flag.\r
-  @param[out] LifetimeLock      Returns physicalPresenceLifetimeLock permanent flag.  \r
-  @param[out] CmdEnable         Returns physicalPresenceCMDEnable permanent flag.\r
-\r
-  @retval EFI_SUCCESS           Operation completed successfully.\r
-  @retval EFI_TIMEOUT           The register can't run into the expected status in time.\r
-  @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.\r
-  @retval EFI_DEVICE_ERROR      Unexpected device behavior.\r
-\r
-**/\r
-EFI_STATUS\r
-TpmCommGetCapability (\r
-  IN      EFI_PEI_SERVICES          **PeiServices,\r
-     OUT  BOOLEAN                   *Deactivated, OPTIONAL\r
-     OUT  BOOLEAN                   *LifetimeLock, OPTIONAL\r
-     OUT  BOOLEAN                   *CmdEnable OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  UINT32                            TpmRecvSize;\r
-  UINT32                            TpmSendSize;\r
-  TPM_CMD_GET_CAPABILITY            SendBuffer;\r
-  UINT8                             RecvBuffer[40];\r
-  TPM_PERMANENT_FLAGS               *TpmPermanentFlags;\r
-\r
-  //\r
-  // send Tpm command TPM_ORD_GetCapability\r
-  //\r
-  TpmRecvSize                   = 40;\r
-  TpmSendSize                   = sizeof (TPM_CMD_GET_CAPABILITY);\r
-  SendBuffer.Hdr.tag            = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r
-  SendBuffer.Hdr.paramSize      = SwapBytes32 (TpmSendSize);  \r
-  SendBuffer.Hdr.ordinal        = SwapBytes32 (TPM_ORD_GetCapability);\r
-  SendBuffer.Capability         = SwapBytes32 (TPM_CAP_FLAG);\r
-  SendBuffer.CapabilityFlagSize = SwapBytes32 (sizeof (TPM_CAP_FLAG_PERMANENT));\r
-  SendBuffer.CapabilityFlag     = SwapBytes32 (TPM_CAP_FLAG_PERMANENT);\r
-  Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, RecvBuffer);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  TpmPermanentFlags = (TPM_PERMANENT_FLAGS *)&RecvBuffer[sizeof (TPM_RSP_COMMAND_HDR) + sizeof (UINT32)];\r
-  if (Deactivated != NULL) {\r
-    *Deactivated      = TpmPermanentFlags->deactivated;\r
-  }\r
-\r
-  if (LifetimeLock != NULL) {\r
-    *LifetimeLock = TpmPermanentFlags->physicalPresenceLifetimeLock;\r
-  }\r
-\r
-  if (CmdEnable != NULL) {\r
-    *CmdEnable = TpmPermanentFlags->physicalPresenceCMDEnable;\r
-  }\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Extend a TPM PCR.\r
-\r
-  @param[in]  PeiServices       Describes the list of possible PEI Services.\r
-  @param[in]  DigestToExtend    The 160 bit value representing the event to be recorded.  \r
-  @param[in]  PcrIndex          The PCR to be updated.\r
-  @param[out] NewPcrValue       New PCR value after extend.  \r
-\r
-  @retval EFI_SUCCESS           Operation completed successfully.\r
-  @retval EFI_TIMEOUT           The register can't run into the expected status in time.\r
-  @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.\r
-  @retval EFI_DEVICE_ERROR      Unexpected device behavior.\r
-\r
-**/\r
-EFI_STATUS\r
-TpmCommExtend (\r
-  IN      EFI_PEI_SERVICES          **PeiServices,\r
-  IN      TPM_DIGEST                *DigestToExtend,\r
-  IN      TPM_PCRINDEX              PcrIndex,\r
-     OUT  TPM_DIGEST                *NewPcrValue\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  UINT32                            TpmSendSize;\r
-  UINT32                            TpmRecvSize;\r
-  TPM_CMD_EXTEND                    SendBuffer;\r
-  UINT8                             RecvBuffer[10 + sizeof(TPM_DIGEST)];\r
-\r
-  //\r
-  // send Tpm command TPM_ORD_Extend\r
-  //\r
-  TpmRecvSize               = sizeof (TPM_RSP_COMMAND_HDR) + sizeof (TPM_DIGEST);\r
-  TpmSendSize               = sizeof (TPM_CMD_EXTEND);\r
-  SendBuffer.Hdr.tag        = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r
-  SendBuffer.Hdr.paramSize  = SwapBytes32 (TpmSendSize);\r
-  SendBuffer.Hdr.ordinal    = SwapBytes32 (TPM_ORD_Extend);\r
-  SendBuffer.PcrIndex       = SwapBytes32 (PcrIndex);\r
-  CopyMem (&SendBuffer.TpmDigest, (UINT8 *)DigestToExtend, sizeof (TPM_DIGEST));\r
-  Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, RecvBuffer);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  if(NewPcrValue != NULL) {\r
-    CopyMem ((UINT8*)NewPcrValue, &RecvBuffer[10], sizeof (TPM_DIGEST));\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Send TSC_PhysicalPresence command to TPM.\r
-\r
-  @param[in] PeiServices        Describes the list of possible PEI Services.\r
-  @param[in] PhysicalPresence   The state to set the TPMs Physical Presence flags.  \r
-\r
-  @retval EFI_SUCCESS           Operation completed successfully.\r
-  @retval EFI_TIMEOUT           The register can't run into the expected status in time.\r
-  @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.\r
-  @retval EFI_DEVICE_ERROR      Unexpected device behavior.\r
-\r
-**/\r
-EFI_STATUS\r
-TpmCommPhysicalPresence (\r
-  IN      EFI_PEI_SERVICES          **PeiServices,\r
-  IN      TPM_PHYSICAL_PRESENCE     PhysicalPresence\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  UINT32                            TpmSendSize;\r
-  UINT32                            TpmRecvSize;\r
-  TPM_CMD_PHYSICAL_PRESENCE         SendBuffer;\r
-  UINT8                             RecvBuffer[10];\r
-\r
-  //\r
-  // send Tpm command TSC_ORD_PhysicalPresence\r
-  //\r
-  TpmRecvSize                 = 10;\r
-  TpmSendSize                 = sizeof (TPM_CMD_PHYSICAL_PRESENCE);\r
-  SendBuffer.Hdr.tag          = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r
-  SendBuffer.Hdr.paramSize    = SwapBytes32 (TpmSendSize);\r
-  SendBuffer.Hdr.ordinal      = SwapBytes32 (TSC_ORD_PhysicalPresence);\r
-  SendBuffer.PhysicalPresence = SwapBytes16 (PhysicalPresence);\r
-  Status = Tpm12SubmitCommand (TpmSendSize, (UINT8 *)&SendBuffer, &TpmRecvSize, RecvBuffer);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Single function calculates SHA1 digest value for all raw data. It\r
-  combines Sha1Init(), Sha1Update() and Sha1Final().\r
-\r
-  @param[in]  Data          Raw data to be digested.\r
-  @param[in]  DataLen       Size of the raw data.\r
-  @param[out] Digest        Pointer to a buffer that stores the final digest.\r
-\r
-  @retval     EFI_SUCCESS   Always successfully calculate the final digest.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TpmCommHashAll (\r
-  IN  CONST UINT8                   *Data,\r
-  IN        UINTN                   DataLen,\r
-  OUT       TPM_DIGEST              *Digest\r
-  )\r
-{\r
-  VOID     *Sha1Ctx;\r
-  UINTN    CtxSize;\r
-\r
-  CtxSize = Sha1GetContextSize ();\r
-  Sha1Ctx = AllocatePool (CtxSize);\r
-  ASSERT (Sha1Ctx != NULL);\r
-\r
-  Sha1Init (Sha1Ctx);\r
-  Sha1Update (Sha1Ctx, Data, DataLen);\r
-  Sha1Final (Sha1Ctx, (UINT8 *)Digest);\r
-\r
-  FreePool (Sha1Ctx);\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/SecurityPkg/Tcg/TcgPei/TpmComm.h b/SecurityPkg/Tcg/TcgPei/TpmComm.h
deleted file mode 100644 (file)
index 06eefe1..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/** @file\r
-  The header file for TPM PEI driver.\r
-  \r
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution.  The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _TPM_COMM_H_\r
-#define _TPM_COMM_H_\r
-\r
-#include <IndustryStandard/Tpm12.h>\r
-#include <IndustryStandard/UefiTcgPlatform.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseCryptLib.h>\r
-#include <Library/Tpm12DeviceLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  TPM_RQU_COMMAND_HDR   Hdr;\r
-  TPM_STARTUP_TYPE      TpmSt;\r
-} TPM_CMD_START_UP;\r
-\r
-typedef struct {\r
-  TPM_RQU_COMMAND_HDR   Hdr;\r
-} TPM_CMD_SELF_TEST;\r
-\r
-typedef struct {\r
-  TPM_RQU_COMMAND_HDR   Hdr;\r
-  UINT32                Capability;\r
-  UINT32                CapabilityFlagSize;\r
-  UINT32                CapabilityFlag;\r
-} TPM_CMD_GET_CAPABILITY;\r
-\r
-typedef struct {\r
-  TPM_RQU_COMMAND_HDR   Hdr;\r
-  TPM_PCRINDEX          PcrIndex;\r
-  TPM_DIGEST            TpmDigest;\r
-} TPM_CMD_EXTEND;\r
-\r
-typedef struct {\r
-  TPM_RQU_COMMAND_HDR   Hdr;\r
-  TPM_PHYSICAL_PRESENCE PhysicalPresence;\r
-} TPM_CMD_PHYSICAL_PRESENCE;\r
-\r
-#pragma pack()\r
-\r
-/**\r
-  Send TPM_Startup command to TPM.\r
-\r
-  @param[in] PeiServices        Describes the list of possible PEI Services.\r
-  @param[in] BootMode           Boot mode.  \r
-\r
-  @retval EFI_SUCCESS           Operation completed successfully.\r
-  @retval EFI_TIMEOUT           The register can't run into the expected status in time.\r
-  @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.\r
-  @retval EFI_DEVICE_ERROR      Unexpected device behavior.\r
-\r
-**/\r
-EFI_STATUS\r
-TpmCommStartup (\r
-  IN      EFI_PEI_SERVICES          **PeiServices,\r
-  IN      EFI_BOOT_MODE             BootMode\r
-  );\r
-\r
-/**\r
-  Send TPM_ContinueSelfTest command to TPM.\r
-\r
-  @param[in] PeiServices        Describes the list of possible PEI Services.\r
-\r
-  @retval EFI_SUCCESS           Operation completed successfully.\r
-  @retval EFI_TIMEOUT           The register can't run into the expected status in time.\r
-  @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.\r
-  @retval EFI_DEVICE_ERROR      Unexpected device behavior.\r
-\r
-**/\r
-EFI_STATUS\r
-TpmCommContinueSelfTest (\r
-  IN      EFI_PEI_SERVICES          **PeiServices\r
-  );\r
-\r
-/**\r
-  Get TPM capability flags.\r
-\r
-  @param[in]  PeiServices       Describes the list of possible PEI Services.\r
-  @param[in]  TpmHandle         TPM handle.  \r
-  @param[out] Deactivated       Returns deactivated flag.\r
-  @param[out] LifetimeLock      Returns physicalPresenceLifetimeLock permanent flag.  \r
-  @param[out] CmdEnable         Returns physicalPresenceCMDEnable permanent flag.\r
\r
-  @retval EFI_SUCCESS           Operation completed successfully.\r
-  @retval EFI_TIMEOUT           The register can't run into the expected status in time.\r
-  @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.\r
-  @retval EFI_DEVICE_ERROR      Unexpected device behavior.\r
-\r
-**/\r
-EFI_STATUS\r
-TpmCommGetCapability (\r
-  IN      EFI_PEI_SERVICES          **PeiServices,\r
-     OUT  BOOLEAN                   *Deactivated, OPTIONAL\r
-     OUT  BOOLEAN                   *LifetimeLock, OPTIONAL\r
-     OUT  BOOLEAN                   *CmdEnable OPTIONAL\r
-  );\r
-\r
-/**\r
-  Extend a TPM PCR.\r
-\r
-  @param[in]  PeiServices       Describes the list of possible PEI Services.\r
-  @param[in]  TpmHandle         TPM handle.  \r
-  @param[in]  DigestToExtend    The 160 bit value representing the event to be recorded.  \r
-  @param[in]  PcrIndex          The PCR to be updated.\r
-  @param[out] NewPcrValue       New PCR value after extend.  \r
\r
-  @retval EFI_SUCCESS           Operation completed successfully.\r
-  @retval EFI_TIMEOUT           The register can't run into the expected status in time.\r
-  @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.\r
-  @retval EFI_DEVICE_ERROR      Unexpected device behavior.\r
-\r
-**/\r
-EFI_STATUS\r
-TpmCommExtend (\r
-  IN      EFI_PEI_SERVICES          **PeiServices,\r
-  IN      TPM_DIGEST                *DigestToExtend,\r
-  IN      TPM_PCRINDEX              PcrIndex,\r
-     OUT  TPM_DIGEST                *NewPcrValue\r
-  );\r
-\r
-\r
-/**\r
-  Send TSC_PhysicalPresence command to TPM.\r
-\r
-  @param[in] PeiServices        Describes the list of possible PEI Services.\r
-  @param[in] TpmHandle          TPM handle.  \r
-  @param[in] PhysicalPresence   The state to set the TPMs Physical Presence flags.  \r
\r
-  @retval EFI_SUCCESS           Operation completed successfully.\r
-  @retval EFI_TIMEOUT           The register can't run into the expected status in time.\r
-  @retval EFI_BUFFER_TOO_SMALL  Response data buffer is too small.\r
-  @retval EFI_DEVICE_ERROR      Unexpected device behavior.\r
-\r
-**/\r
-EFI_STATUS\r
-TpmCommPhysicalPresence (\r
-  IN      EFI_PEI_SERVICES          **PeiServices,\r
-  IN      TPM_PHYSICAL_PRESENCE     PhysicalPresence\r
-  );\r
-\r
-/**\r
-  Single function calculates SHA1 digest value for all raw data. It\r
-  combines Sha1Init(), Sha1Update() and Sha1Final().\r
-\r
-  @param[in]  Data          Raw data to be digested.\r
-  @param[in]  DataLen       Size of the raw data.\r
-  @param[out] Digest        Pointer to a buffer that stores the final digest.\r
-\r
-  @retval     EFI_SUCCESS   Always successfully calculate the final digest.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-TpmCommHashAll (\r
-  IN  CONST UINT8                   *Data,\r
-  IN        UINTN                   DataLen,\r
-  OUT       TPM_DIGEST              *Digest\r
-  );\r
-\r
-#endif  // _TPM_COMM_H_\r