VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.3/doc/internal/man3/ossl_provider_new.pod@ 95218

最後變更 在這個檔案從95218是 94320,由 vboxsync 提交於 3 年 前

libs/openssl-3.0.1: Export to OSE and fix copyright headers in Makefiles, bugref:10128

檔案大小: 16.7 KB
 
1=pod
2
3=head1 NAME
4
5ossl_provider_find, ossl_provider_new, ossl_provider_up_ref,
6ossl_provider_free,
7ossl_provider_set_fallback, ossl_provider_set_module_path,
8ossl_provider_add_parameter, ossl_provider_set_child, ossl_provider_get_parent,
9ossl_provider_up_ref_parent, ossl_provider_free_parent,
10ossl_provider_default_props_update, ossl_provider_get0_dispatch,
11ossl_provider_init_as_child, ossl_provider_deinit_child,
12ossl_provider_activate, ossl_provider_deactivate, ossl_provider_add_to_store,
13ossl_provider_ctx,
14ossl_provider_doall_activated,
15ossl_provider_name, ossl_provider_dso,
16ossl_provider_module_name, ossl_provider_module_path,
17ossl_provider_libctx,
18ossl_provider_teardown, ossl_provider_gettable_params,
19ossl_provider_get_params, ossl_provider_clear_all_operation_bits,
20ossl_provider_query_operation, ossl_provider_unquery_operation,
21ossl_provider_set_operation_bit, ossl_provider_test_operation_bit,
22ossl_provider_get_capabilities
23- internal provider routines
24
25=head1 SYNOPSIS
26
27 #include "internal/provider.h"
28
29 OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name,
30 int noconfig);
31 OSSL_PROVIDER *ossl_provider_new(OSSL_LIB_CTX *libctx, const char *name,
32 ossl_provider_init_fn *init_function
33 int noconfig);
34 int ossl_provider_up_ref(OSSL_PROVIDER *prov);
35 void ossl_provider_free(OSSL_PROVIDER *prov);
36
37 /* Setters */
38 int ossl_provider_set_fallback(OSSL_PROVIDER *prov);
39 int ossl_provider_set_module_path(OSSL_PROVIDER *prov, const char *path);
40 int ossl_provider_add_parameter(OSSL_PROVIDER *prov, const char *name,
41 const char *value);
42
43 /* Child Providers */
44 int ossl_provider_set_child(OSSL_PROVIDER *prov,
45 const OSSL_CORE_HANDLE *handle);
46 const OSSL_CORE_HANDLE *ossl_provider_get_parent(OSSL_PROVIDER *prov);
47 int ossl_provider_up_ref_parent(OSSL_PROVIDER *prov, int activate);
48 int ossl_provider_free_parent(OSSL_PROVIDER *prov, int deactivate);
49 int ossl_provider_default_props_update(OSSL_LIB_CTX *libctx,
50 const char *props);
51
52 /*
53 * Activate the Provider
54 * If the Provider is a module, the module will be loaded
55 */
56 int ossl_provider_activate(OSSL_PROVIDER *prov, int upcalls, int aschild);
57 int ossl_provider_deactivate(OSSL_PROVIDER *prov, int removechildren);
58 int ossl_provider_add_to_store(OSSL_PROVIDER *prov, OSSL_PROVIDER **actualprov,
59 int retain_fallbacks);
60
61 /* Return pointer to the provider's context */
62 void *ossl_provider_ctx(const OSSL_PROVIDER *prov);
63
64 const OSSL_DISPATCH *ossl_provider_get0_dispatch(const OSSL_PROVIDER *prov);
65
66 /* Iterate over all loaded providers */
67 int ossl_provider_doall_activated(OSSL_LIB_CTX *,
68 int (*cb)(OSSL_PROVIDER *provider,
69 void *cbdata),
70 void *cbdata);
71
72 /* Getters for other library functions */
73 const char *ossl_provider_name(OSSL_PROVIDER *prov);
74 const DSO *ossl_provider_dso(OSSL_PROVIDER *prov);
75 const char *ossl_provider_module_name(OSSL_PROVIDER *prov);
76 const char *ossl_provider_module_path(OSSL_PROVIDER *prov);
77 OSSL_LIB_CTX *ossl_provider_libctx(const OSSL_PROVIDER *prov);
78
79 /* Thin wrappers around calls to the provider */
80 void ossl_provider_teardown(const OSSL_PROVIDER *prov);
81 const OSSL_PARAM *ossl_provider_gettable_params(const OSSL_PROVIDER *prov);
82 int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
83 int ossl_provider_get_capabilities(const OSSL_PROVIDER *prov,
84 const char *capability,
85 OSSL_CALLBACK *cb,
86 void *arg);
87 const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
88 int operation_id,
89 int *no_cache);
90 void ossl_provider_unquery_operation(const OSSL_PROVIDER *prov,
91 int operation_id,
92 const OSSL_ALGORITHM *algs);
93
94 int ossl_provider_set_operation_bit(OSSL_PROVIDER *provider, size_t bitnum);
95 int ossl_provider_test_operation_bit(OSSL_PROVIDER *provider, size_t bitnum,
96 int *result);
97 int ossl_provider_clear_all_operation_bits(OSSL_LIB_CTX *libctx);
98
99 int ossl_provider_init_as_child(OSSL_LIB_CTX *ctx,
100 const OSSL_CORE_HANDLE *handle,
101 const OSSL_DISPATCH *in);
102 void ossl_provider_deinit_child(OSSL_LIB_CTX *ctx);
103
104=head1 DESCRIPTION
105
106I<OSSL_PROVIDER> is a type that holds all the necessary information
107to handle a provider, regardless of if it's built in to the
108application or the OpenSSL libraries, or if it's a loadable provider
109module.
110Instances of this type are commonly referred to as "provider objects".
111
112A provider object is always stored in a set of provider objects
113in the library context.
114
115Provider objects are reference counted.
116
117Provider objects are initially inactive, i.e. they are only recorded
118in the store, but are not used.
119They are activated with the first call to ossl_provider_activate(),
120and are deactivated with the last call to ossl_provider_deactivate().
121Activation affects a separate counter.
122
123=head2 Functions
124
125ossl_provider_find() finds an existing provider object in the provider
126object store by I<name>.
127The config file will be automatically loaded unless I<noconfig> is set.
128Typically I<noconfig> should be 0.
129We set I<noconfig> to 1 only when calling these functions while processing a
130config file in order to avoid recursively attempting to load the file.
131The provider object it finds has its reference count incremented.
132
133ossl_provider_new() creates a new provider object named I<name> and
134stores it in the provider object store, unless there already is one
135there with the same name.
136If there already is one with the same name, it's returned with its
137reference count incremented.
138The config file will be automatically loaded unless I<noconfig> is set.
139Typically I<noconfig> should be 0.
140We set I<noconfig> to 1 only when calling these functions while processing a
141config file in order to avoid recursively attempting to load the file.
142The reference count of a newly created provider object will always
143be 2; one for being added to the store, and one for the returned
144reference.
145If I<init_function> is NULL, the provider is assumed to be a
146dynamically loadable module, with the symbol B<OSSL_provider_init> as
147its initialisation function.
148If I<init_function> isn't NULL, the provider is assumed to be built
149in, with I<init_function> being the pointer to its initialisation
150function.
151For further description of the initialisation function, see the
152description of ossl_provider_activate() below.
153
154ossl_provider_up_ref() increments the provider object I<prov>'s
155reference count.
156
157ossl_provider_free() decrements the provider object I<prov>'s
158reference count; when it drops to zero, the provider object is assumed
159to have fallen out of use and will be deinitialized (its I<teardown>
160function is called), and the associated module will be unloaded if one
161was loaded, and I<prov> itself will be freed.
162
163ossl_provider_set_fallback() marks an available provider I<prov> as
164fallback.
165Note that after this call, the provider object pointer that was
166used can simply be dropped, but not freed.
167
168ossl_provider_set_module_path() sets the module path to load the
169provider module given the provider object I<prov>.
170This will be used in preference to automatically trying to figure out
171the path from the provider name and the default module directory (more
172on this in L</NOTES>).
173
174ossl_provider_libctx() returns the library context the given
175provider I<prov> is registered in.
176
177ossl_provider_add_parameter() adds a global parameter for the provider
178to retrieve as it sees fit.
179The parameters are a combination of I<name> and I<value>, and the
180provider will use the name to find the value it wants.
181Only text parameters can be given, and it's up to the provider to
182interpret them.
183
184ossl_provider_set_child() marks this provider as a child of a provider in the
185parent library context. I<handle> is the B<OSSL_CORE_HANDLE> object passed to
186the provider's B<OSSL_provider_init> function.
187
188ossl_provider_get_parent() obtains the handle on the parent provider.
189
190ossl_provider_up_ref_parent() increases the reference count on the parent
191provider. If I<activate> is nonzero then the parent provider is also activated.
192
193ossl_provider_free_parent() decreases the reference count on the parent
194provider. If I<deactivate> is nonzero then the parent provider is also
195deactivated.
196
197ossl_provider_default_props_update() is responsible for informing any child
198providers of an update to the default properties. The new properties are
199supplied in the I<props> string.
200
201ossl_provider_activate() "activates" the provider for the given
202provider object I<prov> by incrementing its activation count, flagging
203it as activated, and initializing it if it isn't already initialized.
204Initializing means one of the following:
205
206=over 4
207
208=item *
209
210If an initialization function was given with ossl_provider_new(), that
211function will get called.
212
213=item *
214
215If no initialization function was given with ossl_provider_new(), a
216loadable module with the I<name> that was given to ossl_provider_new()
217will be located and loaded, then the symbol B<OSSL_provider_init> will
218be located in that module, and called.
219
220=back
221
222If I<upcalls> is nonzero then, if this is a child provider, upcalls to the
223parent libctx will be made to inform it of an up-ref. If I<aschild> is nonzero
224then the provider will only be activated if it is a child provider. Otherwise
225no action is taken and ossl_provider_activate() returns success.
226
227ossl_provider_deactivate() "deactivates" the provider for the given
228provider object I<prov> by decrementing its activation count. When
229that count reaches zero, the activation flag is cleared. If the
230I<removechildren> parameter is 0 then no attempt is made to remove any
231associated child providers.
232
233ossl_provider_add_to_store() adds the provider I<prov> to the provider store and
234makes it available to other threads. This will prevent future automatic loading
235of fallback providers, unless I<retain_fallbacks> is true. If a provider of the
236same name already exists in the store then it is not added but this function
237still returns success. On success the I<actualprov> value is populated with a
238pointer to the provider of the given name that is now in the store. The
239reference passed in the I<prov> argument is consumed by this function. A
240reference to the provider that should be used is passed back in the
241I<actualprov> argument.
242
243ossl_provider_ctx() returns a context created by the provider.
244Outside of the provider, it's completely opaque, but it needs to be
245passed back to some of the provider functions.
246
247ossl_provider_get0_dispatch() returns the dispatch table that the provider
248initially returned in the I<out> parameter of its B<OSSL_provider_init>
249function.
250
251ossl_provider_doall_activated() iterates over all the currently
252"activated" providers, and calls I<cb> for each of them.
253If no providers have been "activated" yet, it tries to activate all
254available fallback providers before iterating over them.
255
256ossl_provider_name() returns the name that was given with
257ossl_provider_new().
258
259ossl_provider_dso() returns a reference to the module, for providers
260that come in the form of loadable modules.
261
262ossl_provider_module_name() returns the filename of the module, for
263providers that come in the form of loadable modules.
264
265ossl_provider_module_path() returns the full path of the module file,
266for providers that come in the form of loadable modules.
267
268ossl_provider_teardown() calls the provider's I<teardown> function, if
269the provider has one.
270
271ossl_provider_gettable_params() calls the provider's I<gettable_params>
272function, if the provider has one.
273It should return an array of I<OSSL_PARAM> to describe all the
274parameters that the provider has for the provider object.
275
276ossl_provider_get_params() calls the provider's parameter request
277responder.
278It should treat the given I<OSSL_PARAM> array as described in
279L<OSSL_PARAM(3)>.
280
281ossl_provider_get_capabilities() calls the provider's I<get_capabilities> function,
282if the provider has one. It provides the name of the I<capability> and a
283callback I<cb> parameter to call for each capability that has a matching name in
284the provider. The callback gets passed OSSL_PARAM details about the capability as
285well as the caller supplied argument I<arg>.
286
287ossl_provider_query_operation() calls the provider's
288I<query_operation> function, if the provider has one.
289It should return an array of I<OSSL_ALGORITHM> for the given
290I<operation_id>.
291
292ossl_provider_unquery_operation() informs the provider that the result of
293ossl_provider_query_operation() is no longer going to be directly accessed and
294that all relevant information has been copied.
295
296ossl_provider_set_operation_bit() registers a 1 for operation I<bitnum>
297in a bitstring that's internal to I<provider>.
298
299ossl_provider_test_operation_bit() checks if the bit operation I<bitnum>
300is set (1) or not (0) in the internal I<provider> bitstring, and sets
301I<*result> to 1 or 0 accorddingly.
302
303ossl_provider_clear_all_operation_bits() clears all of the operation bits
304to (0) for all providers in the library context I<libctx>.
305
306ossl_provider_init_as_child() stores in the library context I<ctx> references to
307the necessary upcalls for managing child providers. The I<handle> and I<in>
308parameters are the B<OSSL_CORE_HANDLE> and B<OSSL_DISPATCH> pointers that were
309passed to the provider's B<OSSL_provider_init> function.
310
311ossl_provider_deinit_child() deregisters callbacks from the parent library
312context about provider creation or removal events for the child library context
313I<ctx>. Must only be called if I<ctx> is a child library context.
314
315=head1 NOTES
316
317Locating a provider module happens as follows:
318
319=over 4
320
321=item 1.
322
323If a path was given with ossl_provider_set_module_path(), use that as
324module path.
325Otherwise, use the provider object's name as module path, with
326platform specific standard extensions added.
327
328=item 2.
329
330If the environment variable B<OPENSSL_MODULES> is defined, assume its
331value is a directory specification and merge it with the module path.
332Otherwise, merge the value of the OpenSSL built in macro B<MODULESDIR>
333with the module path.
334
335=back
336
337When this process is done, the result is used when trying to load the
338provider module.
339
340The command C<openssl version -m> can be used to find out the value
341of the built in macro B<MODULESDIR>.
342
343=head1 RETURN VALUES
344
345ossl_provider_find() and ossl_provider_new() return a pointer to a
346provider object (I<OSSL_PROVIDER>) on success, or NULL on error.
347
348ossl_provider_up_ref() returns the value of the reference count after
349it has been incremented.
350
351ossl_provider_free() doesn't return any value.
352
353ossl_provider_doall_activated() returns 1 if the callback was called for all
354activated providers. A return value of 0 means that the callback was not
355called for any activated providers.
356
357ossl_provider_set_module_path(), ossl_provider_set_fallback(),
358ossl_provider_activate(), ossl_provider_activate_leave_fallbacks() and
359ossl_provider_deactivate(), ossl_provider_add_to_store(),
360ossl_provider_default_props_update() return 1 on success, or 0 on error.
361
362ossl_provider_name(), ossl_provider_dso(),
363ossl_provider_module_name(), and ossl_provider_module_path() return a
364pointer to their respective data if it's available, otherwise NULL
365is returned.
366
367ossl_provider_libctx() return a pointer to the library context.
368This may be NULL, and is perfectly valid, as it denotes the default
369global library context.
370
371ossl_provider_teardown() doesn't return any value.
372
373ossl_provider_gettable_params() returns a pointer to a constant
374I<OSSL_PARAM> array if this function is available in the provider,
375otherwise NULL.
376
377ossl_provider_get_params() returns 1 on success, or 0 on error.
378If this function isn't available in the provider, 0 is returned.
379
380ossl_provider_set_operation_bit() and ossl_provider_test_operation_bit()
381return 1 on success, or 0 on error.
382
383ossl_provider_clear_all_operation_bits() returns 1 on success, or 0 on error.
384
385ossl_provider_get_capabilities() returns 1 on success, or 0 on error.
386If this function isn't available in the provider or the provider does not
387support the requested capability then 0 is returned.
388
389=head1 SEE ALSO
390
391L<OSSL_PROVIDER(3)>, L<provider(7)>, L<openssl(1)>
392
393=head1 HISTORY
394
395The functions described here were all added in OpenSSL 3.0.
396
397=head1 COPYRIGHT
398
399Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
400
401Licensed under the Apache License 2.0 (the "License"). You may not use
402this file except in compliance with the License. You can obtain a copy
403in the file LICENSE in the source distribution or at
404L<https://www.openssl.org/source/license.html>.
405
406=cut
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette