xref: /freebsd/crypto/openssl/doc/man3/OSSL_STORE_open.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5*b077aed3SPierre ProncheryOSSL_STORE_CTX, OSSL_STORE_post_process_info_fn,
6*b077aed3SPierre ProncheryOSSL_STORE_open, OSSL_STORE_open_ex,
7*b077aed3SPierre ProncheryOSSL_STORE_ctrl, OSSL_STORE_load, OSSL_STORE_eof,
8*b077aed3SPierre ProncheryOSSL_STORE_error, OSSL_STORE_close
9*b077aed3SPierre Pronchery- Types and functions to read objects from a URI
10e71b7053SJung-uk Kim
11e71b7053SJung-uk Kim=head1 SYNOPSIS
12e71b7053SJung-uk Kim
13e71b7053SJung-uk Kim #include <openssl/store.h>
14e71b7053SJung-uk Kim
15e71b7053SJung-uk Kim typedef struct ossl_store_ctx_st OSSL_STORE_CTX;
16e71b7053SJung-uk Kim
17e71b7053SJung-uk Kim typedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *,
18e71b7053SJung-uk Kim                                                             void *);
19e71b7053SJung-uk Kim
20e71b7053SJung-uk Kim OSSL_STORE_CTX *OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method,
21e71b7053SJung-uk Kim                                 void *ui_data,
22e71b7053SJung-uk Kim                                 OSSL_STORE_post_process_info_fn post_process,
23e71b7053SJung-uk Kim                                 void *post_process_data);
24*b077aed3SPierre Pronchery OSSL_STORE_CTX *
25*b077aed3SPierre Pronchery OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, const char *propq,
26*b077aed3SPierre Pronchery                    const UI_METHOD *ui_method, void *ui_data,
27*b077aed3SPierre Pronchery                    const OSSL_PARAM params[],
28*b077aed3SPierre Pronchery                    OSSL_STORE_post_process_info_fn post_process,
29*b077aed3SPierre Pronchery                    void *post_process_data);
30*b077aed3SPierre Pronchery
31e71b7053SJung-uk Kim OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx);
32e71b7053SJung-uk Kim int OSSL_STORE_eof(OSSL_STORE_CTX *ctx);
33e71b7053SJung-uk Kim int OSSL_STORE_error(OSSL_STORE_CTX *ctx);
34e71b7053SJung-uk Kim int OSSL_STORE_close(OSSL_STORE_CTX *ctx);
35e71b7053SJung-uk Kim
36*b077aed3SPierre ProncheryThe following function has been deprecated since OpenSSL 3.0, and can be
37*b077aed3SPierre Proncheryhidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
38*b077aed3SPierre Proncherysee L<openssl_user_macros(7)>:
39*b077aed3SPierre Pronchery
40*b077aed3SPierre Pronchery int OSSL_STORE_ctrl(OSSL_STORE_CTX *ctx, int cmd, ... /* args */);
41*b077aed3SPierre Pronchery
42e71b7053SJung-uk Kim=head1 DESCRIPTION
43e71b7053SJung-uk Kim
44e71b7053SJung-uk KimThese functions help the application to fetch supported objects (see
45e71b7053SJung-uk KimL<OSSL_STORE_INFO(3)/SUPPORTED OBJECTS> for information on which those are)
46*b077aed3SPierre Proncheryfrom a given URI.
47e71b7053SJung-uk KimThe general method to do so is to "open" the URI using OSSL_STORE_open(),
48e71b7053SJung-uk Kimread each available and supported object using OSSL_STORE_load() as long as
49e71b7053SJung-uk KimOSSL_STORE_eof() hasn't been reached, and finish it off with OSSL_STORE_close().
50e71b7053SJung-uk Kim
51e71b7053SJung-uk KimThe retrieved information is stored in a B<OSSL_STORE_INFO>, which is further
52e71b7053SJung-uk Kimdescribed in L<OSSL_STORE_INFO(3)>.
53e71b7053SJung-uk Kim
54e71b7053SJung-uk Kim=head2 Types
55e71b7053SJung-uk Kim
56e71b7053SJung-uk KimB<OSSL_STORE_CTX> is a context variable that holds all the internal
57*b077aed3SPierre Proncheryinformation for OSSL_STORE_open(), OSSL_STORE_open_ex(),
58*b077aed3SPierre ProncheryOSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close() to work
59*b077aed3SPierre Proncherytogether.
60e71b7053SJung-uk Kim
61e71b7053SJung-uk Kim=head2 Functions
62e71b7053SJung-uk Kim
63*b077aed3SPierre ProncheryOSSL_STORE_open_ex() takes a uri or path I<uri>, password UI method
6458f35182SJung-uk KimI<ui_method> with associated data I<ui_data>, and post processing
6558f35182SJung-uk Kimcallback I<post_process> with associated data I<post_process_data>,
66*b077aed3SPierre Proncherya library context I<libctx> with an associated property query I<propq>,
67*b077aed3SPierre Proncheryand opens a channel to the data located at the URI and returns a
68e71b7053SJung-uk KimB<OSSL_STORE_CTX> with all necessary internal information.
6958f35182SJung-uk KimThe given I<ui_method> and I<ui_data> will be reused by all
7058f35182SJung-uk Kimfunctions that use B<OSSL_STORE_CTX> when interaction is needed,
7158f35182SJung-uk Kimfor instance to provide a password.
72*b077aed3SPierre ProncheryThe auxiliary L<OSSL_PARAM(3)> parameters in I<params> can be set to further
73*b077aed3SPierre Proncherymodify the store operation.
7458f35182SJung-uk KimThe given I<post_process> and I<post_process_data> will be reused by
75e71b7053SJung-uk KimOSSL_STORE_load() to manipulate or drop the value to be returned.
7658f35182SJung-uk KimThe I<post_process> function drops values by returning NULL, which
77e71b7053SJung-uk Kimwill cause OSSL_STORE_load() to start its process over with loading
7858f35182SJung-uk Kimthe next object, until I<post_process> returns something other than
7958f35182SJung-uk KimNULL, or the end of data is reached as indicated by OSSL_STORE_eof().
80e71b7053SJung-uk Kim
81*b077aed3SPierre ProncheryOSSL_STORE_open() is similar to OSSL_STORE_open_ex() but uses NULL for
82*b077aed3SPierre Proncherythe I<params>, the library context I<libctx> and property query I<propq>.
83*b077aed3SPierre Pronchery
8458f35182SJung-uk KimOSSL_STORE_ctrl() takes a B<OSSL_STORE_CTX>, and command number I<cmd> and
85e71b7053SJung-uk Kimmore arguments not specified here.
86e71b7053SJung-uk KimThe available loader specific command numbers and arguments they each
87e71b7053SJung-uk Kimtake depends on the loader that's used and is documented together with
88e71b7053SJung-uk Kimthat loader.
89e71b7053SJung-uk Kim
90e71b7053SJung-uk KimThere are also global controls available:
91e71b7053SJung-uk Kim
92e71b7053SJung-uk Kim=over 4
93e71b7053SJung-uk Kim
94e71b7053SJung-uk Kim=item B<OSSL_STORE_C_USE_SECMEM>
95e71b7053SJung-uk Kim
96e71b7053SJung-uk KimControls if the loader should attempt to use secure memory for any
97e71b7053SJung-uk Kimallocated B<OSSL_STORE_INFO> and its contents.
98*b077aed3SPierre ProncheryThis control expects one argument, a pointer to an I<int> that is expected to
99e71b7053SJung-uk Kimhave the value 1 (yes) or 0 (no).
100e71b7053SJung-uk KimAny other value is an error.
101e71b7053SJung-uk Kim
102e71b7053SJung-uk Kim=back
103e71b7053SJung-uk Kim
104*b077aed3SPierre ProncheryOSSL_STORE_load() takes a B<OSSL_STORE_CTX> and tries to load the next
105*b077aed3SPierre Proncheryavailable object and return it wrapped with B<OSSL_STORE_INFO>.
106e71b7053SJung-uk Kim
107e71b7053SJung-uk KimOSSL_STORE_eof() takes a B<OSSL_STORE_CTX> and checks if we've reached the end
108e71b7053SJung-uk Kimof data.
109e71b7053SJung-uk Kim
110e71b7053SJung-uk KimOSSL_STORE_error() takes a B<OSSL_STORE_CTX> and checks if an error occurred in
111e71b7053SJung-uk Kimthe last OSSL_STORE_load() call.
112e71b7053SJung-uk KimNote that it may still be meaningful to try and load more objects, unless
113e71b7053SJung-uk KimOSSL_STORE_eof() shows that the end of data has been reached.
114e71b7053SJung-uk Kim
115e71b7053SJung-uk KimOSSL_STORE_close() takes a B<OSSL_STORE_CTX>, closes the channel that was opened
116e71b7053SJung-uk Kimby OSSL_STORE_open() and frees all other information that was stored in the
117e71b7053SJung-uk KimB<OSSL_STORE_CTX>, as well as the B<OSSL_STORE_CTX> itself.
11858f35182SJung-uk KimIf I<ctx> is NULL it does nothing.
119e71b7053SJung-uk Kim
120e71b7053SJung-uk Kim=head1 NOTES
121e71b7053SJung-uk Kim
122e71b7053SJung-uk KimA string without a scheme prefix (that is, a non-URI string) is
123e71b7053SJung-uk Kimimplicitly interpreted as using the F<file:> scheme.
124e71b7053SJung-uk Kim
125e71b7053SJung-uk KimThere are some tools that can be used together with
126e71b7053SJung-uk KimOSSL_STORE_open() to determine if any failure is caused by an unparsable
127e71b7053SJung-uk KimURI, or if it's a different error (such as memory allocation
128e71b7053SJung-uk Kimfailures); if the URI was parsable but the scheme unregistered, the
129e71b7053SJung-uk Kimtop error will have the reason C<OSSL_STORE_R_UNREGISTERED_SCHEME>.
130e71b7053SJung-uk Kim
131e71b7053SJung-uk KimThese functions make no direct assumption regarding the pass phrase received
132e71b7053SJung-uk Kimfrom the password callback.
133e71b7053SJung-uk KimThe loaders may make assumptions, however.
134e71b7053SJung-uk KimFor example, the B<file:> scheme loader inherits the assumptions made by
135e71b7053SJung-uk KimOpenSSL functionality that handles the different file types; this is mostly
136e71b7053SJung-uk Kimrelevant for PKCS#12 objects.
137e71b7053SJung-uk KimSee L<passphrase-encoding(7)> for further information.
138e71b7053SJung-uk Kim
139e71b7053SJung-uk Kim=head1 RETURN VALUES
140e71b7053SJung-uk Kim
141e71b7053SJung-uk KimOSSL_STORE_open() returns a pointer to a B<OSSL_STORE_CTX> on success, or
14258f35182SJung-uk KimNULL on failure.
143e71b7053SJung-uk Kim
144*b077aed3SPierre ProncheryOSSL_STORE_load() returns a pointer to a B<OSSL_STORE_INFO> on success, or NULL
145*b077aed3SPierre Proncheryon error or when end of data is reached.
146e71b7053SJung-uk KimUse OSSL_STORE_error() and OSSL_STORE_eof() to determine the meaning of a
14758f35182SJung-uk Kimreturned NULL.
148e71b7053SJung-uk Kim
149*b077aed3SPierre ProncheryOSSL_STORE_eof() returns 1 if the end of data has been reached
150*b077aed3SPierre Proncheryor an error occurred, 0 otherwise.
151e71b7053SJung-uk Kim
152e71b7053SJung-uk KimOSSL_STORE_error() returns 1 if an error occurred in an OSSL_STORE_load() call,
153e71b7053SJung-uk Kimotherwise 0.
154e71b7053SJung-uk Kim
155e71b7053SJung-uk KimOSSL_STORE_ctrl() and OSSL_STORE_close() returns 1 on success, or 0 on failure.
156e71b7053SJung-uk Kim
157e71b7053SJung-uk Kim=head1 SEE ALSO
158e71b7053SJung-uk Kim
159e71b7053SJung-uk KimL<ossl_store(7)>, L<OSSL_STORE_INFO(3)>, L<OSSL_STORE_register_loader(3)>,
160e71b7053SJung-uk KimL<passphrase-encoding(7)>
161e71b7053SJung-uk Kim
162e71b7053SJung-uk Kim=head1 HISTORY
163e71b7053SJung-uk Kim
164*b077aed3SPierre ProncheryOSSL_STORE_open_ex() was added in OpenSSL 3.0.
165*b077aed3SPierre Pronchery
166*b077aed3SPierre ProncheryB<OSSL_STORE_CTX>, OSSL_STORE_post_process_info_fn(), OSSL_STORE_open(),
167e71b7053SJung-uk KimOSSL_STORE_ctrl(), OSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close()
1686935a639SJung-uk Kimwere added in OpenSSL 1.1.1.
169e71b7053SJung-uk Kim
17058f35182SJung-uk KimHandling of NULL I<ctx> argument for OSSL_STORE_close()
17158f35182SJung-uk Kimwas introduced in OpenSSL 1.1.1h.
17258f35182SJung-uk Kim
173*b077aed3SPierre ProncheryOSSL_STORE_open_ex() was added in OpenSSL 3.0.
174*b077aed3SPierre Pronchery
175*b077aed3SPierre ProncheryOSSL_STORE_ctrl() and OSSL_STORE_vctrl() were deprecated in OpenSSL 3.0.
176*b077aed3SPierre Pronchery
177e71b7053SJung-uk Kim=head1 COPYRIGHT
178e71b7053SJung-uk Kim
179*b077aed3SPierre ProncheryCopyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
180e71b7053SJung-uk Kim
181*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
182e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
183e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
184e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
185e71b7053SJung-uk Kim
186e71b7053SJung-uk Kim=cut
187