summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2022-03-14 08:13:12 +0000
committerPauli <pauli@openssl.org>2022-04-01 10:49:19 +1100
commit927d0566ded0dff9d6c5abc8a40bb84068446b76 (patch)
treec6d898a04aaa2062c9a74cb9c89ce25fa9680a41 /include
parent9c140a33663f319ad4000a6a985c3e14297c7389 (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 'include')
-rw-r--r--include/crypto/context.h40
-rw-r--r--include/internal/cryptlib.h14
2 files changed, 41 insertions, 13 deletions
diff --git a/include/crypto/context.h b/include/crypto/context.h
new file mode 100644
index 0000000000..143f6d6b6d
--- /dev/null
+++ b/include/crypto/context.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/core.h>
+
+void *ossl_provider_store_new(OSSL_LIB_CTX *);
+void *ossl_property_string_data_new(OSSL_LIB_CTX *);
+void *ossl_stored_namemap_new(OSSL_LIB_CTX *);
+void *ossl_property_defns_new(OSSL_LIB_CTX *);
+void *ossl_ctx_global_properties_new(OSSL_LIB_CTX *);
+void *ossl_rand_ctx_new(OSSL_LIB_CTX *);
+void *ossl_prov_conf_ctx_new(OSSL_LIB_CTX *);
+void *ossl_bio_core_globals_new(OSSL_LIB_CTX *);
+void *ossl_child_prov_ctx_new(OSSL_LIB_CTX *);
+void *ossl_prov_drbg_nonce_ctx_new(OSSL_LIB_CTX *);
+void *ossl_self_test_set_callback_new(OSSL_LIB_CTX *);
+void *ossl_rand_crng_ctx_new(OSSL_LIB_CTX *);
+void *ossl_thread_event_ctx_new(OSSL_LIB_CTX *);
+void *ossl_fips_prov_ossl_ctx_new(OSSL_LIB_CTX *);
+
+void ossl_provider_store_free(void *);
+void ossl_property_string_data_free(void *);
+void ossl_stored_namemap_free(void *);
+void ossl_property_defns_free(void *);
+void ossl_ctx_global_properties_free(void *);
+void ossl_rand_ctx_free(void *);
+void ossl_prov_conf_ctx_free(void *);
+void ossl_bio_core_globals_free(void *);
+void ossl_child_prov_ctx_free(void *);
+void ossl_prov_drbg_nonce_ctx_free(void *);
+void ossl_self_test_set_callback_free(void *);
+void ossl_rand_crng_ctx_free(void *);
+void ossl_thread_event_ctx_free(void *);
+void ossl_fips_prov_ossl_ctx_free(void *);
diff --git a/include/internal/cryptlib.h b/include/internal/cryptlib.h
index c017d06483..ab403c512e 100644
--- a/include/internal/cryptlib.h
+++ b/include/internal/cryptlib.h
@@ -117,24 +117,12 @@ typedef struct ossl_ex_data_global_st {
# define OSSL_LIB_CTX_CHILD_PROVIDER_INDEX 18
# define OSSL_LIB_CTX_MAX_INDEXES 19
-# define OSSL_LIB_CTX_METHOD_LOW_PRIORITY -1
-# define OSSL_LIB_CTX_METHOD_DEFAULT_PRIORITY 0
-# define OSSL_LIB_CTX_METHOD_PRIORITY_1 1
-# define OSSL_LIB_CTX_METHOD_PRIORITY_2 2
-
-typedef struct ossl_lib_ctx_method {
- int priority;
- void *(*new_func)(OSSL_LIB_CTX *ctx);
- void (*free_func)(void *);
-} OSSL_LIB_CTX_METHOD;
-
OSSL_LIB_CTX *ossl_lib_ctx_get_concrete(OSSL_LIB_CTX *ctx);
int ossl_lib_ctx_is_default(OSSL_LIB_CTX *ctx);
int ossl_lib_ctx_is_global_default(OSSL_LIB_CTX *ctx);
/* Functions to retrieve pointers to data by index */
-void *ossl_lib_ctx_get_data(OSSL_LIB_CTX *, int /* index */,
- const OSSL_LIB_CTX_METHOD * ctx);
+void *ossl_lib_ctx_get_data(OSSL_LIB_CTX *, int /* index */);
void ossl_lib_ctx_default_deinit(void);
OSSL_EX_DATA_GLOBAL *ossl_lib_ctx_get_ex_data_global(OSSL_LIB_CTX *ctx);