30 lines
1.3 KiB
Diff
30 lines
1.3 KiB
Diff
diff --git a/crypto/crmf/crmf_lib.c b/crypto/crmf/crmf_lib.c
|
|
index d5ad51e4503..5747ab18569 100644
|
|
--- a/crypto/crmf/crmf_lib.c
|
|
+++ b/crypto/crmf/crmf_lib.c
|
|
@@ -762,6 +762,7 @@ unsigned char *OSSL_CRMF_ENCRYPTEDVALUE_decrypt(const OSSL_CRMF_ENCRYPTEDVALUE *
|
|
EVP_CIPHER *cipher = NULL; /* used cipher */
|
|
int cikeysize = 0; /* key size from cipher */
|
|
unsigned char *iv = NULL; /* initial vector for symmetric encryption */
|
|
+ int iv_len; /* iv length */
|
|
unsigned char *out = NULL; /* decryption output buffer */
|
|
int n, ret = 0;
|
|
EVP_PKEY_CTX *pkctx = NULL; /* private key context */
|
|
@@ -811,11 +812,12 @@ unsigned char *OSSL_CRMF_ENCRYPTEDVALUE_decrypt(const OSSL_CRMF_ENCRYPTEDVALUE *
|
|
} else {
|
|
goto end;
|
|
}
|
|
- if ((iv = OPENSSL_malloc(EVP_CIPHER_get_iv_length(cipher))) == NULL)
|
|
+ iv_len = EVP_CIPHER_get_iv_length(cipher);
|
|
+ if ((iv = OPENSSL_malloc(iv_len)) == NULL)
|
|
goto end;
|
|
- if (ASN1_TYPE_get_octetstring(enc->symmAlg->parameter, iv,
|
|
- EVP_CIPHER_get_iv_length(cipher))
|
|
- != EVP_CIPHER_get_iv_length(cipher)) {
|
|
+ if (enc->symmAlg->parameter == NULL
|
|
+ || ASN1_TYPE_get_octetstring(enc->symmAlg->parameter, iv, iv_len)
|
|
+ != iv_len) {
|
|
ERR_raise(ERR_LIB_CRMF, CRMF_R_MALFORMED_IV);
|
|
goto end;
|
|
}
|