Add OSSL_PROVIDER_do_all()
authorRichard Levitte <levitte@openssl.org>
Mon, 18 May 2020 10:43:12 +0000 (12:43 +0200)
committerRichard Levitte <levitte@openssl.org>
Wed, 20 May 2020 09:26:14 +0000 (11:26 +0200)
This allows applications to iterate over all loaded providers.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11858)

crypto/provider.c
doc/man3/OSSL_PROVIDER.pod
include/openssl/provider.h
util/libcrypto.num

index fe46d31..09a5e53 100644 (file)
@@ -85,3 +85,11 @@ const char *OSSL_PROVIDER_name(const OSSL_PROVIDER *prov)
 {
     return ossl_provider_name(prov);
 }
 {
     return ossl_provider_name(prov);
 }
+
+int OSSL_PROVIDER_do_all(OPENSSL_CTX *ctx,
+                         int (*cb)(OSSL_PROVIDER *provider,
+                                   void *cbdata),
+                         void *cbdata)
+{
+    return ossl_provider_forall_loaded(ctx, cb, cbdata);
+}
index 3f1a946..93d6e14 100644 (file)
@@ -4,7 +4,7 @@
 
 OSSL_PROVIDER_set_default_search_path,
 OSSL_PROVIDER, OSSL_PROVIDER_load, OSSL_PROVIDER_unload,
 
 OSSL_PROVIDER_set_default_search_path,
 OSSL_PROVIDER, OSSL_PROVIDER_load, OSSL_PROVIDER_unload,
-OSSL_PROVIDER_available,
+OSSL_PROVIDER_available, OSSL_PROVIDER_do_all,
 OSSL_PROVIDER_gettable_params, OSSL_PROVIDER_get_params,
 OSSL_PROVIDER_add_builtin, OSSL_PROVIDER_name - provider routines
 
 OSSL_PROVIDER_gettable_params, OSSL_PROVIDER_get_params,
 OSSL_PROVIDER_add_builtin, OSSL_PROVIDER_name - provider routines
 
@@ -20,6 +20,9 @@ OSSL_PROVIDER_add_builtin, OSSL_PROVIDER_name - provider routines
  OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *libctx, const char *name);
  int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov);
  int OSSL_PROVIDER_available(OPENSSL_CTX *libctx, const char *name);
  OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *libctx, const char *name);
  int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov);
  int OSSL_PROVIDER_available(OPENSSL_CTX *libctx, const char *name);
+ int OSSL_PROVIDER_do_all(OPENSSL_CTX *ctx,
+                          int (*cb)(OSSL_PROVIDER *provider, void *cbdata),
+                          void *cbdata);
 
  const OSSL_PARAM *OSSL_PROVIDER_gettable_params(OSSL_PROVIDER *prov);
  int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, OSSL_PARAM params[]);
 
  const OSSL_PARAM *OSSL_PROVIDER_gettable_params(OSSL_PROVIDER *prov);
  int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, OSSL_PARAM params[]);
@@ -66,6 +69,10 @@ runs its teardown function.
 OSSL_PROVIDER_available() checks if a named provider is available
 for use.
 
 OSSL_PROVIDER_available() checks if a named provider is available
 for use.
 
+OSSL_PROVIDER_do_all() iterates over all loaded providers, calling
+I<cb> for each one, with the current provider in I<provider> and the
+I<cbdata> that comes from the caller.
+
 OSSL_PROVIDER_gettable_params() is used to get a provider parameter
 descriptor set as a constant B<OSSL_PARAM> array.
 See L<OSSL_PARAM(3)> for more information.
 OSSL_PROVIDER_gettable_params() is used to get a provider parameter
 descriptor set as a constant B<OSSL_PARAM> array.
 See L<OSSL_PARAM(3)> for more information.
index f297ea2..6ce68b1 100644 (file)
@@ -23,6 +23,9 @@ int OSSL_PROVIDER_set_default_search_path(OPENSSL_CTX *, const char *path);
 OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *, const char *name);
 int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov);
 int OSSL_PROVIDER_available(OPENSSL_CTX *, const char *name);
 OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *, const char *name);
 int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov);
 int OSSL_PROVIDER_available(OPENSSL_CTX *, const char *name);
+int OSSL_PROVIDER_do_all(OPENSSL_CTX *ctx,
+                         int (*cb)(OSSL_PROVIDER *provider, void *cbdata),
+                         void *cbdata);
 
 const OSSL_PARAM *OSSL_PROVIDER_gettable_params(const OSSL_PROVIDER *prov);
 int OSSL_PROVIDER_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
 
 const OSSL_PARAM *OSSL_PROVIDER_gettable_params(const OSSL_PROVIDER *prov);
 int OSSL_PROVIDER_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
index 8882f04..12c9f4f 100644 (file)
@@ -5092,3 +5092,4 @@ OSSL_STORE_LOADER_set_attach            ? 3_0_0   EXIST::FUNCTION:
 EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen ?      3_0_0   EXIST::FUNCTION:RSA
 EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md ?      3_0_0   EXIST::FUNCTION:RSA
 EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_name ? 3_0_0   EXIST::FUNCTION:RSA
 EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen ?      3_0_0   EXIST::FUNCTION:RSA
 EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md ?      3_0_0   EXIST::FUNCTION:RSA
 EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_name ? 3_0_0   EXIST::FUNCTION:RSA
+OSSL_PROVIDER_do_all                    ?      3_0_0   EXIST::FUNCTION: