|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
+ * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
|
|
*
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
@@ -96,6 +96,8 @@ typedef struct {
|
|
|
|
|
|
DEFINE_SPARSE_ARRAY_OF(ALGORITHM);
|
|
|
|
|
|
+DEFINE_STACK_OF(ALGORITHM)
|
|
|
+
|
|
|
typedef struct ossl_global_properties_st {
|
|
|
OSSL_PROPERTY_LIST *list;
|
|
|
#ifndef FIPS_MODULE
|
|
@@ -461,33 +463,45 @@ static void alg_do_one(ALGORITHM *alg, IMPLEMENTATION *impl,
|
|
|
fn(alg->nid, impl->method.method, fnarg);
|
|
|
}
|
|
|
|
|
|
-struct alg_do_each_data_st {
|
|
|
- void (*fn)(int id, void *method, void *fnarg);
|
|
|
- void *fnarg;
|
|
|
-};
|
|
|
-
|
|
|
-static void alg_do_each(ossl_uintmax_t idx, ALGORITHM *alg, void *arg)
|
|
|
+static void alg_copy(ossl_uintmax_t idx, ALGORITHM *alg, void *arg)
|
|
|
{
|
|
|
- struct alg_do_each_data_st *data = arg;
|
|
|
- int i, end = sk_IMPLEMENTATION_num(alg->impls);
|
|
|
-
|
|
|
- for (i = 0; i < end; i++) {
|
|
|
- IMPLEMENTATION *impl = sk_IMPLEMENTATION_value(alg->impls, i);
|
|
|
+ STACK_OF(ALGORITHM) *newalg = arg;
|
|
|
|
|
|
- alg_do_one(alg, impl, data->fn, data->fnarg);
|
|
|
- }
|
|
|
+ (void)sk_ALGORITHM_push(newalg, alg);
|
|
|
}
|
|
|
|
|
|
void ossl_method_store_do_all(OSSL_METHOD_STORE *store,
|
|
|
void (*fn)(int id, void *method, void *fnarg),
|
|
|
void *fnarg)
|
|
|
{
|
|
|
- struct alg_do_each_data_st data;
|
|
|
+ int i, j;
|
|
|
+ int numalgs, numimps;
|
|
|
+ STACK_OF(ALGORITHM) *tmpalgs;
|
|
|
+ ALGORITHM *alg;
|
|
|
|
|
|
- data.fn = fn;
|
|
|
- data.fnarg = fnarg;
|
|
|
- if (store != NULL)
|
|
|
- ossl_sa_ALGORITHM_doall_arg(store->algs, alg_do_each, &data);
|
|
|
+ if (store != NULL) {
|
|
|
+
|
|
|
+ if (!ossl_property_read_lock(store))
|
|
|
+ return;
|
|
|
+
|
|
|
+ tmpalgs = sk_ALGORITHM_new_reserve(NULL,
|
|
|
+ ossl_sa_ALGORITHM_num(store->algs));
|
|
|
+ if (tmpalgs == NULL) {
|
|
|
+ ossl_property_unlock(store);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ossl_sa_ALGORITHM_doall_arg(store->algs, alg_copy, tmpalgs);
|
|
|
+ ossl_property_unlock(store);
|
|
|
+ numalgs = sk_ALGORITHM_num(tmpalgs);
|
|
|
+ for (i = 0; i < numalgs; i++) {
|
|
|
+ alg = sk_ALGORITHM_value(tmpalgs, i);
|
|
|
+ numimps = sk_IMPLEMENTATION_num(alg->impls);
|
|
|
+ for (j = 0; j < numimps; j++)
|
|
|
+ alg_do_one(alg, sk_IMPLEMENTATION_value(alg->impls, j), fn, fnarg);
|
|
|
+ }
|
|
|
+ sk_ALGORITHM_free(tmpalgs);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
int ossl_method_store_fetch(OSSL_METHOD_STORE *store,
|
|
@@ -643,10 +657,13 @@ static void impl_cache_flush_one_alg(ossl_uintmax_t idx, ALGORITHM *alg,
|
|
|
void *v)
|
|
|
{
|
|
|
IMPL_CACHE_FLUSH *state = (IMPL_CACHE_FLUSH *)v;
|
|
|
+ unsigned long orig_down_load = lh_QUERY_get_down_load(alg->cache);
|
|
|
|
|
|
state->cache = alg->cache;
|
|
|
+ lh_QUERY_set_down_load(alg->cache, 0);
|
|
|
lh_QUERY_doall_IMPL_CACHE_FLUSH(state->cache, &impl_cache_flush_cache,
|
|
|
state);
|
|
|
+ lh_QUERY_set_down_load(alg->cache, orig_down_load);
|
|
|
}
|
|
|
|
|
|
static void ossl_method_cache_flush_some(OSSL_METHOD_STORE *store)
|