summaryrefslogtreecommitdiff
path: root/Cryptlib/Pem
diff options
context:
space:
mode:
authorSteve Langasek <steve.langasek@canonical.com>2014-10-06 15:39:48 -0700
committerSteve Langasek <steve.langasek@canonical.com>2014-10-06 15:39:48 -0700
commit72bb39c0237f8bcc3afa8b623e8b097eec6d69cd (patch)
treeab49a0f8e82cdee502fd556ad7ccca3242f40f05 /Cryptlib/Pem
parentbfab8d6791bccc38a8604cbc933048319c920780 (diff)
downloadefi-boot-shim-72bb39c0237f8bcc3afa8b623e8b097eec6d69cd.tar.gz
efi-boot-shim-72bb39c0237f8bcc3afa8b623e8b097eec6d69cd.zip
Import upstream version 0.7
Diffstat (limited to 'Cryptlib/Pem')
-rw-r--r--Cryptlib/Pem/CryptPem.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/Cryptlib/Pem/CryptPem.c b/Cryptlib/Pem/CryptPem.c
index 2c3a97b2..51e648b7 100644
--- a/Cryptlib/Pem/CryptPem.c
+++ b/Cryptlib/Pem/CryptPem.c
@@ -1,7 +1,7 @@
/** @file
PEM (Privacy Enhanced Mail) Format Handler Wrapper Implementation over OpenSSL.
-Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -36,7 +36,7 @@ PasswordCallback (
{
INTN KeyLength;
- ZeroMem ((VOID *)Buf, (UINTN)Size);
+ ZeroMem ((VOID *) Buf, (UINTN) Size);
if (Key != NULL) {
//
// Duplicate key phrase directly.
@@ -86,31 +86,41 @@ RsaGetPrivateKeyFromPem (
return FALSE;
}
- Status = FALSE;
- PemBio = NULL;
-
//
// Add possible block-cipher descriptor for PEM data decryption.
// NOTE: Only support most popular ciphers (3DES, AES) for the encrypted PEM.
//
- EVP_add_cipher (EVP_des_ede3_cbc());
- EVP_add_cipher (EVP_aes_128_cbc());
- EVP_add_cipher (EVP_aes_192_cbc());
- EVP_add_cipher (EVP_aes_256_cbc());
+ if (EVP_add_cipher (EVP_des_ede3_cbc ()) == 0) {
+ return FALSE;
+ }
+ if (EVP_add_cipher (EVP_aes_128_cbc ()) == 0) {
+ return FALSE;
+ }
+ if (EVP_add_cipher (EVP_aes_192_cbc ()) == 0) {
+ return FALSE;
+ }
+ if (EVP_add_cipher (EVP_aes_256_cbc ()) == 0) {
+ return FALSE;
+ }
+
+ Status = FALSE;
//
// Read encrypted PEM Data.
//
PemBio = BIO_new (BIO_s_mem ());
- BIO_write (PemBio, PemData, (int)PemSize);
if (PemBio == NULL) {
goto _Exit;
}
+ if (BIO_write (PemBio, PemData, (int) PemSize) <= 0) {
+ goto _Exit;
+ }
+
//
// Retrieve RSA Private Key from encrypted PEM data.
//
- *RsaContext = PEM_read_bio_RSAPrivateKey (PemBio, NULL, (pem_password_cb *)&PasswordCallback, (void *)Password);
+ *RsaContext = PEM_read_bio_RSAPrivateKey (PemBio, NULL, (pem_password_cb *) &PasswordCallback, (void *) Password);
if (*RsaContext != NULL) {
Status = TRUE;
}