summaryrefslogtreecommitdiffstats
path: root/crypto/core_namemap.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-05-23 03:27:37 +0200
committerRichard Levitte <levitte@openssl.org>2019-11-20 14:22:35 +0100
commit6a835fcfb10ba004498f9e39873db3d2b9011609 (patch)
tree5188724c2854ee6bb4997ef21a4810f6393fdd9f /crypto/core_namemap.c
parent9ce91035bcf7d74fe15c94650f3bc1f89b7c0f07 (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/core_namemap.c')
-rw-r--r--crypto/core_namemap.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/crypto/core_namemap.c b/crypto/core_namemap.c
index 71b70ff5aa..e5a17272d8 100644
--- a/crypto/core_namemap.c
+++ b/crypto/core_namemap.c
@@ -119,6 +119,18 @@ void ossl_namemap_free(OSSL_NAMEMAP *namemap)
OPENSSL_free(namemap);
}
+int ossl_namemap_empty(OSSL_NAMEMAP *namemap)
+{
+ int rv = 0;
+
+ CRYPTO_THREAD_read_lock(namemap->lock);
+ if (namemap->max_number == 0)
+ rv = 1;
+ CRYPTO_THREAD_unlock(namemap->lock);
+
+ return rv;
+}
+
typedef struct doall_names_data_st {
int number;
void (*fn)(const char *name, void *data);