From: Matt Caswell Date: Thu, 29 Mar 2018 16:48:28 +0000 (+0100) Subject: Don't crash if an unrecognised digest is used with dsa_paramgen_md X-Git-Tag: OpenSSL_1_1_1-pre5~56 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=06d3b485db8b6bfd5437c9998d92e882a3cdfa1f;p=oweals%2Fopenssl.git Don't crash if an unrecognised digest is used with dsa_paramgen_md Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/5800) --- diff --git a/crypto/dsa/dsa_pmeth.c b/crypto/dsa/dsa_pmeth.c index 88744a9ce2..493427667e 100644 --- a/crypto/dsa/dsa_pmeth.c +++ b/crypto/dsa/dsa_pmeth.c @@ -189,9 +189,15 @@ static int pkey_dsa_ctrl_str(EVP_PKEY_CTX *ctx, NULL); } if (strcmp(type, "dsa_paramgen_md") == 0) { + const EVP_MD *md = EVP_get_digestbyname(value); + + if (md == NULL) { + DSAerr(DSA_F_PKEY_DSA_CTRL_STR, DSA_R_INVALID_DIGEST_TYPE); + return 0; + } return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, - (void *)EVP_get_digestbyname(value)); + (void *)md); } return -2; }