mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
fix: ossl_digest_get_approved_nid() returns NID_undef on invalid digest
We checked using 'md_nid < 0', which is faulty. Impact: DSA and ECDSA signature provider implementations Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Viktor Dukhovni <viktor@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/24992)
This commit is contained in:
parent
f68ba38e18
commit
d1c2c054a4
@ -168,7 +168,7 @@ static int dsa_setup_md(PROV_DSA_CTX *ctx,
|
||||
if (md == NULL)
|
||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST,
|
||||
"%s could not be fetched", mdname);
|
||||
if (md_nid < 0)
|
||||
if (md_nid == NID_undef)
|
||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED,
|
||||
"digest=%s", mdname);
|
||||
if (mdname_len >= sizeof(ctx->mdname))
|
||||
|
@ -197,7 +197,7 @@ static int ecdsa_setup_md(PROV_ECDSA_CTX *ctx,
|
||||
goto err;
|
||||
}
|
||||
md_nid = ossl_digest_get_approved_nid(md);
|
||||
if (md_nid < 0) {
|
||||
if (md_nid == NID_undef) {
|
||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED,
|
||||
"digest=%s", mdname);
|
||||
goto err;
|
||||
|
@ -387,7 +387,7 @@ static int rsa_setup_md(PROV_RSA_CTX *ctx, const char *mdname,
|
||||
goto err;
|
||||
}
|
||||
md_nid = ossl_digest_rsa_sign_get_md_nid(md);
|
||||
if (md_nid <= 0) {
|
||||
if (md_nid == NID_undef) {
|
||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED,
|
||||
"digest=%s", mdname);
|
||||
goto err;
|
||||
|
Loading…
Reference in New Issue
Block a user