]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/OSSL_STORE_LOADER.pod
Don't hold a lock when calling a callback in ossl_namemap_doall_names
[thirdparty/openssl.git] / doc / man3 / OSSL_STORE_LOADER.pod
CommitLineData
e2e603fe
RL
1=pod
2
3=head1 NAME
4
c4fc564d
RL
5OSSL_STORE_LOADER,
6OSSL_STORE_LOADER_fetch,
7OSSL_STORE_LOADER_up_ref,
8OSSL_STORE_LOADER_free,
9OSSL_STORE_LOADER_provider,
10OSSL_STORE_LOADER_properties,
11OSSL_STORE_LOADER_is_a,
12OSSL_STORE_LOADER_number,
13OSSL_STORE_LOADER_do_all_provided,
14OSSL_STORE_LOADER_names_do_all,
15OSSL_STORE_LOADER_CTX, OSSL_STORE_LOADER_new,
e2e603fe 16OSSL_STORE_LOADER_get0_engine, OSSL_STORE_LOADER_get0_scheme,
d8652be0 17OSSL_STORE_LOADER_set_open, OSSL_STORE_LOADER_set_open_ex,
faa64bca
RL
18OSSL_STORE_LOADER_set_attach, OSSL_STORE_LOADER_set_ctrl,
19OSSL_STORE_LOADER_set_expect, OSSL_STORE_LOADER_set_find,
20OSSL_STORE_LOADER_set_load, OSSL_STORE_LOADER_set_eof,
21OSSL_STORE_LOADER_set_error, OSSL_STORE_LOADER_set_close,
c4fc564d 22OSSL_STORE_register_loader, OSSL_STORE_unregister_loader,
d8652be0 23OSSL_STORE_open_fn, OSSL_STORE_open_ex_fn,
faa64bca 24OSSL_STORE_attach_fn, OSSL_STORE_ctrl_fn,
6ab6decc 25OSSL_STORE_expect_fn, OSSL_STORE_find_fn,
e2e603fe
RL
26OSSL_STORE_load_fn, OSSL_STORE_eof_fn, OSSL_STORE_error_fn,
27OSSL_STORE_close_fn - Types and functions to manipulate, register and
28unregister STORE loaders for different URI schemes
29
30=head1 SYNOPSIS
31
32 #include <openssl/store.h>
33
34 typedef struct ossl_store_loader_st OSSL_STORE_LOADER;
35
c4fc564d 36 OSSL_STORE_LOADER *OSSL_STORE_LOADER_fetch(const char *scheme,
b4250010 37 OSSL_LIB_CTX *libctx,
c4fc564d
RL
38 const char *properties);
39 int OSSL_STORE_LOADER_up_ref(OSSL_STORE_LOADER *loader);
40 void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader);
41 const OSSL_PROVIDER *OSSL_STORE_LOADER_provider(const OSSL_STORE_LOADER *
42 loader);
43 const char *OSSL_STORE_LOADER_properties(const OSSL_STORE_LOADER *loader);
44 int OSSL_STORE_LOADER_number(const OSSL_STORE_LOADER *loader);
45 int OSSL_STORE_LOADER_is_a(const OSSL_STORE_LOADER *loader,
46 const char *scheme);
b4250010 47 void OSSL_STORE_LOADER_do_all_provided(OSSL_LIB_CTX *libctx,
c4fc564d
RL
48 void (*fn)(OSSL_STORE_LOADER *loader,
49 void *arg),
50 void *arg);
d84f5515
MC
51 int OSSL_STORE_LOADER_names_do_all(const OSSL_STORE_LOADER *loader,
52 void (*fn)(const char *name, void *data),
53 void *data);
c4fc564d 54
a1447076
RL
55Deprecated since OpenSSL 3.0, can be hidden entirely by defining
56B<OPENSSL_API_COMPAT> with a suitable version value, see
57L<openssl_user_macros(7)>:
c4fc564d 58
e2e603fe
RL
59 OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme);
60 const ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER
61 *store_loader);
62 const char *OSSL_STORE_LOADER_get0_scheme(const OSSL_STORE_LOADER
63 *store_loader);
64
65 /* struct ossl_store_loader_ctx_st is defined differently by each loader */
66 typedef struct ossl_store_loader_ctx_st OSSL_STORE_LOADER_CTX;
67
6725682d
SL
68 typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_fn)(
69 const char *uri, const UI_METHOD *ui_method, void *ui_data);
e2e603fe
RL
70 int OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *store_loader,
71 OSSL_STORE_open_fn store_open_function);
d8652be0 72 typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_ex_fn)(
faa64bca 73 const char *uri, const UI_METHOD *ui_method, void *ui_data);
d8652be0 74 int OSSL_STORE_LOADER_set_open_ex
faa64bca 75 (OSSL_STORE_LOADER *store_loader,
d8652be0 76 OSSL_STORE_open_ex_fn store_open_ex_function);
6725682d
SL
77 typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_attach_fn)
78 (const OSSL_STORE_LOADER *loader, BIO *bio,
b4250010 79 OSSL_LIB_CTX *libctx, const char *propq,
6725682d 80 const UI_METHOD *ui_method, void *ui_data);
6ab6ecfd
RL
81 int OSSL_STORE_LOADER_set_attach(OSSL_STORE_LOADER *loader,
82 OSSL_STORE_attach_fn attach_function);
e2e603fe
RL
83 typedef int (*OSSL_STORE_ctrl_fn)(OSSL_STORE_LOADER_CTX *ctx, int cmd,
84 va_list args);
85 int OSSL_STORE_LOADER_set_ctrl(OSSL_STORE_LOADER *store_loader,
86 OSSL_STORE_ctrl_fn store_ctrl_function);
ce9586b9
RL
87 typedef int (*OSSL_STORE_expect_fn)(OSSL_STORE_LOADER_CTX *ctx, int expected);
88 int OSSL_STORE_LOADER_set_expect(OSSL_STORE_LOADER *loader,
89 OSSL_STORE_expect_fn expect_function);
6ab6decc
RL
90 typedef int (*OSSL_STORE_find_fn)(OSSL_STORE_LOADER_CTX *ctx,
91 OSSL_STORE_SEARCH *criteria);
92 int OSSL_STORE_LOADER_set_find(OSSL_STORE_LOADER *loader,
93 OSSL_STORE_find_fn find_function);
e2e603fe
RL
94 typedef OSSL_STORE_INFO *(*OSSL_STORE_load_fn)(OSSL_STORE_LOADER_CTX *ctx,
95 UI_METHOD *ui_method,
96 void *ui_data);
97 int OSSL_STORE_LOADER_set_load(OSSL_STORE_LOADER *store_loader,
98 OSSL_STORE_load_fn store_load_function);
99 typedef int (*OSSL_STORE_eof_fn)(OSSL_STORE_LOADER_CTX *ctx);
100 int OSSL_STORE_LOADER_set_eof(OSSL_STORE_LOADER *store_loader,
101 OSSL_STORE_eof_fn store_eof_function);
102 typedef int (*OSSL_STORE_error_fn)(OSSL_STORE_LOADER_CTX *ctx);
103 int OSSL_STORE_LOADER_set_error(OSSL_STORE_LOADER *store_loader,
104 OSSL_STORE_error_fn store_error_function);
105 typedef int (*OSSL_STORE_close_fn)(OSSL_STORE_LOADER_CTX *ctx);
106 int OSSL_STORE_LOADER_set_close(OSSL_STORE_LOADER *store_loader,
107 OSSL_STORE_close_fn store_close_function);
108 void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *store_loader);
dae2218d 109
e2e603fe
RL
110 int OSSL_STORE_register_loader(OSSL_STORE_LOADER *loader);
111 OSSL_STORE_LOADER *OSSL_STORE_unregister_loader(const char *scheme);
112
113=head1 DESCRIPTION
114
c4fc564d 115B<OSSL_STORE_LOADER> is a method for OSSL_STORE loaders, which implement
d8652be0 116OSSL_STORE_open(), OSSL_STORE_open_ex(), OSSL_STORE_load(),
c4fc564d
RL
117OSSL_STORE_eof(), OSSL_STORE_error() and OSSL_STORE_close() for specific
118storage schemes.
e2e603fe 119
c4fc564d 120OSSL_STORE_LOADER_fetch() looks for an implementation for a storage
b4250010 121I<scheme> within the providers that has been loaded into the B<OSSL_LIB_CTX>
c4fc564d 122given by I<ctx>, and with the properties given by I<properties>.
e2e603fe 123
c4fc564d
RL
124OSSL_STORE_LOADER_up_ref() increments the reference count for the given
125I<loader>.
126
127OSSL_STORE_LOADER_free() decrements the reference count for the given
128I<loader>, and when the count reaches zero, frees it.
129
130OSSL_STORE_LOADER_provider() returns the provider of the given
131I<loader>.
132
133OSSL_STORE_LOADER_properties() returns the property definition associated
134with the given I<loader>.
135
136OSSL_STORE_LOADER_is_a() checks if I<loader> is an implementation
137of an algorithm that's identifiable with I<scheme>.
138
139OSSL_STORE_LOADER_number() returns the internal dynamic number assigned
140to the given I<loader>.
141
142OSSL_STORE_LOADER_do_all_provided() traverses all store implementations
143by all activated providers in the library context I<libctx>, and for each
144of the implementations, calls I<fn> with the implementation method and
145I<data> as arguments.
146
147OSSL_STORE_LOADER_names_do_all() traverses all names for the given
148I<loader>, and calls I<fn> with each name and I<data>.
149
a1447076 150=head2 Legacy Types and Functions (deprecated)
c4fc564d
RL
151
152These functions help applications and engines to create loaders for
a1447076
RL
153schemes they support. These are all deprecated and discouraged in favour of
154provider implementations, see L<provider-storemgmt(7)>.
e2e603fe
RL
155
156B<OSSL_STORE_LOADER_CTX> is a type template, to be defined by each loader
c4fc564d 157using C<struct ossl_store_loader_ctx_st { ... }>.
e2e603fe 158
d8652be0 159B<OSSL_STORE_open_fn>, B<OSSL_STORE_open_ex_fn>,
faa64bca
RL
160B<OSSL_STORE_ctrl_fn>, B<OSSL_STORE_expect_fn>, B<OSSL_STORE_find_fn>,
161B<OSSL_STORE_load_fn>, B<OSSL_STORE_eof_fn>, and B<OSSL_STORE_close_fn>
ce9586b9 162are the function pointer types used within a STORE loader.
e2e603fe
RL
163The functions pointed at define the functionality of the given loader.
164
165=over 4
166
d8652be0 167=item B<OSSL_STORE_open_fn> and B<OSSL_STORE_open_ex_fn>
e2e603fe 168
d8652be0 169B<OSSL_STORE_open_ex_fn> takes a URI and is expected to
faa64bca
RL
170interpret it in the best manner possible according to the scheme the
171loader implements. It also takes a B<UI_METHOD> and associated data,
172to be used any time something needs to be prompted for, as well as a
173library context I<libctx> with an associated property query I<propq>,
174to be used when fetching necessary algorithms to perform the loads.
e2e603fe 175Furthermore, this function is expected to initialize what needs to be
faa64bca
RL
176initialized, to create a private data store (B<OSSL_STORE_LOADER_CTX>,
177see above), and to return it.
e2e603fe
RL
178If something goes wrong, this function is expected to return NULL.
179
faa64bca 180B<OSSL_STORE_open_fn> does the same thing as
d8652be0 181B<OSSL_STORE_open_ex_fn> but uses NULL for the library
faa64bca
RL
182context I<libctx> and property query I<propq>.
183
184=item B<OSSL_STORE_attach_fn>
6ab6ecfd 185
faa64bca 186This function takes a B<BIO>, otherwise works like
d8652be0 187B<OSSL_STORE_open_ex_fn>.
6ab6ecfd 188
e2e603fe
RL
189=item B<OSSL_STORE_ctrl_fn>
190
191This function takes a B<OSSL_STORE_LOADER_CTX> pointer, a command number
c4fc564d 192I<cmd> and a B<va_list> I<args> and is used to manipulate loader
e2e603fe
RL
193specific parameters.
194
195=begin comment
196
197Globally known command numbers are documented in L<OSSL_STORE_ctrl(3)>,
c4fc564d 198along with what I<args> are expected with each of them.
e2e603fe
RL
199
200=end comment
201
202Loader specific command numbers must begin at B<OSSL_STORE_C_CUSTOM_START>.
203Any number below that is reserved for future globally known command
204numbers.
205
206This function is expected to return 1 on success, 0 on error.
207
ce9586b9
RL
208=item B<OSSL_STORE_expect_fn>
209
210This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a B<OSSL_STORE_INFO>
c4fc564d 211identity I<expected>, and is used to tell the loader what object type is
ce9586b9 212expected.
c4fc564d 213I<expected> may be zero to signify that no specific object type is expected.
ce9586b9
RL
214
215This function is expected to return 1 on success, 0 on error.
216
6ab6decc
RL
217=item B<OSSL_STORE_find_fn>
218
219This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a
220B<OSSL_STORE_SEARCH> search criterion, and is used to tell the loader what
221to search for.
222
c4fc564d 223When called with the loader context being NULL, this function is expected
6ab6decc
RL
224to return 1 if the loader supports the criterion, otherwise 0.
225
c4fc564d 226When called with the loader context being something other than NULL, this
6ab6decc
RL
227function is expected to return 1 on success, 0 on error.
228
e2e603fe
RL
229=item B<OSSL_STORE_load_fn>
230
231This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a B<UI_METHOD>
232with associated data.
233It's expected to load the next available data, mold it into a data
234structure that can be wrapped in a B<OSSL_STORE_INFO> using one of the
235L<OSSL_STORE_INFO(3)> functions.
236If no more data is available or an error occurs, this function is
237expected to return NULL.
238The B<OSSL_STORE_eof_fn> and B<OSSL_STORE_error_fn> functions must indicate if
a970b14f 239it was in fact the end of data or if an error occurred.
e2e603fe 240
a970b14f 241Note that this function retrieves I<one> data item only.
e2e603fe
RL
242
243=item B<OSSL_STORE_eof_fn>
244
245This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
246return 1 to indicate that the end of available data has been reached.
247It is otherwise expected to return 0.
248
249=item B<OSSL_STORE_error_fn>
250
251This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
3266cf58 252return 1 to indicate that an error occurred in a previous call to the
e2e603fe
RL
253B<OSSL_STORE_load_fn> function.
254It is otherwise expected to return 0.
255
256=item B<OSSL_STORE_close_fn>
257
258This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
259close or shut down what needs to be closed, and finally free the
260contents of the B<OSSL_STORE_LOADER_CTX> pointer.
261It returns 1 on success and 0 on error.
262
263=back
264
e2e603fe 265OSSL_STORE_LOADER_new() creates a new B<OSSL_STORE_LOADER>.
c4fc564d
RL
266It takes an B<ENGINE> I<e> and a string I<scheme>.
267I<scheme> must I<always> be set.
268Both I<e> and I<scheme> are used as is and must therefore be alive as
e2e603fe
RL
269long as the created loader is.
270
c4fc564d
RL
271OSSL_STORE_LOADER_get0_engine() returns the engine of the I<store_loader>.
272OSSL_STORE_LOADER_get0_scheme() returns the scheme of the I<store_loader>.
e2e603fe
RL
273
274OSSL_STORE_LOADER_set_open() sets the opener function for the
c4fc564d 275I<store_loader>.
e2e603fe 276
d8652be0 277OSSL_STORE_LOADER_set_open_ex() sets the opener with library context
faa64bca
RL
278function for the I<store_loader>.
279
6ab6ecfd 280OSSL_STORE_LOADER_set_attach() sets the attacher function for the
c4fc564d 281I<store_loader>.
6ab6ecfd 282
e2e603fe 283OSSL_STORE_LOADER_set_ctrl() sets the control function for the
c4fc564d 284I<store_loader>.
e2e603fe 285
ce9586b9 286OSSL_STORE_LOADER_set_expect() sets the expect function for the
c4fc564d 287I<store_loader>.
ce9586b9 288
e2e603fe 289OSSL_STORE_LOADER_set_load() sets the loader function for the
c4fc564d 290I<store_loader>.
e2e603fe
RL
291
292OSSL_STORE_LOADER_set_eof() sets the end of file checker function for the
c4fc564d 293I<store_loader>.
e2e603fe
RL
294
295OSSL_STORE_LOADER_set_close() sets the closing function for the
c4fc564d 296I<store_loader>.
e2e603fe 297
c4fc564d 298OSSL_STORE_LOADER_free() frees the given I<store_loader>.
e2e603fe 299
c4fc564d 300OSSL_STORE_register_loader() register the given I<store_loader> and
faa64bca 301thereby makes it available for use with OSSL_STORE_open(),
d8652be0 302OSSL_STORE_open_ex(), OSSL_STORE_load(), OSSL_STORE_eof()
faa64bca 303and OSSL_STORE_close().
e2e603fe
RL
304
305OSSL_STORE_unregister_loader() unregister the store loader for the given
c4fc564d 306I<scheme>.
e2e603fe 307
c4fc564d 308=head1 RETURN VALUES
e2e603fe 309
c4fc564d
RL
310OSSL_STORE_LOADER_fetch() returns a pointer to an OSSL_STORE_LOADER object,
311or NULL on error.
e2e603fe 312
c4fc564d
RL
313OSSL_STORE_LOADER_up_ref() returns 1 on success, or 0 on error.
314
d84f5515
MC
315OSSL_STORE_LOADER_names_do_all() returns 1 if the callback was called for all
316names. A return value of 0 means that the callback was not called for any names.
317
c4fc564d
RL
318OSSL_STORE_LOADER_free() doesn't return any value.
319
320OSSL_STORE_LOADER_provider() returns a pointer to a provider object, or
321NULL on error.
322
323OSSL_STORE_LOADER_properties() returns a pointer to a property
324definition string, or NULL on error.
325
326OSSL_STORE_LOADER_is_a() returns 1 if I<loader> was identifiable,
327otherwise 0.
328
329OSSL_STORE_LOADER_number() returns an integer.
e2e603fe 330
faa64bca 331The functions with the types B<OSSL_STORE_open_fn>,
d8652be0 332B<OSSL_STORE_open_ex_fn>, B<OSSL_STORE_ctrl_fn>,
faa64bca
RL
333B<OSSL_STORE_expect_fn>, B<OSSL_STORE_load_fn>, B<OSSL_STORE_eof_fn>
334and B<OSSL_STORE_close_fn> have the same return values as OSSL_STORE_open(),
d8652be0 335OSSL_STORE_open_ex(), OSSL_STORE_ctrl(), OSSL_STORE_expect(),
ce9586b9 336OSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close(), respectively.
e2e603fe
RL
337
338OSSL_STORE_LOADER_new() returns a pointer to a B<OSSL_STORE_LOADER> on success,
c4fc564d 339or NULL on failure.
e2e603fe 340
d8652be0 341OSSL_STORE_LOADER_set_open(), OSSL_STORE_LOADER_set_open_ex(),
faa64bca
RL
342OSSL_STORE_LOADER_set_ctrl(), OSSL_STORE_LOADER_set_load(),
343OSSL_STORE_LOADER_set_eof() and OSSL_STORE_LOADER_set_close() return 1
344on success, or 0 on failure.
e2e603fe
RL
345
346OSSL_STORE_register_loader() returns 1 on success, or 0 on failure.
347
348OSSL_STORE_unregister_loader() returns the unregistered loader on success,
c4fc564d 349or NULL on failure.
e2e603fe
RL
350
351=head1 SEE ALSO
352
b4250010 353L<ossl_store(7)>, L<OSSL_STORE_open(3)>, L<OSSL_LIB_CTX(3)>,
c4fc564d 354L<provider-storemgmt(7)>
e2e603fe
RL
355
356=head1 HISTORY
357
c4fc564d
RL
358OSSL_STORE_LOADER_fetch(), OSSL_STORE_LOADER_up_ref(),
359OSSL_STORE_LOADER_free(), OSSL_STORE_LOADER_provider(),
360OSSL_STORE_LOADER_properties(), OSSL_STORE_LOADER_is_a(),
361OSSL_STORE_LOADER_number(), OSSL_STORE_LOADER_do_all_provided() and
362OSSL_STORE_LOADER_names_do_all() were added in OpenSSL 3.0.
363
d8652be0 364OSSL_STORE_open_ex_fn() was added in OpenSSL 3.0.
faa64bca
RL
365
366B<OSSL_STORE_LOADER>, B<OSSL_STORE_LOADER_CTX>, OSSL_STORE_LOADER_new(),
e2e603fe
RL
367OSSL_STORE_LOADER_set0_scheme(), OSSL_STORE_LOADER_set_open(),
368OSSL_STORE_LOADER_set_ctrl(), OSSL_STORE_LOADER_set_load(),
369OSSL_STORE_LOADER_set_eof(), OSSL_STORE_LOADER_set_close(),
370OSSL_STORE_LOADER_free(), OSSL_STORE_register_loader(),
371OSSL_STORE_unregister_loader(), OSSL_STORE_open_fn(), OSSL_STORE_ctrl_fn(),
372OSSL_STORE_load_fn(), OSSL_STORE_eof_fn() and OSSL_STORE_close_fn()
a1447076 373were added in OpenSSL 1.1.1, and became deprecated in OpenSSL 3.0.
e2e603fe
RL
374
375=head1 COPYRIGHT
376
454afd98 377Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
e2e603fe 378
4746f25a 379Licensed under the Apache License 2.0 (the "License"). You may not use
e2e603fe
RL
380this file except in compliance with the License. You can obtain a copy
381in the file LICENSE in the source distribution or at
382L<https://www.openssl.org/source/license.html>.
383
384=cut