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