From: Dmitry Belyavskiy Date: Thu, 18 May 2023 13:38:56 +0000 (+0200) Subject: If oaep_md is not initialized, correctly initialize it X-Git-Tag: openssl-3.2.0-alpha1~794 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5aa719502f1ef456b27347e5f7b15c07817da4e;p=thirdparty%2Fopenssl.git If oaep_md is not initialized, correctly initialize it Fixes #20993 Reviewed-by: Matt Caswell Reviewed-by: Paul Dale Reviewed-by: Shane Lontis Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/20994) --- diff --git a/providers/implementations/asymciphers/rsa_enc.c b/providers/implementations/asymciphers/rsa_enc.c index 884c032d211..be795251007 100644 --- a/providers/implementations/asymciphers/rsa_enc.c +++ b/providers/implementations/asymciphers/rsa_enc.c @@ -162,10 +162,12 @@ static int rsa_encrypt(void *vprsactx, unsigned char *out, size_t *outlen, if ((tbuf = OPENSSL_malloc(rsasize)) == NULL) 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,