1b0d17251Schristos=pod 2b0d17251Schristos 3b0d17251Schristos=head1 NAME 4b0d17251Schristos 5b0d17251SchristosOSSL_PROVIDER_set_default_search_path, 6b0d17251SchristosOSSL_PROVIDER, OSSL_PROVIDER_load, OSSL_PROVIDER_try_load, OSSL_PROVIDER_unload, 7b0d17251SchristosOSSL_PROVIDER_available, OSSL_PROVIDER_do_all, 8b0d17251SchristosOSSL_PROVIDER_gettable_params, OSSL_PROVIDER_get_params, 9b0d17251SchristosOSSL_PROVIDER_query_operation, OSSL_PROVIDER_unquery_operation, 10b0d17251SchristosOSSL_PROVIDER_get0_provider_ctx, OSSL_PROVIDER_get0_dispatch, 11b0d17251SchristosOSSL_PROVIDER_add_builtin, OSSL_PROVIDER_get0_name, OSSL_PROVIDER_get_capabilities, 12b0d17251SchristosOSSL_PROVIDER_self_test 13b0d17251Schristos- provider routines 14b0d17251Schristos 15b0d17251Schristos=head1 SYNOPSIS 16b0d17251Schristos 17b0d17251Schristos #include <openssl/provider.h> 18b0d17251Schristos 19b0d17251Schristos typedef struct ossl_provider_st OSSL_PROVIDER; 20b0d17251Schristos 21b0d17251Schristos int OSSL_PROVIDER_set_default_search_path(OSSL_LIB_CTX *libctx, 22b0d17251Schristos const char *path); 23b0d17251Schristos 24b0d17251Schristos OSSL_PROVIDER *OSSL_PROVIDER_load(OSSL_LIB_CTX *libctx, const char *name); 25b0d17251Schristos OSSL_PROVIDER *OSSL_PROVIDER_try_load(OSSL_LIB_CTX *libctx, const char *name, 26b0d17251Schristos int retain_fallbacks); 27b0d17251Schristos int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov); 28b0d17251Schristos int OSSL_PROVIDER_available(OSSL_LIB_CTX *libctx, const char *name); 29b0d17251Schristos int OSSL_PROVIDER_do_all(OSSL_LIB_CTX *ctx, 30b0d17251Schristos int (*cb)(OSSL_PROVIDER *provider, void *cbdata), 31b0d17251Schristos void *cbdata); 32b0d17251Schristos 33b0d17251Schristos const OSSL_PARAM *OSSL_PROVIDER_gettable_params(OSSL_PROVIDER *prov); 34b0d17251Schristos int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, OSSL_PARAM params[]); 35b0d17251Schristos 36b0d17251Schristos const OSSL_ALGORITHM *OSSL_PROVIDER_query_operation(const OSSL_PROVIDER *prov, 37b0d17251Schristos int operation_id, 38b0d17251Schristos int *no_cache); 39b0d17251Schristos void OSSL_PROVIDER_unquery_operation(const OSSL_PROVIDER *prov, 40b0d17251Schristos int operation_id, 41b0d17251Schristos const OSSL_ALGORITHM *algs); 42b0d17251Schristos void *OSSL_PROVIDER_get0_provider_ctx(const OSSL_PROVIDER *prov); 43b0d17251Schristos const OSSL_DISPATCH *OSSL_PROVIDER_get0_dispatch(const OSSL_PROVIDER *prov); 44b0d17251Schristos 45b0d17251Schristos int OSSL_PROVIDER_add_builtin(OSSL_LIB_CTX *libctx, const char *name, 46b0d17251Schristos ossl_provider_init_fn *init_fn); 47b0d17251Schristos 48b0d17251Schristos const char *OSSL_PROVIDER_get0_name(const OSSL_PROVIDER *prov); 49b0d17251Schristos 50b0d17251Schristos int OSSL_PROVIDER_get_capabilities(const OSSL_PROVIDER *prov, 51b0d17251Schristos const char *capability, 52b0d17251Schristos OSSL_CALLBACK *cb, 53b0d17251Schristos void *arg); 54b0d17251Schristos int OSSL_PROVIDER_self_test(const OSSL_PROVIDER *prov); 55b0d17251Schristos 56b0d17251Schristos=head1 DESCRIPTION 57b0d17251Schristos 58b0d17251SchristosB<OSSL_PROVIDER> is a type that holds internal information about 59b0d17251Schristosimplementation providers (see L<provider(7)> for information on what a 60b0d17251Schristosprovider is). 61b0d17251SchristosA provider can be built in to the application or the OpenSSL 62b0d17251Schristoslibraries, or can be a loadable module. 63b0d17251SchristosThe functions described here handle both forms. 64b0d17251Schristos 65b0d17251SchristosSome of these functions operate within a library context, please see 66b0d17251SchristosL<OSSL_LIB_CTX(3)> for further details. 67b0d17251Schristos 68b0d17251Schristos=head2 Functions 69b0d17251Schristos 70b0d17251SchristosOSSL_PROVIDER_set_default_search_path() specifies the default search I<path> 71b0d17251Schristosthat is to be used for looking for providers in the specified I<libctx>. 72b0d17251SchristosIf left unspecified, an environment variable and a fall back default value will 73b0d17251Schristosbe used instead. 74b0d17251Schristos 75b0d17251SchristosOSSL_PROVIDER_add_builtin() is used to add a built in provider to 76b0d17251SchristosB<OSSL_PROVIDER> store in the given library context, by associating a 77b0d17251Schristosprovider name with a provider initialization function. 78b0d17251SchristosThis name can then be used with OSSL_PROVIDER_load(). 79b0d17251Schristos 80b0d17251SchristosOSSL_PROVIDER_load() loads and initializes a provider. 81b0d17251SchristosThis may simply initialize a provider that was previously added with 82b0d17251SchristosOSSL_PROVIDER_add_builtin() and run its given initialization function, 83b0d17251Schristosor load a provider module with the given name and run its provider 84b0d17251Schristosentry point, C<OSSL_provider_init>. The I<name> can be a path 85b0d17251Schristosto a provider module, in that case the provider name as returned 86b0d17251Schristosby OSSL_PROVIDER_get0_name() will be the path. Interpretation 87b0d17251Schristosof relative paths is platform dependent and they are relative 88b0d17251Schristosto the configured "MODULESDIR" directory or the path set in 89b0d17251Schristosthe environment variable OPENSSL_MODULES if set. 90b0d17251Schristos 91b0d17251SchristosOSSL_PROVIDER_try_load() functions like OSSL_PROVIDER_load(), except that 92b0d17251Schristosit does not disable the fallback providers if the provider cannot be 93*4778aedeSchristosloaded and initialized or if I<retain_fallbacks> is nonzero. 94*4778aedeSchristosIf the provider loads successfully and I<retain_fallbacks> is zero, the 95b0d17251Schristosfallback providers are disabled. 96b0d17251Schristos 97b0d17251SchristosOSSL_PROVIDER_unload() unloads the given provider. 98b0d17251SchristosFor a provider added with OSSL_PROVIDER_add_builtin(), this simply 99b0d17251Schristosruns its teardown function. 100b0d17251Schristos 101b0d17251SchristosOSSL_PROVIDER_available() checks if a named provider is available 102b0d17251Schristosfor use. 103b0d17251Schristos 104b0d17251SchristosOSSL_PROVIDER_do_all() iterates over all loaded providers, calling 105b0d17251SchristosI<cb> for each one, with the current provider in I<provider> and the 106b0d17251SchristosI<cbdata> that comes from the caller. If no other provider has been loaded 107b0d17251Schristosbefore calling this function, the default provider is still available as 108b0d17251Schristosfallback. 109b0d17251SchristosSee L<OSSL_PROVIDER-default(7)> for more information on this fallback 110b0d17251Schristosbehaviour. 111b0d17251Schristos 112b0d17251SchristosOSSL_PROVIDER_gettable_params() is used to get a provider parameter 113b0d17251Schristosdescriptor set as a constant L<OSSL_PARAM(3)> array. 114b0d17251Schristos 115b0d17251SchristosOSSL_PROVIDER_get_params() is used to get provider parameter values. 116b0d17251SchristosThe caller must prepare the L<OSSL_PARAM(3)> array before calling this 117b0d17251Schristosfunction, and the variables acting as buffers for this parameter array 118b0d17251Schristosshould be filled with data when it returns successfully. 119b0d17251Schristos 120b0d17251SchristosOSSL_PROVIDER_self_test() is used to run a provider's self tests on demand. 121b0d17251SchristosIf the self tests fail then the provider will fail to provide any further 122b0d17251Schristosservices and algorithms. L<OSSL_SELF_TEST_set_callback(3)> may be called 123b0d17251Schristosbeforehand in order to display diagnostics for the running self tests. 124b0d17251Schristos 125b0d17251SchristosOSSL_PROVIDER_query_operation() calls the provider's I<query_operation> 126b0d17251Schristosfunction (see L<provider(7)>), if the provider has one. It returns an 127b0d17251Schristosarray of I<OSSL_ALGORITHM> for the given I<operation_id> terminated by an all 128b0d17251SchristosNULL OSSL_ALGORITHM entry. This is considered a low-level function that most 129b0d17251Schristosapplications should not need to call. 130b0d17251Schristos 131b0d17251SchristosOSSL_PROVIDER_unquery_operation() calls the provider's I<unquery_operation> 132b0d17251Schristosfunction (see L<provider(7)>), if the provider has one. This is considered a 133b0d17251Schristoslow-level function that most applications should not need to call. 134b0d17251Schristos 135b0d17251SchristosOSSL_PROVIDER_get0_provider_ctx() returns the provider context for the given 136b0d17251Schristosprovider. The provider context is an opaque handle set by the provider itself 137b0d17251Schristosand is passed back to the provider by libcrypto in various function calls. 138b0d17251Schristos 139b0d17251SchristosOSSL_PROVIDER_get0_dispatch() returns the provider's dispatch table as it was 140b0d17251Schristosreturned in the I<out> parameter from the provider's init function. See 141b0d17251SchristosL<provider-base(7)>. 142b0d17251Schristos 143b0d17251SchristosIf it is permissible to cache references to this array then I<*no_store> is set 144b0d17251Schristosto 0 or 1 otherwise. If the array is not cacheable then it is assumed to 145b0d17251Schristoshave a short lifetime. 146b0d17251Schristos 147b0d17251SchristosOSSL_PROVIDER_get0_name() returns the name of the given provider. 148b0d17251Schristos 149b0d17251SchristosOSSL_PROVIDER_get_capabilities() provides information about the capabilities 150b0d17251Schristossupported by the provider specified in I<prov> with the capability name 151b0d17251SchristosI<capability>. For each capability of that name supported by the provider it 152b0d17251Schristoswill call the callback I<cb> and supply a set of L<OSSL_PARAM(3)>s describing the 153b0d17251Schristoscapability. It will also pass back the argument I<arg>. For more details about 154b0d17251Schristoscapabilities and what they can be used for please see 155b0d17251SchristosL<provider-base(7)/CAPABILTIIES>. 156b0d17251Schristos 157b0d17251Schristos=head1 RETURN VALUES 158b0d17251Schristos 159b0d17251SchristosOSSL_PROVIDER_set_default_search_path(), OSSL_PROVIDER_add(), 160b0d17251SchristosOSSL_PROVIDER_unload(), OSSL_PROVIDER_get_params() and 161b0d17251SchristosOSSL_PROVIDER_get_capabilities() return 1 on success, or 0 on error. 162b0d17251Schristos 163b0d17251SchristosOSSL_PROVIDER_load() and OSSL_PROVIDER_try_load() return a pointer to a 164b0d17251Schristosprovider object on success, or NULL on error. 165b0d17251Schristos 166b0d17251SchristosOSSL_PROVIDER_do_all() returns 1 if the callback I<cb> returns 1 for every 167b0d17251Schristosprovider it is called with, or 0 if any provider callback invocation returns 0; 168b0d17251Schristoscallback processing stops at the first callback invocation on a provider 169b0d17251Schristosthat returns 0. 170b0d17251Schristos 171b0d17251SchristosOSSL_PROVIDER_available() returns 1 if the named provider is available, 172b0d17251Schristosotherwise 0. 173b0d17251Schristos 174b0d17251SchristosOSSL_PROVIDER_gettable_params() returns a pointer to an array 175b0d17251Schristosof constant L<OSSL_PARAM(3)>, or NULL if none is provided. 176b0d17251Schristos 177b0d17251SchristosOSSL_PROVIDER_get_params() and returns 1 on success, or 0 on error. 178b0d17251Schristos 179b0d17251SchristosOSSL_PROVIDER_query_operation() returns an array of OSSL_ALGORITHM or NULL on 180b0d17251Schristoserror. 181b0d17251Schristos 182b0d17251SchristosOSSL_PROVIDER_self_test() returns 1 if the self tests pass, or 0 on error. 183b0d17251Schristos 184b0d17251Schristos=head1 EXAMPLES 185b0d17251Schristos 186b0d17251SchristosThis demonstrates how to load the provider module "foo" and ask for 187b0d17251Schristosits build information. 188b0d17251Schristos 189b0d17251Schristos #include <openssl/params.h> 190b0d17251Schristos #include <openssl/provider.h> 191b0d17251Schristos #include <openssl/err.h> 192b0d17251Schristos 193b0d17251Schristos OSSL_PROVIDER *prov = NULL; 194b0d17251Schristos const char *build = NULL; 195b0d17251Schristos OSSL_PARAM request[] = { 196b0d17251Schristos { "buildinfo", OSSL_PARAM_UTF8_PTR, &build, 0, 0 }, 197b0d17251Schristos { NULL, 0, NULL, 0, 0 } 198b0d17251Schristos }; 199b0d17251Schristos 200b0d17251Schristos if ((prov = OSSL_PROVIDER_load(NULL, "foo")) != NULL 201b0d17251Schristos && OSSL_PROVIDER_get_params(prov, request)) 202b0d17251Schristos printf("Provider 'foo' buildinfo: %s\n", build); 203b0d17251Schristos else 204b0d17251Schristos ERR_print_errors_fp(stderr); 205b0d17251Schristos 206b0d17251Schristos=head1 SEE ALSO 207b0d17251Schristos 208b0d17251SchristosL<openssl-core.h(7)>, L<OSSL_LIB_CTX(3)>, L<provider(7)> 209b0d17251Schristos 210b0d17251Schristos=head1 HISTORY 211b0d17251Schristos 212b0d17251SchristosThe type and functions described here were added in OpenSSL 3.0. 213b0d17251Schristos 214b0d17251Schristos=head1 COPYRIGHT 215b0d17251Schristos 216*4778aedeSchristosCopyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved. 217b0d17251Schristos 218b0d17251SchristosLicensed under the Apache License 2.0 (the "License"). You may not use 219b0d17251Schristosthis file except in compliance with the License. You can obtain a copy 220b0d17251Schristosin the file LICENSE in the source distribution or at 221b0d17251SchristosL<https://www.openssl.org/source/license.html>. 222b0d17251Schristos 223b0d17251Schristos=cut 224