]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c
SecurityPkg: Tpm2DeviceLib: Enable CapCRBIdleBypass support
[mirror_edk2.git] / SecurityPkg / Library / PeiRsa2048Sha256GuidedSectionExtractLib / PeiRsa2048Sha256GuidedSectionExtractLib.c
index e2a0fb6708845eda93736172f2d24ee7f8aee171..2272308ddca0c99b779a6d52687b162e3d4a9ebe 100644 (file)
@@ -57,7 +57,7 @@ CONST UINT8 mRsaE[] = { 0x01, 0x00, 0x01 };
   @param SectionAttribute   The attribute of the input guided section.\r
 \r
   @retval EFI_SUCCESS            The size of destination buffer, the size of scratch buffer and \r
-                                 the attribute of the input section are successull retrieved.\r
+                                 the attribute of the input section are successfully retrieved.\r
   @retval EFI_INVALID_PARAMETER  The GUID in InputSection does not match this instance guid.\r
 \r
 **/\r
@@ -84,7 +84,7 @@ Rsa2048Sha256GuidedSectionGetInfo (
     //\r
     *SectionAttribute  = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;\r
     *ScratchBufferSize = 0;\r
-    *OutputBufferSize  = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;\r
+    *OutputBufferSize  = SECTION2_SIZE (InputSection) - sizeof(RSA_2048_SHA_256_SECTION2_HEADER);\r
   } else {\r
     //\r
     // Check whether the input guid section is recognized.\r
@@ -99,7 +99,7 @@ Rsa2048Sha256GuidedSectionGetInfo (
     //\r
     *SectionAttribute  = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;\r
     *ScratchBufferSize = 0;\r
-    *OutputBufferSize  = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;\r
+    *OutputBufferSize  = SECTION_SIZE (InputSection) - sizeof(RSA_2048_SHA_256_SECTION_HEADER);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -160,9 +160,9 @@ Rsa2048Sha256GuidedSectionHandler (
     CertBlockRsa2048Sha256 = &((RSA_2048_SHA_256_SECTION2_HEADER *) InputSection)->CertBlockRsa2048Sha256;\r
     OutputBufferSize       = SECTION2_SIZE (InputSection) - sizeof (RSA_2048_SHA_256_SECTION2_HEADER);\r
     if ((((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) != 0) {\r
-      PERF_START (NULL, "RsaCopy", "PEI", 0);\r
+      PERF_INMODULE_BEGIN ("PeiRsaCopy");\r
       CopyMem (*OutputBuffer, (UINT8 *)InputSection + sizeof (RSA_2048_SHA_256_SECTION2_HEADER), OutputBufferSize);\r
-      PERF_END (NULL, "RsaCopy", "PEI", 0);\r
+      PERF_INMODULE_END ("PeiRsaCopy");\r
     } else {\r
       *OutputBuffer = (UINT8 *)InputSection + sizeof (RSA_2048_SHA_256_SECTION2_HEADER);\r
     }\r
@@ -188,9 +188,9 @@ Rsa2048Sha256GuidedSectionHandler (
     CertBlockRsa2048Sha256 = &((RSA_2048_SHA_256_SECTION_HEADER *)InputSection)->CertBlockRsa2048Sha256;\r
     OutputBufferSize       = SECTION_SIZE (InputSection) - sizeof (RSA_2048_SHA_256_SECTION_HEADER);\r
     if ((((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) != 0) {\r
-      PERF_START (NULL, "RsaCopy", "PEI", 0);\r
+      PERF_INMODULE_BEGIN ("PeiRsaCopy");\r
       CopyMem (*OutputBuffer, (UINT8 *)InputSection + sizeof (RSA_2048_SHA_256_SECTION_HEADER), OutputBufferSize);\r
-      PERF_END (NULL, "RsaCopy", "PEI", 0);\r
+      PERF_INMODULE_END ("PeiRsaCopy");\r
     } else {\r
       *OutputBuffer = (UINT8 *)InputSection + sizeof (RSA_2048_SHA_256_SECTION_HEADER);\r
     }\r
@@ -311,9 +311,9 @@ Rsa2048Sha256GuidedSectionHandler (
     *AuthenticationStatus |= EFI_AUTH_STATUS_TEST_FAILED;\r
     goto Done;\r
   }\r
-  PERF_START (NULL, "RsaShaData", "PEI", 0);\r
+  PERF_INMODULE_BEGIN ("PeiRsaShaData");\r
   CryptoStatus = Sha256Update (HashContext, *OutputBuffer, OutputBufferSize);\r
-  PERF_END (NULL, "RsaShaData", "PEI", 0);\r
+  PERF_INMODULE_END ("PeiRsaShaData");\r
   if (!CryptoStatus) {\r
     DEBUG ((DEBUG_ERROR, "PeiRsa2048Sha256: Sha256Update() failed\n"));\r
     *AuthenticationStatus |= EFI_AUTH_STATUS_TEST_FAILED;\r
@@ -329,7 +329,7 @@ Rsa2048Sha256GuidedSectionHandler (
   //\r
   // Verify the RSA 2048 SHA 256 signature.\r
   //\r
-  PERF_START (NULL, "RsaVerify", "PEI", 0);\r
+  PERF_INMODULE_BEGIN ("PeiRsaVerify");\r
   CryptoStatus = RsaPkcs1Verify (\r
                    Rsa, \r
                    Digest, \r
@@ -337,7 +337,7 @@ Rsa2048Sha256GuidedSectionHandler (
                    CertBlockRsa2048Sha256->Signature, \r
                    sizeof (CertBlockRsa2048Sha256->Signature)\r
                    );\r
-  PERF_END (NULL, "RsaVerify", "PEI", 0);\r
+  PERF_INMODULE_END ("PeiRsaVerify");\r
   if (!CryptoStatus) {\r
     //\r
     // If RSA 2048 SHA 256 signature verification fails, AUTH tested failed bit is set.\r
@@ -357,12 +357,6 @@ Done:
     FreePool (HashContext);\r
   }\r
 \r
-  //\r
-  // Temp solution until PeiCore checks AUTH Status.\r
-  //\r
-  if ((*AuthenticationStatus & (EFI_AUTH_STATUS_TEST_FAILED | EFI_AUTH_STATUS_NOT_TESTED)) != 0) {\r
-    Status = EFI_ACCESS_DENIED;\r
-  }\r
   DEBUG ((DEBUG_VERBOSE, "PeiRsa2048Sha256: Status = %r  AuthenticationStatus = %08x\n", Status, *AuthenticationStatus));\r
 \r
   return Status;\r