diff options
author | Richard Levitte <levitte@openssl.org> | 2020-01-15 01:04:37 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-01-17 08:59:41 +0100 |
commit | e4a1d0230016d090ba78bc7092384315f85b0e72 (patch) | |
tree | 518e1155d0185622e42d10918b9b0ca9a2317c3a /crypto/evp/evp_lib.c | |
parent | 9bb3e5fd87905e3e9f5f7edcc2e22d98360510ab (diff) |
Modify EVP_CIPHER_is_a() and EVP_MD_is_a() to handle legacy methods too
These functions would only handle provided methods, but there are
cases where the caller just passes along a received method without
knowing the underlying method tech, so might pass along a legacy
method. We therefore need to have them handle this case as well so
they don't cause any unnecessary surprises.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10845)
Diffstat (limited to 'crypto/evp/evp_lib.c')
-rw-r--r-- | crypto/evp/evp_lib.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index 3c2083148e..2b51267179 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -532,14 +532,9 @@ int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx) int EVP_CIPHER_is_a(const EVP_CIPHER *cipher, const char *name) { -#ifndef FIPS_MODE - if (cipher->prov == NULL) { - int nid = EVP_CIPHER_nid(cipher); - - return nid == OBJ_sn2nid(name) || nid == OBJ_ln2nid(name); - } -#endif - return evp_is_a(cipher->prov, cipher->name_id, name); + if (cipher->prov != NULL) + return evp_is_a(cipher->prov, cipher->name_id, NULL, name); + return evp_is_a(NULL, 0, EVP_CIPHER_name(cipher), name); } int EVP_CIPHER_number(const EVP_CIPHER *cipher) @@ -578,7 +573,9 @@ int EVP_CIPHER_mode(const EVP_CIPHER *cipher) int EVP_MD_is_a(const EVP_MD *md, const char *name) { - return evp_is_a(md->prov, md->name_id, name); + if (md->prov != NULL) + return evp_is_a(md->prov, md->name_id, NULL, name); + return evp_is_a(NULL, 0, EVP_MD_name(md), name); } int EVP_MD_number(const EVP_MD *md) |