xref: /netbsd-src/crypto/external/bsd/openssl.old/dist/doc/man3/OSSL_STORE_open.pod (revision 4724848cf0da353df257f730694b7882798e5daf)
1*4724848cSchristos=pod
2*4724848cSchristos
3*4724848cSchristos=head1 NAME
4*4724848cSchristos
5*4724848cSchristosOSSL_STORE_CTX, OSSL_STORE_post_process_info_fn, OSSL_STORE_open,
6*4724848cSchristosOSSL_STORE_ctrl, OSSL_STORE_load, OSSL_STORE_eof, OSSL_STORE_error,
7*4724848cSchristosOSSL_STORE_close - Types and functions to read objects from a URI
8*4724848cSchristos
9*4724848cSchristos=head1 SYNOPSIS
10*4724848cSchristos
11*4724848cSchristos #include <openssl/store.h>
12*4724848cSchristos
13*4724848cSchristos typedef struct ossl_store_ctx_st OSSL_STORE_CTX;
14*4724848cSchristos
15*4724848cSchristos typedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *,
16*4724848cSchristos                                                             void *);
17*4724848cSchristos
18*4724848cSchristos OSSL_STORE_CTX *OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method,
19*4724848cSchristos                                 void *ui_data,
20*4724848cSchristos                                 OSSL_STORE_post_process_info_fn post_process,
21*4724848cSchristos                                 void *post_process_data);
22*4724848cSchristos int OSSL_STORE_ctrl(OSSL_STORE_CTX *ctx, int cmd, ... /* args */);
23*4724848cSchristos OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx);
24*4724848cSchristos int OSSL_STORE_eof(OSSL_STORE_CTX *ctx);
25*4724848cSchristos int OSSL_STORE_error(OSSL_STORE_CTX *ctx);
26*4724848cSchristos int OSSL_STORE_close(OSSL_STORE_CTX *ctx);
27*4724848cSchristos
28*4724848cSchristos=head1 DESCRIPTION
29*4724848cSchristos
30*4724848cSchristosThese functions help the application to fetch supported objects (see
31*4724848cSchristosL<OSSL_STORE_INFO(3)/SUPPORTED OBJECTS> for information on which those are)
32*4724848cSchristosfrom a given URI (see L</SUPPORTED SCHEMES> for more information on
33*4724848cSchristosthe supported URI schemes).
34*4724848cSchristosThe general method to do so is to "open" the URI using OSSL_STORE_open(),
35*4724848cSchristosread each available and supported object using OSSL_STORE_load() as long as
36*4724848cSchristosOSSL_STORE_eof() hasn't been reached, and finish it off with OSSL_STORE_close().
37*4724848cSchristos
38*4724848cSchristosThe retrieved information is stored in a B<OSSL_STORE_INFO>, which is further
39*4724848cSchristosdescribed in L<OSSL_STORE_INFO(3)>.
40*4724848cSchristos
41*4724848cSchristos=head2 Types
42*4724848cSchristos
43*4724848cSchristosB<OSSL_STORE_CTX> is a context variable that holds all the internal
44*4724848cSchristosinformation for OSSL_STORE_open(), OSSL_STORE_load(), OSSL_STORE_eof() and
45*4724848cSchristosOSSL_STORE_close() to work together.
46*4724848cSchristos
47*4724848cSchristos=head2 Functions
48*4724848cSchristos
49*4724848cSchristosOSSL_STORE_open() takes a uri or path I<uri>, password UI method
50*4724848cSchristosI<ui_method> with associated data I<ui_data>, and post processing
51*4724848cSchristoscallback I<post_process> with associated data I<post_process_data>,
52*4724848cSchristosopens a channel to the data located at that URI and returns a
53*4724848cSchristosB<OSSL_STORE_CTX> with all necessary internal information.
54*4724848cSchristosThe given I<ui_method> and I<ui_data> will be reused by all
55*4724848cSchristosfunctions that use B<OSSL_STORE_CTX> when interaction is needed,
56*4724848cSchristosfor instance to provide a password.
57*4724848cSchristosThe given I<post_process> and I<post_process_data> will be reused by
58*4724848cSchristosOSSL_STORE_load() to manipulate or drop the value to be returned.
59*4724848cSchristosThe I<post_process> function drops values by returning NULL, which
60*4724848cSchristoswill cause OSSL_STORE_load() to start its process over with loading
61*4724848cSchristosthe next object, until I<post_process> returns something other than
62*4724848cSchristosNULL, or the end of data is reached as indicated by OSSL_STORE_eof().
63*4724848cSchristos
64*4724848cSchristosOSSL_STORE_ctrl() takes a B<OSSL_STORE_CTX>, and command number I<cmd> and
65*4724848cSchristosmore arguments not specified here.
66*4724848cSchristosThe available loader specific command numbers and arguments they each
67*4724848cSchristostake depends on the loader that's used and is documented together with
68*4724848cSchristosthat loader.
69*4724848cSchristos
70*4724848cSchristosThere are also global controls available:
71*4724848cSchristos
72*4724848cSchristos=over 4
73*4724848cSchristos
74*4724848cSchristos=item B<OSSL_STORE_C_USE_SECMEM>
75*4724848cSchristos
76*4724848cSchristosControls if the loader should attempt to use secure memory for any
77*4724848cSchristosallocated B<OSSL_STORE_INFO> and its contents.
78*4724848cSchristosThis control expects one argument, a pointer to an B<int> that is expected to
79*4724848cSchristoshave the value 1 (yes) or 0 (no).
80*4724848cSchristosAny other value is an error.
81*4724848cSchristos
82*4724848cSchristos=back
83*4724848cSchristos
84*4724848cSchristosOSSL_STORE_load() takes a B<OSSL_STORE_CTX>, tries to load the next available
85*4724848cSchristosobject and return it wrapped with  B<OSSL_STORE_INFO>.
86*4724848cSchristos
87*4724848cSchristosOSSL_STORE_eof() takes a B<OSSL_STORE_CTX> and checks if we've reached the end
88*4724848cSchristosof data.
89*4724848cSchristos
90*4724848cSchristosOSSL_STORE_error() takes a B<OSSL_STORE_CTX> and checks if an error occurred in
91*4724848cSchristosthe last OSSL_STORE_load() call.
92*4724848cSchristosNote that it may still be meaningful to try and load more objects, unless
93*4724848cSchristosOSSL_STORE_eof() shows that the end of data has been reached.
94*4724848cSchristos
95*4724848cSchristosOSSL_STORE_close() takes a B<OSSL_STORE_CTX>, closes the channel that was opened
96*4724848cSchristosby OSSL_STORE_open() and frees all other information that was stored in the
97*4724848cSchristosB<OSSL_STORE_CTX>, as well as the B<OSSL_STORE_CTX> itself.
98*4724848cSchristosIf I<ctx> is NULL it does nothing.
99*4724848cSchristos
100*4724848cSchristos=head1 SUPPORTED SCHEMES
101*4724848cSchristos
102*4724848cSchristosThe basic supported scheme is B<file:>.
103*4724848cSchristosAny other scheme can be added dynamically, using
104*4724848cSchristosOSSL_STORE_register_loader().
105*4724848cSchristos
106*4724848cSchristos=head1 NOTES
107*4724848cSchristos
108*4724848cSchristosA string without a scheme prefix (that is, a non-URI string) is
109*4724848cSchristosimplicitly interpreted as using the F<file:> scheme.
110*4724848cSchristos
111*4724848cSchristosThere are some tools that can be used together with
112*4724848cSchristosOSSL_STORE_open() to determine if any failure is caused by an unparsable
113*4724848cSchristosURI, or if it's a different error (such as memory allocation
114*4724848cSchristosfailures); if the URI was parsable but the scheme unregistered, the
115*4724848cSchristostop error will have the reason C<OSSL_STORE_R_UNREGISTERED_SCHEME>.
116*4724848cSchristos
117*4724848cSchristosThese functions make no direct assumption regarding the pass phrase received
118*4724848cSchristosfrom the password callback.
119*4724848cSchristosThe loaders may make assumptions, however.
120*4724848cSchristosFor example, the B<file:> scheme loader inherits the assumptions made by
121*4724848cSchristosOpenSSL functionality that handles the different file types; this is mostly
122*4724848cSchristosrelevant for PKCS#12 objects.
123*4724848cSchristosSee L<passphrase-encoding(7)> for further information.
124*4724848cSchristos
125*4724848cSchristos=head1 RETURN VALUES
126*4724848cSchristos
127*4724848cSchristosOSSL_STORE_open() returns a pointer to a B<OSSL_STORE_CTX> on success, or
128*4724848cSchristosNULL on failure.
129*4724848cSchristos
130*4724848cSchristosOSSL_STORE_load() returns a pointer to a B<OSSL_STORE_INFO> on success, or
131*4724848cSchristosNULL on error or when end of data is reached.
132*4724848cSchristosUse OSSL_STORE_error() and OSSL_STORE_eof() to determine the meaning of a
133*4724848cSchristosreturned NULL.
134*4724848cSchristos
135*4724848cSchristosOSSL_STORE_eof() returns 1 if the end of data has been reached, otherwise
136*4724848cSchristos0.
137*4724848cSchristos
138*4724848cSchristosOSSL_STORE_error() returns 1 if an error occurred in an OSSL_STORE_load() call,
139*4724848cSchristosotherwise 0.
140*4724848cSchristos
141*4724848cSchristosOSSL_STORE_ctrl() and OSSL_STORE_close() returns 1 on success, or 0 on failure.
142*4724848cSchristos
143*4724848cSchristos=head1 SEE ALSO
144*4724848cSchristos
145*4724848cSchristosL<ossl_store(7)>, L<OSSL_STORE_INFO(3)>, L<OSSL_STORE_register_loader(3)>,
146*4724848cSchristosL<passphrase-encoding(7)>
147*4724848cSchristos
148*4724848cSchristos=head1 HISTORY
149*4724848cSchristos
150*4724848cSchristosOSSL_STORE_CTX(), OSSL_STORE_post_process_info_fn(), OSSL_STORE_open(),
151*4724848cSchristosOSSL_STORE_ctrl(), OSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close()
152*4724848cSchristoswere added in OpenSSL 1.1.1.
153*4724848cSchristos
154*4724848cSchristosHandling of NULL I<ctx> argument for OSSL_STORE_close()
155*4724848cSchristoswas introduced in OpenSSL 1.1.1h.
156*4724848cSchristos
157*4724848cSchristos=head1 COPYRIGHT
158*4724848cSchristos
159*4724848cSchristosCopyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
160*4724848cSchristos
161*4724848cSchristosLicensed under the OpenSSL license (the "License").  You may not use
162*4724848cSchristosthis file except in compliance with the License.  You can obtain a copy
163*4724848cSchristosin the file LICENSE in the source distribution or at
164*4724848cSchristosL<https://www.openssl.org/source/license.html>.
165*4724848cSchristos
166*4724848cSchristos=cut
167