summaryrefslogtreecommitdiffstats
path: root/crypto/cms
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-12-25 13:38:23 +0100
committerDr. David von Oheimb <dev@ddvo.net>2023-05-30 22:02:10 +0200
commit36b91a198ae027c054ef128a35a268bc3c307f00 (patch)
treea47bf3a4c012fb34c51c8c34f973e15dc912f9b4 /crypto/cms
parentfdef95716dbcc6127d05f8cfc90f389a84acaf9b (diff)
CMS, PKCS7, and CRMF: simplify use of EVP_PKEY_decrypt() by helper function
Also remove needless constant_time_* and ERR_clear_error() calls from OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert(). Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/17354)
Diffstat (limited to 'crypto/cms')
-rw-r--r--crypto/cms/cms_env.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/crypto/cms/cms_env.c b/crypto/cms/cms_env.c
index c55511011f..2b06da468e 100644
--- a/crypto/cms/cms_env.c
+++ b/crypto/cms/cms_env.c
@@ -615,24 +615,11 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms,
* disable implicit rejection for RSA keys */
EVP_PKEY_CTX_ctrl_str(ktri->pctx, "rsa_pkcs1_implicit_rejection", "0");
- if (EVP_PKEY_decrypt(ktri->pctx, NULL, &eklen,
- ktri->encryptedKey->data,
- ktri->encryptedKey->length) <= 0)
+ if (evp_pkey_decrypt_alloc(ktri->pctx, &ek, &eklen, fixlen,
+ ktri->encryptedKey->data,
+ ktri->encryptedKey->length) <= 0)
goto err;
- ek = OPENSSL_malloc(eklen);
- if (ek == NULL)
- goto err;
-
- if (EVP_PKEY_decrypt(ktri->pctx, ek, &eklen,
- ktri->encryptedKey->data,
- ktri->encryptedKey->length) <= 0
- || eklen == 0
- || (fixlen != 0 && eklen != fixlen)) {
- ERR_raise(ERR_LIB_CMS, CMS_R_CMS_LIB);
- goto err;
- }
-
ret = 1;
OPENSSL_clear_free(ec->key, ec->keylen);