} ALGORITHM;
struct ossl_method_store_st {
+ OPENSSL_CTX *ctx;
size_t nelem;
SPARSE_ARRAY_OF(ALGORITHM) *algs;
OSSL_PROPERTY_LIST *global_properties;
return p != 0 ? CRYPTO_THREAD_unlock(p->lock) : 0;
}
-int ossl_method_store_init(void)
+static openssl_ctx_run_once_fn do_method_store_init;
+int do_method_store_init(OPENSSL_CTX *ctx)
{
- if (ossl_property_string_init()
- && ossl_prop_defn_init()
- && ossl_property_parse_init())
- return 1;
-
- ossl_method_store_cleanup();
- return 0;
-}
-
-void ossl_method_store_cleanup(void)
-{
- ossl_property_string_cleanup();
- ossl_prop_defn_cleanup();
-}
-
-static CRYPTO_ONCE method_store_init_flag = CRYPTO_ONCE_STATIC_INIT;
-DEFINE_RUN_ONCE_STATIC(do_method_store_init)
-{
- return OPENSSL_init_crypto(0, NULL)
- && ossl_method_store_init()
- && OPENSSL_atexit(&ossl_method_store_cleanup);
+ return ossl_property_parse_init(ctx);
}
static unsigned long query_hash(const QUERY *a)
}
}
-OSSL_METHOD_STORE *ossl_method_store_new(void)
+/*
+ * The OPENSSL_CTX param here allows access to underlying property data needed
+ * for computation
+ */
+OSSL_METHOD_STORE *ossl_method_store_new(OPENSSL_CTX *ctx)
{
OSSL_METHOD_STORE *res;
- if (!RUN_ONCE(&method_store_init_flag, do_method_store_init))
- return 0;
+ if (!openssl_ctx_run_once(ctx,
+ OPENSSL_CTX_METHOD_STORE_RUN_ONCE_INDEX,
+ do_method_store_init))
+ return NULL;
res = OPENSSL_zalloc(sizeof(*res));
if (res != NULL) {
+ res->ctx = ctx;
if ((res->algs = ossl_sa_ALGORITHM_new()) == NULL) {
OPENSSL_free(res);
return NULL;
*/
ossl_property_write_lock(store);
ossl_method_cache_flush(store, nid);
- if ((impl->properties = ossl_prop_defn_get(properties)) == NULL) {
- if ((impl->properties = ossl_parse_property(properties)) == NULL)
+ if ((impl->properties = ossl_prop_defn_get(store->ctx, properties)) == NULL) {
+ impl->properties = ossl_parse_property(store->ctx, properties);
+ if (impl->properties == NULL)
goto err;
- ossl_prop_defn_set(properties, impl->properties);
+ ossl_prop_defn_set(store->ctx, properties, impl->properties);
}
alg = ossl_method_store_retrieve(store, nid);
}
goto fin;
}
- pq = ossl_parse_query(prop_query);
+ pq = ossl_parse_query(store->ctx, prop_query);
if (pq == NULL)
goto fin;
if (store->global_properties != NULL) {
ossl_property_unlock(store);
return 1;
}
- store->global_properties = ossl_parse_query(prop_query);
+ store->global_properties = ossl_parse_query(store->ctx, prop_query);
ret = store->global_properties != NULL;
ossl_property_unlock(store);
return ret;