]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Sign.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / Pk / CryptPkcs7Sign.c
index 0f61d4b4ad4b9ce1f6b919e95c26100fae24cf16..3f8b4642442d79f623cff73a5a978f66056be5db 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   PKCS#7 SignedData Sign Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2009 - 2017, 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
+Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -68,8 +62,9 @@ Pkcs7Sign (
   //\r
   // Check input parameters.\r
   //\r
-  if (PrivateKey == NULL || KeyPassword == NULL || InData == NULL ||\r
-    SignCert == NULL || SignedData == NULL || SignedDataSize == NULL || InDataSize > INT_MAX) {\r
+  if ((PrivateKey == NULL) || (KeyPassword == NULL) || (InData == NULL) ||\r
+      (SignCert == NULL) || (SignedData == NULL) || (SignedDataSize == NULL) || (InDataSize > INT_MAX))\r
+  {\r
     return FALSE;\r
   }\r
 \r
@@ -85,8 +80,8 @@ Pkcs7Sign (
   Status = RsaGetPrivateKeyFromPem (\r
              PrivateKey,\r
              PrivateKeySize,\r
-             (CONST CHAR8 *) KeyPassword,\r
-             (VOID **) &RsaContext\r
+             (CONST CHAR8 *)KeyPassword,\r
+             (VOID **)&RsaContext\r
              );\r
   if (!Status) {\r
     return Status;\r
@@ -100,9 +95,11 @@ Pkcs7Sign (
   if (EVP_add_digest (EVP_md5 ()) == 0) {\r
     goto _Exit;\r
   }\r
+\r
   if (EVP_add_digest (EVP_sha1 ()) == 0) {\r
     goto _Exit;\r
   }\r
+\r
   if (EVP_add_digest (EVP_sha256 ()) == 0) {\r
     goto _Exit;\r
   }\r
@@ -116,19 +113,20 @@ Pkcs7Sign (
   if (Key == NULL) {\r
     goto _Exit;\r
   }\r
-  if (EVP_PKEY_assign_RSA (Key, (RSA *) RsaContext) == 0) {\r
+\r
+  if (EVP_PKEY_assign_RSA (Key, (RSA *)RsaContext) == 0) {\r
     goto _Exit;\r
   }\r
 \r
   //\r
-  // Convert the data to be signed to BIO format. \r
+  // Convert the data to be signed to BIO format.\r
   //\r
   DataBio = BIO_new (BIO_s_mem ());\r
   if (DataBio == NULL) {\r
     goto _Exit;\r
   }\r
 \r
-  if (BIO_write (DataBio, InData, (int) InDataSize) <= 0) {\r
+  if (BIO_write (DataBio, InData, (int)InDataSize) <= 0) {\r
     goto _Exit;\r
   }\r
 \r
@@ -136,9 +134,9 @@ Pkcs7Sign (
   // Create the PKCS#7 signedData structure.\r
   //\r
   Pkcs7 = PKCS7_sign (\r
-            (X509 *) SignCert,\r
+            (X509 *)SignCert,\r
             Key,\r
-            (STACK_OF(X509) *) OtherCerts,\r
+            (STACK_OF (X509) *) OtherCerts,\r
             DataBio,\r
             PKCS7_BINARY | PKCS7_NOATTR | PKCS7_DETACHED\r
             );\r
@@ -154,13 +152,13 @@ Pkcs7Sign (
     goto _Exit;\r
   }\r
 \r
-  P7Data     = malloc (P7DataSize);\r
+  P7Data = malloc (P7DataSize);\r
   if (P7Data == NULL) {\r
     goto _Exit;\r
   }\r
 \r
   Tmp        = P7Data;\r
-  P7DataSize = i2d_PKCS7 (Pkcs7, (unsigned char **) &Tmp);\r
+  P7DataSize = i2d_PKCS7 (Pkcs7, (unsigned char **)&Tmp);\r
   ASSERT (P7DataSize > 19);\r
 \r
   //\r