diff options
author | Matt Caswell <matt@openssl.org> | 2018-03-29 17:48:28 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2018-04-05 17:02:43 +0100 |
commit | 5dcd9b1c7c138576d39aa2b5669270a570eb6b9f (patch) | |
tree | 2aad8a8752f9921f15d51d4569bd51ffad03c3af | |
parent | 23dec58b9c2e36311208a90efb3d56818a9ed6fd (diff) |
Don't crash if an unrecognised digest is used with dsa_paramgen_md
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5883)
-rw-r--r-- | crypto/dsa/dsa_pmeth.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/dsa/dsa_pmeth.c b/crypto/dsa/dsa_pmeth.c index 95f088a5ec..a1cbaadc64 100644 --- a/crypto/dsa/dsa_pmeth.c +++ b/crypto/dsa/dsa_pmeth.c @@ -187,9 +187,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; } |