]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Sign.c
CryptoPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / Pk / CryptPkcs7Sign.c
index 704eb4ec94003b54f7ff2536fc918ebf72b8177e..442f573f8bddb108bd0859f69c8fef59f903006b 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   PKCS#7 SignedData Sign Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2009 - 2015, 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
@@ -18,7 +12,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <openssl/x509.h>\r
 #include <openssl/pkcs7.h>\r
 \r
-\r
 /**\r
   Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message\r
   Syntax Standard, version 1.5". This interface is only intended to be used for\r
@@ -35,7 +28,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @param[in]  OtherCerts       Pointer to an optional additional set of certificates to\r
                                include in the PKCS#7 signedData (e.g. any intermediate\r
                                CAs in the chain).\r
-  @param[out] SignedData       Pointer to output PKCS#7 signedData.\r
+  @param[out] SignedData       Pointer to output PKCS#7 signedData. It's caller's\r
+                               responsibility to free the buffer with FreePool().\r
   @param[out] SignedDataSize   Size of SignedData in bytes.\r
 \r
   @retval     TRUE             PKCS#7 data signing succeeded.\r
@@ -121,7 +115,7 @@ Pkcs7Sign (
   }\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
@@ -168,7 +162,7 @@ Pkcs7Sign (
   // is totally 19 bytes.\r
   //\r
   *SignedDataSize = P7DataSize - 19;\r
-  *SignedData     = malloc (*SignedDataSize);\r
+  *SignedData     = AllocatePool (*SignedDataSize);\r
   if (*SignedData == NULL) {\r
     OPENSSL_free (P7Data);\r
     goto _Exit;\r
@@ -184,13 +178,6 @@ _Exit:
   //\r
   // Release Resources\r
   //\r
-  if (RsaContext != NULL) {\r
-    RsaFree (RsaContext);\r
-    if (Key != NULL) {\r
-      Key->pkey.rsa = NULL;\r
-    }\r
-  }\r
-\r
   if (Key != NULL) {\r
     EVP_PKEY_free (Key);\r
   }\r