blob: 4386c28da3a5b4a644aa44f28a86159e28d6f8b9 [file] [log] [blame]
Richard Levittee2e603f2016-12-13 13:46:53 +01001=pod
2
3=head1 NAME
4
5OSSL_STORE_LOADER, OSSL_STORE_LOADER_CTX, OSSL_STORE_LOADER_new,
6OSSL_STORE_LOADER_get0_engine, OSSL_STORE_LOADER_get0_scheme,
7OSSL_STORE_LOADER_set_open, OSSL_STORE_LOADER_set_ctrl,
8OSSL_STORE_LOADER_set_load, OSSL_STORE_LOADER_set_eof,
9OSSL_STORE_LOADER_set_error, OSSL_STORE_LOADER_set_close,
10OSSL_STORE_LOADER_free, OSSL_STORE_register_loader,
11OSSL_STORE_unregister_loader, OSSL_STORE_open_fn, OSSL_STORE_ctrl_fn,
12OSSL_STORE_load_fn, OSSL_STORE_eof_fn, OSSL_STORE_error_fn,
13OSSL_STORE_close_fn - Types and functions to manipulate, register and
14unregister STORE loaders for different URI schemes
15
16=head1 SYNOPSIS
17
18 #include <openssl/store.h>
19
20 typedef struct ossl_store_loader_st OSSL_STORE_LOADER;
21
22 OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme);
23 const ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER
24 *store_loader);
25 const char *OSSL_STORE_LOADER_get0_scheme(const OSSL_STORE_LOADER
26 *store_loader);
27
28 /* struct ossl_store_loader_ctx_st is defined differently by each loader */
29 typedef struct ossl_store_loader_ctx_st OSSL_STORE_LOADER_CTX;
30
31 typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_fn)(const char *uri,
32 const UI_METHOD *ui_method,
33 void *ui_data);
34 int OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *store_loader,
35 OSSL_STORE_open_fn store_open_function);
36 typedef int (*OSSL_STORE_ctrl_fn)(OSSL_STORE_LOADER_CTX *ctx, int cmd,
37 va_list args);
38 int OSSL_STORE_LOADER_set_ctrl(OSSL_STORE_LOADER *store_loader,
39 OSSL_STORE_ctrl_fn store_ctrl_function);
40 typedef OSSL_STORE_INFO *(*OSSL_STORE_load_fn)(OSSL_STORE_LOADER_CTX *ctx,
41 UI_METHOD *ui_method,
42 void *ui_data);
43 int OSSL_STORE_LOADER_set_load(OSSL_STORE_LOADER *store_loader,
44 OSSL_STORE_load_fn store_load_function);
45 typedef int (*OSSL_STORE_eof_fn)(OSSL_STORE_LOADER_CTX *ctx);
46 int OSSL_STORE_LOADER_set_eof(OSSL_STORE_LOADER *store_loader,
47 OSSL_STORE_eof_fn store_eof_function);
48 typedef int (*OSSL_STORE_error_fn)(OSSL_STORE_LOADER_CTX *ctx);
49 int OSSL_STORE_LOADER_set_error(OSSL_STORE_LOADER *store_loader,
50 OSSL_STORE_error_fn store_error_function);
51 typedef int (*OSSL_STORE_close_fn)(OSSL_STORE_LOADER_CTX *ctx);
52 int OSSL_STORE_LOADER_set_close(OSSL_STORE_LOADER *store_loader,
53 OSSL_STORE_close_fn store_close_function);
54 void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *store_loader);
55
56 int OSSL_STORE_register_loader(OSSL_STORE_LOADER *loader);
57 OSSL_STORE_LOADER *OSSL_STORE_unregister_loader(const char *scheme);
58
59=head1 DESCRIPTION
60
61These functions help applications and engines to create loaders for
62schemes they support.
63
64=head2 Types
65
66B<OSSL_STORE_LOADER> is the type to hold a loader.
67It contains a scheme and the functions needed to implement
68OSSL_STORE_open(), OSSL_STORE_load(), OSSL_STORE_eof(), OSSL_STORE_error() and
69OSSL_STORE_close() for this scheme.
70
71B<OSSL_STORE_LOADER_CTX> is a type template, to be defined by each loader
72using B<struct ossl_store_loader_ctx_st { ... }>.
73
74B<OSSL_STORE_open_fn>, B<OSSL_STORE_ctrl_fn>, B<OSSL_STORE_load_fn>,
75B<OSSL_STORE_eof_fn> and B<OSSL_STORE_close_fn> are the function pointer
76types used within a STORE loader.
77The functions pointed at define the functionality of the given loader.
78
79=over 4
80
81=item B<OSSL_STORE_open_fn>
82
83This function takes a URI and is expected to interpret it in the best
84manner possible according to the scheme the loader implements, it also
85takes a B<UI_METHOD> and associated data, to be used any time
86something needs to be prompted for.
87Furthermore, this function is expected to initialize what needs to be
88initialized, to create a privata data store (B<OSSL_STORE_LOADER_CTX>, see
89above), and to return it.
90If something goes wrong, this function is expected to return NULL.
91
92=item B<OSSL_STORE_ctrl_fn>
93
94This function takes a B<OSSL_STORE_LOADER_CTX> pointer, a command number
95B<cmd> and a B<va_list> B<args> and is used to manipulate loader
96specific parameters.
97
98=begin comment
99
100Globally known command numbers are documented in L<OSSL_STORE_ctrl(3)>,
101along with what B<args> are expected with each of them.
102
103=end comment
104
105Loader specific command numbers must begin at B<OSSL_STORE_C_CUSTOM_START>.
106Any number below that is reserved for future globally known command
107numbers.
108
109This function is expected to return 1 on success, 0 on error.
110
111=item B<OSSL_STORE_load_fn>
112
113This function takes a B<OSSL_STORE_LOADER_CTX> pointer and a B<UI_METHOD>
114with associated data.
115It's expected to load the next available data, mold it into a data
116structure that can be wrapped in a B<OSSL_STORE_INFO> using one of the
117L<OSSL_STORE_INFO(3)> functions.
118If no more data is available or an error occurs, this function is
119expected to return NULL.
120The B<OSSL_STORE_eof_fn> and B<OSSL_STORE_error_fn> functions must indicate if
121it was in fact the end of data or if an error occured.
122
123Note that this function retrives I<one> data item only.
124
125=item B<OSSL_STORE_eof_fn>
126
127This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
128return 1 to indicate that the end of available data has been reached.
129It is otherwise expected to return 0.
130
131=item B<OSSL_STORE_error_fn>
132
133This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
134return 1 to indicate that an error occured in a previous call to the
135B<OSSL_STORE_load_fn> function.
136It is otherwise expected to return 0.
137
138=item B<OSSL_STORE_close_fn>
139
140This function takes a B<OSSL_STORE_LOADER_CTX> pointer and is expected to
141close or shut down what needs to be closed, and finally free the
142contents of the B<OSSL_STORE_LOADER_CTX> pointer.
143It returns 1 on success and 0 on error.
144
145=back
146
147=head2 Functions
148
149OSSL_STORE_LOADER_new() creates a new B<OSSL_STORE_LOADER>.
150It takes an B<ENGINE> B<e> and a string B<scheme>.
151B<scheme> must I<always> be set.
152Both B<e> and B<scheme> are used as is and must therefore be alive as
153long as the created loader is.
154
155OSSL_STORE_LOADER_get0_engine() returns the engine of the B<store_loader>.
156OSSL_STORE_LOADER_get0_scheme() returns the scheme of the B<store_loader>.
157
158OSSL_STORE_LOADER_set_open() sets the opener function for the
159B<store_loader>.
160
161OSSL_STORE_LOADER_set_ctrl() sets the control function for the
162B<store_loader>.
163
164OSSL_STORE_LOADER_set_load() sets the loader function for the
165B<store_loader>.
166
167OSSL_STORE_LOADER_set_eof() sets the end of file checker function for the
168B<store_loader>.
169
170OSSL_STORE_LOADER_set_close() sets the closing function for the
171B<store_loader>.
172
173OSSL_STORE_LOADER_free() frees the given B<store_loader>.
174
175OSSL_STORE_register_loader() register the given B<store_loader> and thereby
176makes it available for use with OSSL_STORE_open(), OSSL_STORE_load(),
177OSSL_STORE_eof() and OSSL_STORE_close().
178
179OSSL_STORE_unregister_loader() unregister the store loader for the given
180B<scheme>.
181
182=head1 NOTES
183
184The B<file:> scheme has built in support.
185
186=head1 RETURN VALUES
187
188The functions with the types B<OSSL_STORE_open_fn>, B<OSSL_STORE_ctrl_fn>,
189B<OSSL_STORE_load_fn>, B<OSSL_STORE_eof_fn> and B<OSSL_STORE_close_fn> have the
190same return values as OSSL_STORE_open(), OSSL_STORE_load(), OSSL_STORE_eof() and
191OSSL_STORE_close(), respectively.
192
193OSSL_STORE_LOADER_new() returns a pointer to a B<OSSL_STORE_LOADER> on success,
194or B<NULL> on failure.
195
196OSSL_STORE_LOADER_set_open(), OSSL_STORE_LOADER_set_ctrl(),
197OSSL_STORE_LOADER_set_load(), OSSL_STORE_LOADER_set_eof() and
198OSSL_STORE_LOADER_set_close() return 1 on success, or 0 on failure.
199
200OSSL_STORE_register_loader() returns 1 on success, or 0 on failure.
201
202OSSL_STORE_unregister_loader() returns the unregistered loader on success,
203or B<NULL> on failure.
204
205=head1 SEE ALSO
206
207L<ossl_store(7)>, L<OSSL_STORE_open(3)>
208
209=head1 HISTORY
210
211OSSL_STORE_LOADER(), OSSL_STORE_LOADER_CTX(), OSSL_STORE_LOADER_new(),
212OSSL_STORE_LOADER_set0_scheme(), OSSL_STORE_LOADER_set_open(),
213OSSL_STORE_LOADER_set_ctrl(), OSSL_STORE_LOADER_set_load(),
214OSSL_STORE_LOADER_set_eof(), OSSL_STORE_LOADER_set_close(),
215OSSL_STORE_LOADER_free(), OSSL_STORE_register_loader(),
216OSSL_STORE_unregister_loader(), OSSL_STORE_open_fn(), OSSL_STORE_ctrl_fn(),
217OSSL_STORE_load_fn(), OSSL_STORE_eof_fn() and OSSL_STORE_close_fn()
218were added to OpenSSL 1.1.1.
219
220=head1 COPYRIGHT
221
222Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
223
224Licensed under the OpenSSL license (the "License"). You may not use
225this file except in compliance with the License. You can obtain a copy
226in the file LICENSE in the source distribution or at
227L<https://www.openssl.org/source/license.html>.
228
229=cut