diff options
author | Hugo Landau <hlandau@openssl.org> | 2022-03-14 08:13:12 +0000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-04-01 10:49:19 +1100 |
commit | 927d0566ded0dff9d6c5abc8a40bb84068446b76 (patch) | |
tree | c6d898a04aaa2062c9a74cb9c89ce25fa9680a41 /crypto/bio | |
parent | 9c140a33663f319ad4000a6a985c3e14297c7389 (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)
Diffstat (limited to 'crypto/bio')
-rw-r--r-- | crypto/bio/bss_core.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/crypto/bio/bss_core.c b/crypto/bio/bss_core.c index b78b1bedaa..66b56647f6 100644 --- a/crypto/bio/bss_core.c +++ b/crypto/bio/bss_core.c @@ -10,6 +10,7 @@ #include <openssl/core_dispatch.h> #include "bio_local.h" #include "internal/cryptlib.h" +#include "crypto/context.h" typedef struct { OSSL_FUNC_BIO_read_ex_fn *c_bio_read_ex; @@ -21,26 +22,19 @@ typedef struct { OSSL_FUNC_BIO_free_fn *c_bio_free; } BIO_CORE_GLOBALS; -static void bio_core_globals_free(void *vbcg) +void ossl_bio_core_globals_free(void *vbcg) { OPENSSL_free(vbcg); } -static void *bio_core_globals_new(OSSL_LIB_CTX *ctx) +void *ossl_bio_core_globals_new(OSSL_LIB_CTX *ctx) { return OPENSSL_zalloc(sizeof(BIO_CORE_GLOBALS)); } -static const OSSL_LIB_CTX_METHOD bio_core_globals_method = { - OSSL_LIB_CTX_METHOD_DEFAULT_PRIORITY, - bio_core_globals_new, - bio_core_globals_free, -}; - static ossl_inline BIO_CORE_GLOBALS *get_globals(OSSL_LIB_CTX *libctx) { - return ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_BIO_CORE_INDEX, - &bio_core_globals_method); + return ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_BIO_CORE_INDEX); } static int bio_core_read_ex(BIO *bio, char *data, size_t data_len, |