Skip to content

Commit

Permalink
Don't crash if an unrecognised digest is used with dsa_paramgen_md
Browse files Browse the repository at this point in the history
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from #5800)
  • Loading branch information
mattcaswell committed Apr 5, 2018
1 parent fdb8113 commit 06d3b48
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crypto/dsa/dsa_pmeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 06d3b48

Please sign in to comment.