diff options
author | Hugo Landau <hlandau@openssl.org> | 2022-03-14 08:13:12 +0000 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-11-21 10:49:51 +0100 |
commit | 8436ef8bdb96c0a977a15ec707d28404d97c3a6c (patch) | |
tree | 4af422951654f59fbd8e100892ecb21f3475c941 /crypto/provider_conf.c | |
parent | ee246234bf591cd2a9779a4ad3a2ee3c53848213 (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/provider_conf.c')
-rw-r--r-- | crypto/provider_conf.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/crypto/provider_conf.c b/crypto/provider_conf.c index 6a62f0df60..e3b576d6c2 100644 --- a/crypto/provider_conf.c +++ b/crypto/provider_conf.c @@ -16,6 +16,7 @@ #include "internal/provider.h" #include "internal/cryptlib.h" #include "provider_local.h" +#include "crypto/context.h" DEFINE_STACK_OF(OSSL_PROVIDER) @@ -26,7 +27,7 @@ typedef struct { STACK_OF(OSSL_PROVIDER) *activated_providers; } PROVIDER_CONF_GLOBAL; -static void *prov_conf_ossl_ctx_new(OSSL_LIB_CTX *libctx) +void *ossl_prov_conf_ctx_new(OSSL_LIB_CTX *libctx) { PROVIDER_CONF_GLOBAL *pcgbl = OPENSSL_zalloc(sizeof(*pcgbl)); @@ -42,7 +43,7 @@ static void *prov_conf_ossl_ctx_new(OSSL_LIB_CTX *libctx) return pcgbl; } -static void prov_conf_ossl_ctx_free(void *vpcgbl) +void ossl_prov_conf_ctx_free(void *vpcgbl) { PROVIDER_CONF_GLOBAL *pcgbl = vpcgbl; @@ -54,13 +55,6 @@ static void prov_conf_ossl_ctx_free(void *vpcgbl) OPENSSL_free(pcgbl); } -static const OSSL_LIB_CTX_METHOD provider_conf_ossl_ctx_method = { - /* Must be freed before the provider store is freed */ - OSSL_LIB_CTX_METHOD_PRIORITY_2, - prov_conf_ossl_ctx_new, - prov_conf_ossl_ctx_free, -}; - static const char *skip_dot(const char *name) { const char *p = strchr(name, '.'); @@ -141,8 +135,7 @@ static int provider_conf_activate(OSSL_LIB_CTX *libctx, const char *name, int soft, const CONF *cnf) { PROVIDER_CONF_GLOBAL *pcgbl - = ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_PROVIDER_CONF_INDEX, - &provider_conf_ossl_ctx_method); + = ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_PROVIDER_CONF_INDEX); OSSL_PROVIDER *prov = NULL, *actual = NULL; int ok = 0; |