summaryrefslogtreecommitdiffstats
path: root/crypto/core_fetch.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-07-10 23:14:03 +0200
committerRichard Levitte <levitte@openssl.org>2019-07-23 06:34:09 +0200
commit84d167f6eb1c3cb3cf9092122349967f717c56ca (patch)
tree0c19ef746a71ea3c4845ac413f2ab2e2930c1952 /crypto/core_fetch.c
parentAdd internal function ossl_algorithm_do_all() (diff)
downloadopenssl-84d167f6eb1c3cb3cf9092122349967f717c56ca.tar.xz
openssl-84d167f6eb1c3cb3cf9092122349967f717c56ca.zip
Refactor ossl_method_construct() in terms of ossl_algorithm_do_all()
Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/9356)
Diffstat (limited to '')
-rw-r--r--crypto/core_fetch.c78
1 files changed, 34 insertions, 44 deletions
diff --git a/crypto/core_fetch.c b/crypto/core_fetch.c
index 56a3c5cadb..c1c81588bb 100644
--- a/crypto/core_fetch.c
+++ b/crypto/core_fetch.c
@@ -24,55 +24,45 @@ struct construct_data_st {
void *mcm_data;
};
-static int ossl_method_construct_this(OSSL_PROVIDER *provider, void *cbdata)
+static void ossl_method_construct_this(OSSL_PROVIDER *provider,
+ const OSSL_ALGORITHM *algo,
+ int no_store, void *cbdata)
{
struct construct_data_st *data = cbdata;
- int no_store = 0; /* Assume caching is ok */
- const OSSL_ALGORITHM *map =
- ossl_provider_query_operation(provider, data->operation_id, &no_store);
-
- if (map == NULL)
- return 0;
-
- while (map->algorithm_name != NULL) {
- const OSSL_ALGORITHM *thismap = map++;
- void *method = NULL;
-
- if ((method = data->mcm->construct(thismap->algorithm_name,
- thismap->implementation, provider,
- data->mcm_data)) == NULL)
- continue;
+ void *method = NULL;
+ if ((method = data->mcm->construct(algo->algorithm_name,
+ algo->implementation, provider,
+ data->mcm_data)) == NULL)
+ return;
+
+ /*
+ * Note regarding putting the method in stores:
+ *
+ * we don't need to care if it actually got in or not here.
+ * If it didn't get in, it will simply not be available when
+ * ossl_method_construct() tries to get it from the store.
+ *
+ * It is *expected* that the put function increments the refcnt
+ * of the passed method.
+ */
+
+ if (data->force_store || !no_store) {
/*
- * Note regarding putting the method in stores:
- *
- * we don't need to care if it actually got in or not here.
- * If it didn't get in, it will simply not be available when
- * ossl_method_construct() tries to get it from the store.
- *
- * It is *expected* that the put function increments the refcnt
- * of the passed method.
+ * If we haven't been told not to store,
+ * add to the global store
*/
-
- if (data->force_store || !no_store) {
- /*
- * If we haven't been told not to store,
- * add to the global store
- */
- data->mcm->put(data->libctx, NULL, method, data->operation_id,
- thismap->algorithm_name,
- thismap->property_definition, data->mcm_data);
- }
-
- data->mcm->put(data->libctx, data->store, method, data->operation_id,
- thismap->algorithm_name, thismap->property_definition,
- data->mcm_data);
-
- /* refcnt-- because we're dropping the reference */
- data->mcm->destruct(method, data->mcm_data);
+ data->mcm->put(data->libctx, NULL, method, data->operation_id,
+ algo->algorithm_name,
+ algo->property_definition, data->mcm_data);
}
- return 1;
+ data->mcm->put(data->libctx, data->store, method, data->operation_id,
+ algo->algorithm_name, algo->property_definition,
+ data->mcm_data);
+
+ /* refcnt-- because we're dropping the reference */
+ data->mcm->destruct(method, data->mcm_data);
}
void *ossl_method_construct(OPENSSL_CTX *libctx, int operation_id,
@@ -99,8 +89,8 @@ void *ossl_method_construct(OPENSSL_CTX *libctx, int operation_id,
cbdata.force_store = force_store;
cbdata.mcm = mcm;
cbdata.mcm_data = mcm_data;
- ossl_provider_forall_loaded(libctx, ossl_method_construct_this,
- &cbdata);
+ ossl_algorithm_do_all(libctx, operation_id, NULL,
+ ossl_method_construct_this, &cbdata);
method = mcm->get(libctx, cbdata.store, operation_id, name,
propquery, mcm_data);