summaryrefslogtreecommitdiffstats
path: root/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs1Oaep.c
diff options
context:
space:
mode:
Diffstat (limited to 'CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs1Oaep.c')
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs1Oaep.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs1Oaep.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs1Oaep.c
index 970fa2a36e..ea43c1381c 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs1Oaep.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs1Oaep.c
@@ -67,8 +67,9 @@ Pkcs1v2Encrypt (
//
// Check input parameters.
//
- if (PublicKey == NULL || InData == NULL ||
- EncryptedData == NULL || EncryptedDataSize == NULL) {
+ if ((PublicKey == NULL) || (InData == NULL) ||
+ (EncryptedData == NULL) || (EncryptedDataSize == NULL))
+ {
return FALSE;
}
@@ -82,15 +83,15 @@ Pkcs1v2Encrypt (
return FALSE;
}
- *EncryptedData = NULL;
- *EncryptedDataSize = 0;
- Result = FALSE;
- TempPointer = NULL;
- CertData = NULL;
- InternalPublicKey = NULL;
- PkeyCtx = NULL;
- OutData = NULL;
- OutDataSize = 0;
+ *EncryptedData = NULL;
+ *EncryptedDataSize = 0;
+ Result = FALSE;
+ TempPointer = NULL;
+ CertData = NULL;
+ InternalPublicKey = NULL;
+ PkeyCtx = NULL;
+ OutData = NULL;
+ OutDataSize = 0;
//
// If it provides a seed then use it.
@@ -107,7 +108,7 @@ Pkcs1v2Encrypt (
// Parse the X509 cert and extract the public key.
//
TempPointer = PublicKey;
- CertData = d2i_X509 (&CertData, &TempPointer, (UINT32)PublicKeySize);
+ CertData = d2i_X509 (&CertData, &TempPointer, (UINT32)PublicKeySize);
if (CertData == NULL) {
//
// Fail to parse X509 cert.
@@ -137,11 +138,13 @@ Pkcs1v2Encrypt (
//
goto _Exit;
}
+
//
// Initialize the context and set the desired padding.
//
- if (EVP_PKEY_encrypt_init (PkeyCtx) <= 0 ||
- EVP_PKEY_CTX_set_rsa_padding (PkeyCtx, RSA_PKCS1_OAEP_PADDING) <= 0) {
+ if ((EVP_PKEY_encrypt_init (PkeyCtx) <= 0) ||
+ (EVP_PKEY_CTX_set_rsa_padding (PkeyCtx, RSA_PKCS1_OAEP_PADDING) <= 0))
+ {
//
// Fail to initialize the context.
//
@@ -177,7 +180,7 @@ Pkcs1v2Encrypt (
// Fail to encrypt data, need to free the output buffer.
//
FreePool (OutData);
- OutData = NULL;
+ OutData = NULL;
OutDataSize = 0;
goto _Exit;
}
@@ -185,20 +188,22 @@ Pkcs1v2Encrypt (
//
// Encrypt done.
//
- *EncryptedData = OutData;
+ *EncryptedData = OutData;
*EncryptedDataSize = OutDataSize;
- Result = TRUE;
+ Result = TRUE;
_Exit:
//
// Release Resources
//
if (CertData != NULL) {
- X509_free (CertData );
+ X509_free (CertData);
}
+
if (InternalPublicKey != NULL) {
EVP_PKEY_free (InternalPublicKey);
}
+
if (PkeyCtx != NULL) {
EVP_PKEY_CTX_free (PkeyCtx);
}