diff options
author | Richard Levitte <levitte@openssl.org> | 2020-08-05 10:40:01 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-08-07 04:14:59 +0200 |
commit | 90ef39f43ad5bf4e85c56a79d0b56fb590b3c7f7 (patch) | |
tree | 8a71a0bf387898f5e08b4911af5de868c94b2cf5 | |
parent | a7922e208ddfbdcff44d1b3fa5839f96510d04bd (diff) |
EVP: Fix the returned value for ASN1_PKEY_CTRL_DEFAULT_MD_NID
Trust the returned value from EVP_PKEY_get_default_digest_name()! It
mimics exactly the values that EVP_PKEY_get_default_digest_nid() is
supposed to return, and that value should simply be passed unchanged.
Callers depend on it.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12586)
-rw-r--r-- | crypto/evp/p_lib.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 3e3f2118a2..2563cd97ca 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -1202,19 +1202,18 @@ static int legacy_asn1_ctrl_to_param(EVP_PKEY *pkey, int op, case ASN1_PKEY_CTRL_DEFAULT_MD_NID: { char mdname[80] = ""; - int nid; int rv = EVP_PKEY_get_default_digest_name(pkey, mdname, sizeof(mdname)); - if (rv <= 0) - return rv; - nid = OBJ_sn2nid(mdname); - if (nid == NID_undef) - nid = OBJ_ln2nid(mdname); - if (nid == NID_undef) - return 0; - *(int *)arg2 = nid; - return 1; + if (rv > 0) { + int nid; + + nid = OBJ_sn2nid(mdname); + if (nid == NID_undef) + nid = OBJ_ln2nid(mdname); + *(int *)arg2 = nid; + } + return rv; } default: return -2; |