Codebase list openssl / f0191d0
Add the internal function ossl_method_store_do_all() It will simply call the given callback for every method found in the given store. Fixes #15538 Fixes #14837 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15604) Richard Levitte 2 years ago
2 changed file(s) with 39 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
359359 }
360360 ossl_property_unlock(store);
361361 return 0;
362 }
363
364 static void alg_do_one(ALGORITHM *alg, IMPLEMENTATION *impl,
365 void (*fn)(int id, void *method, void *fnarg),
366 void *fnarg)
367 {
368 fn(alg->nid, impl->method.method, fnarg);
369 }
370
371 struct alg_do_each_data_st {
372 void (*fn)(int id, void *method, void *fnarg);
373 void *fnarg;
374 };
375
376 static void alg_do_each(ossl_uintmax_t idx, ALGORITHM *alg, void *arg)
377 {
378 struct alg_do_each_data_st *data = arg;
379 int i, end = sk_IMPLEMENTATION_num(alg->impls);
380
381 for (i = 0; i < end; i++) {
382 IMPLEMENTATION *impl = sk_IMPLEMENTATION_value(alg->impls, i);
383
384 alg_do_one(alg, impl, data->fn, data->fnarg);
385 }
386 }
387
388 void ossl_method_store_do_all(OSSL_METHOD_STORE *store,
389 void (*fn)(int id, void *method, void *fnarg),
390 void *fnarg)
391 {
392 struct alg_do_each_data_st data;
393
394 data.fn = fn;
395 data.fnarg = fnarg;
396 if (store != NULL)
397 ossl_sa_ALGORITHM_doall_arg(store->algs, alg_do_each, &data);
362398 }
363399
364400 int ossl_method_store_fetch(OSSL_METHOD_STORE *store, int nid,
5757 void (*method_destruct)(void *));
5858 int ossl_method_store_remove(OSSL_METHOD_STORE *store, int nid,
5959 const void *method);
60 void ossl_method_store_do_all(OSSL_METHOD_STORE *store,
61 void (*fn)(int id, void *method, void *fnarg),
62 void *fnarg);
6063 int ossl_method_store_fetch(OSSL_METHOD_STORE *store, int nid,
6164 const char *prop_query, void **method);
6265