177e2c2e83d4b855a3d4336ca6f18b0e78e5a6be
[openssl.git] / doc / man3 / OSSL_PROVIDER.pod
1 =pod
2
3 =head1 NAME
4
5 OSSL_PROVIDER_set_default_search_path,
6 OSSL_PROVIDER, OSSL_PROVIDER_load, OSSL_PROVIDER_unload,
7 OSSL_PROVIDER_available, OSSL_PROVIDER_do_all,
8 OSSL_PROVIDER_gettable_params, OSSL_PROVIDER_get_params,
9 OSSL_PROVIDER_query_operation, OSSL_PROVIDER_add_builtin,
10 OSSL_PROVIDER_name - provider routines
11
12 =head1 SYNOPSIS
13
14  #include <openssl/provider.h>
15
16  typedef struct ossl_provider_st OSSL_PROVIDER;
17
18  void OSSL_PROVIDER_set_default_search_path(OPENSSL_CTX *libctx,
19                                             const char *path);
20
21  OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *libctx, const char *name);
22  int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov);
23  int OSSL_PROVIDER_available(OPENSSL_CTX *libctx, const char *name);
24  int OSSL_PROVIDER_do_all(OPENSSL_CTX *ctx,
25                           int (*cb)(OSSL_PROVIDER *provider, void *cbdata),
26                           void *cbdata);
27
28  const OSSL_PARAM *OSSL_PROVIDER_gettable_params(OSSL_PROVIDER *prov);
29  int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, OSSL_PARAM params[]);
30
31  const OSSL_ALGORITHM *OSSL_PROVIDER_query_operation(const OSSL_PROVIDER *prov,
32                                                      int operation_id,
33                                                      int *no_cache);
34
35  int OSSL_PROVIDER_add_builtin(OPENSSL_CTX *libctx, const char *name,
36                                ossl_provider_init_fn *init_fn);
37
38  const char *OSSL_PROVIDER_name(const OSSL_PROVIDER *prov);
39
40 =head1 DESCRIPTION
41
42 B<OSSL_PROVIDER> is a type that holds internal information about
43 implementation providers (see L<provider(7)> for information on what a
44 provider is).
45 A provider can be built in to the application or the OpenSSL
46 libraries, or can be a loadable module.
47 The functions described here handle both forms.
48
49 Some of these functions operate within a library context, please see
50 L<OPENSSL_CTX(3)> for further details.
51
52 =head2 Functions
53
54 OSSL_PROVIDER_set_default_search_path() specifies the default search B<path>
55 that is to be used for looking for providers in the specified B<libctx>.
56 If left unspecified, an environment variable and a fall back default value will
57 be used instead.
58
59 OSSL_PROVIDER_add_builtin() is used to add a built in provider to
60 B<OSSL_PROVIDER> store in the given library context, by associating a
61 provider name with a provider initialization function.
62 This name can then be used with OSSL_PROVIDER_load().
63
64 OSSL_PROVIDER_load() loads and initializes a provider.
65 This may simply initialize a provider that was previously added with
66 OSSL_PROVIDER_add_builtin() and run its given initialization function,
67 or load a provider module with the given name and run its provider
68 entry point, C<OSSL_provider_init>.
69
70 OSSL_PROVIDER_unload() unloads the given provider.
71 For a provider added with OSSL_PROVIDER_add_builtin(), this simply
72 runs its teardown function.
73
74 OSSL_PROVIDER_available() checks if a named provider is available
75 for use.
76
77 OSSL_PROVIDER_do_all() iterates over all loaded providers, calling
78 I<cb> for each one, with the current provider in I<provider> and the
79 I<cbdata> that comes from the caller.
80
81 OSSL_PROVIDER_gettable_params() is used to get a provider parameter
82 descriptor set as a constant B<OSSL_PARAM> array.
83 See L<OSSL_PARAM(3)> for more information.
84
85 OSSL_PROVIDER_get_params() is used to get provider parameter values.
86 The caller must prepare the B<OSSL_PARAM> array before calling this
87 function, and the variables acting as buffers for this parameter array
88 should be filled with data when it returns successfully.
89
90 OSSL_PROVIDER_query_operation() calls the provider's I<query_operation>
91 function (see L<provider(7)>), if the provider has one. It should return an
92 array of I<OSSL_ALGORITHM> for the given I<operation_id> terminated by an all
93 NULL OSSL_ALGORITHM entry. This is considered a low-level function that most
94 applications should not need to call.
95
96 If it is permissible to cache references to this array then I<*no_store> is set
97 to 0 or 1 otherwise. If the array is not cacheable then it should be assumed to
98 have a short lifetime.
99
100 OSSL_PROVIDER_name() returns the name of the given provider.
101
102 =head1 RETURN VALUES
103
104 OSSL_PROVIDER_add() returns 1 on success, or 0 on error.
105
106 OSSL_PROVIDER_load() returns a pointer to a provider object on
107 success, or B<NULL> on error.
108
109 OSSL_PROVIDER_unload() returns 1 on success, or 0 on error.
110
111 OSSL_PROVIDER_available() returns 1 if the named provider is available,
112 otherwise 0.
113
114 OSSL_PROVIDER_gettable_params() returns a pointer to an array
115 of constant B<OSSL_PARAM>, or NULL if none is provided.
116
117 OSSL_PROVIDER_get_params() returns 1 on success, or 0 on error.
118
119 OSSL_PROVIDER_query_operation() returns an array of OSSL_ALGORITHM or NULL on
120 error.
121
122 =head1 EXAMPLES
123
124 This demonstrates how to load the provider module "foo" and ask for
125 its build number.
126
127  OSSL_PROVIDER *prov = NULL;
128  const char *build = NULL;
129  size_t built_l = 0;
130  OSSL_PARAM request[] = {
131      { "build", OSSL_PARAM_UTF8_STRING_PTR, &build, 0, &build_l },
132      { NULL, 0, NULL, 0, NULL }
133  };
134
135  if ((prov = OSSL_PROVIDER_load(NULL, "foo")) != NULL
136      && OSSL_PROVIDER_get_params(prov, request))
137      printf("Provider 'foo' build %s\n", build);
138  else
139      ERR_print_errors_fp(stderr);
140
141 =head1 SEE ALSO
142
143 L<openssl-core.h(7)>, L<OPENSSL_CTX(3)>, L<provider(7)>
144
145 =head1 HISTORY
146
147 The type and functions described here were added in OpenSSL 3.0.
148
149 =head1 COPYRIGHT
150
151 Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
152
153 Licensed under the Apache License 2.0 (the "License").  You may not use
154 this file except in compliance with the License.  You can obtain a copy
155 in the file LICENSE in the source distribution or at
156 L<https://www.openssl.org/source/license.html>.
157
158 =cut