summaryrefslogtreecommitdiffstats
path: root/crypto/core_namemap.c
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2022-03-14 08:13:12 +0000
committerTomas Mraz <tomas@openssl.org>2022-11-21 10:49:51 +0100
commit8436ef8bdb96c0a977a15ec707d28404d97c3a6c (patch)
tree4af422951654f59fbd8e100892ecb21f3475c941 /crypto/core_namemap.c
parentee246234bf591cd2a9779a4ad3a2ee3c53848213 (diff)
Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA
This refactors OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA. The assorted objects to be managed by OSSL_LIB_CTX are hardcoded and are initialized eagerly rather than lazily, which avoids the need for locking on access in most cases. Fixes #17116. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17881) (cherry picked from commit 927d0566ded0dff9d6c5abc8a40bb84068446b76)
Diffstat (limited to 'crypto/core_namemap.c')
-rw-r--r--crypto/core_namemap.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/crypto/core_namemap.c b/crypto/core_namemap.c
index 7e11ab1c88..554524a5c4 100644
--- a/crypto/core_namemap.c
+++ b/crypto/core_namemap.c
@@ -12,6 +12,7 @@
#include "crypto/lhash.h" /* ossl_lh_strcasehash */
#include "internal/tsan_assist.h"
#include "internal/sizes.h"
+#include "crypto/context.h"
/*-
* The namenum entry
@@ -60,7 +61,7 @@ static void namenum_free(NAMENUM_ENTRY *n)
/* OSSL_LIB_CTX_METHOD functions for a namemap stored in a library context */
-static void *stored_namemap_new(OSSL_LIB_CTX *libctx)
+void *ossl_stored_namemap_new(OSSL_LIB_CTX *libctx)
{
OSSL_NAMEMAP *namemap = ossl_namemap_new();
@@ -70,7 +71,7 @@ static void *stored_namemap_new(OSSL_LIB_CTX *libctx)
return namemap;
}
-static void stored_namemap_free(void *vnamemap)
+void ossl_stored_namemap_free(void *vnamemap)
{
OSSL_NAMEMAP *namemap = vnamemap;
@@ -81,12 +82,6 @@ static void stored_namemap_free(void *vnamemap)
}
}
-static const OSSL_LIB_CTX_METHOD stored_namemap_method = {
- OSSL_LIB_CTX_METHOD_DEFAULT_PRIORITY,
- stored_namemap_new,
- stored_namemap_free,
-};
-
/*-
* API functions
* =============
@@ -468,8 +463,7 @@ OSSL_NAMEMAP *ossl_namemap_stored(OSSL_LIB_CTX *libctx)
int nms;
#endif
OSSL_NAMEMAP *namemap =
- ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_NAMEMAP_INDEX,
- &stored_namemap_method);
+ ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_NAMEMAP_INDEX);
if (namemap == NULL)
return NULL;