diff options
author | Richard Levitte <levitte@openssl.org> | 2021-03-11 13:36:06 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2021-04-18 10:10:24 +0200 |
commit | 01ba6c8e438ea2d31c92fe2f386e6ce5809f29f0 (patch) | |
tree | 28057e0df17db961a95cd00eae235f58b4963d4b /crypto | |
parent | ad57a13bb86949a9e9adc7a2960e3f39e3e5b284 (diff) |
CORE: Register all legacy "names" when generating the initial namemap
When generating the initial namemap from EVP cipher and digest names,
we din't do it quite as thoroughly as necessary, which meant that so
called "long names" weren't necessarily registered, and if anyone ever
tried to check the algorithm of an EVP_CIPHER or EVP_MD using a so
called "long name" would fail.
This doesn't deal with the fact that "long names" have a distinct role
as human readable descriptors, useful for printouts. Further changes
are necessary to deal with this.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14498)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/core_namemap.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/crypto/core_namemap.c b/crypto/core_namemap.c index ae9aa19c3f..89c92bdd92 100644 --- a/crypto/core_namemap.c +++ b/crypto/core_namemap.c @@ -378,45 +378,45 @@ int ossl_namemap_add_names(OSSL_NAMEMAP *namemap, int number, #include <openssl/evp.h> /* Creates an initial namemap with names found in the legacy method db */ -static void get_legacy_evp_names(const char *main_name, const char *alias, +static void get_legacy_evp_names(const char *name, const char *desc, void *arg) { - int main_id = ossl_namemap_add_name(arg, 0, main_name); + int num = ossl_namemap_add_name(arg, 0, name); /* - * We could check that the returned value is the same as main_id, - * but since this is a void function, there's no sane way to report - * the error. The best we can do is trust ourselve to keep the legacy - * method database conflict free. + * We currently treat the description ("long name" in OBJ speak) as an + * alias. + */ + + /* + * We could check that the returned value is the same as id, but since + * this is a void function, there's no sane way to report the error. + * The best we can do is trust ourselve to keep the legacy method + * database conflict free. * * This registers any alias with the same number as the main name. * Should it be that the current |on| *has* the main name, this is * simply a no-op. */ - if (alias != NULL) { - (void)ossl_namemap_add_name(arg, main_id, alias); + if (desc != NULL) { + (void)ossl_namemap_add_name(arg, num, desc); } } static void get_legacy_cipher_names(const OBJ_NAME *on, void *arg) { const EVP_CIPHER *cipher = (void *)OBJ_NAME_get(on->name, on->type); + int nid = EVP_CIPHER_type(cipher); - get_legacy_evp_names(EVP_CIPHER_name(cipher), on->name, arg); + get_legacy_evp_names(OBJ_nid2sn(nid), OBJ_nid2ln(nid), arg); } static void get_legacy_md_names(const OBJ_NAME *on, void *arg) { const EVP_MD *md = (void *)OBJ_NAME_get(on->name, on->type); - /* We don't want the pkey_type names, so we need some extra care */ - int snid, lnid; - - snid = OBJ_sn2nid(on->name); - lnid = OBJ_ln2nid(on->name); - if (snid != EVP_MD_pkey_type(md) && lnid != EVP_MD_pkey_type(md)) - get_legacy_evp_names(EVP_MD_name(md), on->name, arg); - else - get_legacy_evp_names(EVP_MD_name(md), NULL, arg); + int nid = EVP_MD_type(md); + + get_legacy_evp_names(OBJ_nid2sn(nid), OBJ_nid2ln(nid), arg); } #endif |