diff options
author | Richard Levitte <levitte@openssl.org> | 2019-05-23 03:27:37 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-11-20 14:22:35 +0100 |
commit | 6a835fcfb10ba004498f9e39873db3d2b9011609 (patch) | |
tree | 5188724c2854ee6bb4997ef21a4810f6393fdd9f /crypto/evp/evp_enc.c | |
parent | 9ce91035bcf7d74fe15c94650f3bc1f89b7c0f07 (diff) |
Replumbing: pre-populate the EVP namemap with commonly known names
This adds ossl_namemap_empty(), to detect if a namemap is empty and
can thereby be pre-populated.
This also affects the way legacy NIDs are looked up in
evp_cipher_from_dispatch() and evp_md_from_dispatch(). Instead of
trying to find the NID directly, look up the legacy method structure
and grab the NID from there. The reason is that NIDs can be aliases
for other NIDs, which looks like a clash even if wasn't really one.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8984)
Diffstat (limited to 'crypto/evp/evp_enc.c')
-rw-r--r-- | crypto/evp/evp_enc.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index 45e1dc67c2..da6dde0c4d 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -1359,12 +1359,18 @@ static void set_legacy_nid(const char *name, void *vlegacy_nid) { int nid; int *legacy_nid = vlegacy_nid; + /* + * We use lowest level function to get the associated method, because + * higher level functions such as EVP_get_cipherbyname() have changed + * to look at providers too. + */ + const void *legacy_method = OBJ_NAME_get(name, OBJ_NAME_TYPE_CIPHER_METH); if (*legacy_nid == -1) /* We found a clash already */ return; - if ((nid = OBJ_sn2nid(name)) == NID_undef - && (nid = OBJ_ln2nid(name)) == NID_undef) + if (legacy_method == NULL) return; + nid = EVP_CIPHER_nid(legacy_method); if (*legacy_nid != NID_undef && *legacy_nid != nid) { *legacy_nid = -1; return; |