]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Sign.c
CryptoPkg/BaseCryptLib: Add missing OpenSSL includes
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / Pk / CryptPkcs7Sign.c
index 25865910f69b072eb9cafce1e0596ee8add26836..704eb4ec94003b54f7ff2536fc918ebf72b8177e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   PKCS#7 SignedData Sign Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\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
@@ -116,15 +116,21 @@ Pkcs7Sign (
   if (Key == NULL) {\r
     goto _Exit;\r
   }\r
-  Key->save_type = EVP_PKEY_RSA;\r
-  Key->type      = EVP_PKEY_type (EVP_PKEY_RSA);\r
-  Key->pkey.rsa  = (RSA *) RsaContext;\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
   //\r
   DataBio = BIO_new (BIO_s_mem ());\r
-  BIO_write (DataBio, InData, (int) InDataSize);\r
+  if (DataBio == NULL) {\r
+    goto _Exit;\r
+  }\r
+\r
+  if (BIO_write (DataBio, InData, (int) InDataSize) <= 0) {\r
+    goto _Exit;\r
+  }\r
 \r
   //\r
   // Create the PKCS#7 signedData structure.\r
@@ -155,6 +161,7 @@ Pkcs7Sign (
 \r
   Tmp        = P7Data;\r
   P7DataSize = i2d_PKCS7 (Pkcs7, (unsigned char **) &Tmp);\r
+  ASSERT (P7DataSize > 19);\r
 \r
   //\r
   // Strip ContentInfo to content only for signeddata. The data be trimmed off\r
@@ -168,7 +175,7 @@ Pkcs7Sign (
   }\r
 \r
   CopyMem (*SignedData, P7Data + 19, *SignedDataSize);\r
-  \r
+\r
   OPENSSL_free (P7Data);\r
 \r
   Status = TRUE;\r