summaryrefslogtreecommitdiffstats
path: root/providers/implementations/asymciphers
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2023-05-18 15:38:56 +0200
committerTomas Mraz <tomas@openssl.org>2023-05-23 15:10:56 +0200
commitd411105a7f62c1b5894062bd54408c1ee798edc9 (patch)
tree02dad0c4ed4e38e5c9cf457a86bcf281460f0507 /providers/implementations/asymciphers
parent3ea88ee374a9ea973a5b95db907155226ce19b61 (diff)
If oaep_md is not initialized, correctly initialize it
Fixes #20993 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20994) (cherry picked from commit c5aa719502f1ef456b27347e5f7b15c07817da4e)
Diffstat (limited to 'providers/implementations/asymciphers')
-rw-r--r--providers/implementations/asymciphers/rsa_enc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/providers/implementations/asymciphers/rsa_enc.c b/providers/implementations/asymciphers/rsa_enc.c
index 568452ec56..d1ceae546e 100644
--- a/providers/implementations/asymciphers/rsa_enc.c
+++ b/providers/implementations/asymciphers/rsa_enc.c
@@ -161,10 +161,12 @@ static int rsa_encrypt(void *vprsactx, unsigned char *out, size_t *outlen,
return 0;
}
if (prsactx->oaep_md == NULL) {
- OPENSSL_free(tbuf);
prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL);
- ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
- return 0;
+ if (prsactx->oaep_md == NULL) {
+ OPENSSL_free(tbuf);
+ ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
+ return 0;
+ }
}
ret =
ossl_rsa_padding_add_PKCS1_OAEP_mgf1_ex(prsactx->libctx, tbuf,