]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/internal/man3/ossl_provider_new.pod
Replumbing: make the oneshot proider cipher function like the others
[thirdparty/openssl.git] / doc / internal / man3 / ossl_provider_new.pod
CommitLineData
c4532834
RL
1=pod
2
3=head1 NAME
4
5ossl_provider_find, ossl_provider_new, ossl_provider_upref,
6ossl_provider_free, ossl_provider_add_module_location,
e55008a9
RL
7ossl_provider_set_fallback, ossl_provider_activate,
8ossl_provider_forall_loaded,
85e2417c 9ossl_provider_name, ossl_provider_dso,
c4532834
RL
10ossl_provider_module_name, ossl_provider_module_path,
11ossl_provider_teardown, ossl_provider_get_param_types,
099bd339
RL
12ossl_provider_get_params, ossl_provider_query_operation
13- internal provider routines
c4532834
RL
14
15=head1 SYNOPSIS
16
17 #include "internal/provider.h"
18
19 OSSL_PROVIDER *ossl_provider_find(OPENSSL_CTX *libctx, const char *name);
20 OSSL_PROVIDER *ossl_provider_new(OPENSSL_CTX *libctx, const char *name,
21 ossl_provider_init_fn *init_function);
22 int ossl_provider_upref(OSSL_PROVIDER *prov);
23 void ossl_provider_free(OSSL_PROVIDER *prov);
24
25 /* Setters */
26 int ossl_provider_add_module_location(OSSL_PROVIDER *prov, const char *loc);
e55008a9 27 int ossl_provider_set_fallback(OSSL_PROVIDER *prov);
c4532834
RL
28
29 /* Load and initialize the Provider */
30 int ossl_provider_activate(OSSL_PROVIDER *prov);
31
85e2417c
RL
32 /* Iterate over all loaded providers */
33 int ossl_provider_forall_loaded(OPENSSL_CTX *,
34 int (*cb)(OSSL_PROVIDER *provider,
35 void *cbdata),
36 void *cbdata);
37
c4532834
RL
38 /* Getters for other library functions */
39 const char *ossl_provider_name(OSSL_PROVIDER *prov);
40 const DSO *ossl_provider_dso(OSSL_PROVIDER *prov);
41 const char *ossl_provider_module_name(OSSL_PROVIDER *prov);
42 const char *ossl_provider_module_path(OSSL_PROVIDER *prov);
43
44 /* Thin wrappers around calls to the provider */
45 void ossl_provider_teardown(const OSSL_PROVIDER *prov);
46 const OSSL_ITEM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov);
47 int ossl_provider_get_params(const OSSL_PROVIDER *prov,
48 const OSSL_PARAM params[]);
099bd339
RL
49 const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
50 int operation_id,
51 int *no_cache);
c4532834
RL
52
53=head1 DESCRIPTION
54
55C<OSSL_PROVIDER> is a type that holds all the necessary information
56to handle a provider, regardless of if it's built in to the
57application or the OpenSSL libraries, or if it's a loadable provider
58module.
59Instances of this type are commonly refered to as I<provider object>s.
60
61A I<provider object> is always stored in a set of I<provider object>s
62in the library context.
63
64I<provider object>s are reference counted.
65
66I<provider object>s are initially inactive, i.e. they are only
67recorded in the store, but are not used.
68They are activated with the first call to ossl_provider_activate(),
69and are inactivated when ossl_provider_free() has been called as many
70times as ossl_provider_activate() has.
71
72=head2 Functions
73
74ossl_provider_find() finds an existing I<provider object> in the
75I<provider object> store by C<name>.
e55008a9 76The I<provider object> it finds gets its reference count
c4532834
RL
77incremented.
78
79ossl_provider_new() creates a new I<provider object> and stores it in
80the I<provider object> store, unless there already is one there with
81the same name.
82The reference counter of a newly created I<provider object> will
83always be 2; one for being added to the store, and one for the
84returned reference.
85To indicate a built-in provider, the C<init_function> argument must
86point at the provider initialization function for that provider.
87
88ossl_provider_free() decrements a I<provider object>'s reference
e55008a9
RL
89counter; if it drops below 2, the I<provider object> is assumed to
90have fallen out of use and will be inactivated (its teardown function
91is called); if it drops down to zero, the I<provider object> is
92assumed to have been taken out of the store, and the associated module
93will be unloaded if one was loaded, and the I<provider object> will be
94freed.
c4532834
RL
95
96ossl_provider_add_module_location() adds a location to look for a
97provider module.
98
e55008a9
RL
99ossl_provider_set_fallback() marks an available provider as fallback.
100Note that after this call, the I<provider object> pointer that was
101used can simply be dropped, but not freed.
102
c4532834
RL
103ossl_provider_activate() "activates" the provider for the given
104I<provider object>.
105What "activates" means depends on what type of I<provider object> it
106is:
107
108=over 4
109
110=item *
111
112If an initialization function was given with ossl_provider_new(), that
113function will get called.
114
115=item *
116
117If no intialization function was given with ossl_provider_new(), a
118loadable module with the C<name> that was given to ossl_provider_new()
119will be located and loaded, then the symbol C<OSSL_provider_init> will
120be located in that module, and called.
121
122=back
123
85e2417c
RL
124ossl_provider_forall_loaded() iterates over all the currently
125"activated" providers, and calls C<cb> for each of them.
e55008a9
RL
126If no providers have been "activated" yet, it tries to activate all
127available fallback providers and tries another iteration.
85e2417c 128
c4532834
RL
129ossl_provider_name() returns the name that was given with
130ossl_provider_new().
131
132ossl_provider_dso() returns a reference to the module, for providers
133that come in the form of loadable modules.
134
135ossl_provider_module_name() returns the file name of the module, for
136providers that come in the form of loadable modules.
137
138ossl_provider_module_path() returns the full path of the module file,
139for providers that come in the form of loadable modules.
140
141ossl_provider_teardown() calls the provider's C<teardown> function, if
142the provider has one.
143
144ossl_provider_get_param_types() calls the provider's C<get_param_types>
145function, if the provider has one.
146It should return an array of C<OSSL_ITEM> to describe all the
147parameters that the provider has for the I<provider object>.
148
149ossl_provider_get_params() calls the provider's parameter request
150responder.
151It should treat the given C<OSSL_PARAM> array as described in
152L<OSSL_PARAM(3)>.
153
099bd339
RL
154ossl_provider_query_operation() calls the provider's
155C<query_operation> function, if the provider has one.
156It should return an array of C<OSSL_ALGORITHM> for the given
157C<operation_id>.
158
c4532834
RL
159=head1 NOTES
160
161Locating a provider module happens as follows:
162
163=over 4
164
165=item 1.
166
167Look in each directory given by ossl_provider_add_module_location().
168
169=item 2.
170
171Look in the directory given by the environment variable
172B<OPENSSL_MODULES>.
173
174=item 3.
175
176Look in the directory given by the OpenSSL built in macro
177B<MODULESDIR>.
178
179=back
180
181=head1 RETURN VALUES
182
183ossl_provider_find() and ossl_provider_new() return a pointer to a
184I<provider object> (C<OSSL_PROVIDER>) on success, or B<NULL> on error.
185
186ossl_provider_upref() returns the value of the reference counter after
187it has been incremented.
188
189ossl_provider_free() doesn't return any value.
190
e55008a9
RL
191ossl_provider_add_module_location(), ossl_provider_set_fallback() and
192ossl_provider_activate() return 1 on success, or 0 on error.
c4532834
RL
193
194ossl_provider_name(), ossl_provider_dso(),
195ossl_provider_module_name(), and ossl_provider_module_path() return a
196pointer to their respective data if it's available, otherwise B<NULL>
197is returned.
198
199ossl_provider_teardown() doesnt't return any value.
200
201ossl_provider_get_param_types() returns a pointer to an C<OSSL_ITEM>
202array if this function is available in the provider, otherwise
203B<NULL>.
204
205ossl_provider_get_params() returns 1 on success, or 0 on error.
206If this function isn't available in the provider, 0 is returned.
207
208=head1 SEE ALSO
209
210L<OSSL_PROVIDER(3)>, L<provider(7)>
211
212=head1 HISTORY
213
214The functions described here were all added in OpenSSL 3.0.
215
216=head1 COPYRIGHT
217
218Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
219
220Licensed under the Apache License 2.0 (the "License"). You may not use
221this file except in compliance with the License. You can obtain a copy
222in the file LICENSE in the source distribution or at
223L<https://www.openssl.org/source/license.html>.
224
225=cut