xref: /freebsd/crypto/openssl/doc/man7/provider-storemgmt.pod (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1b077aed3SPierre Pronchery=pod
2b077aed3SPierre Pronchery
3b077aed3SPierre Pronchery=head1 NAME
4b077aed3SPierre Pronchery
5b077aed3SPierre Proncheryprovider-storemgmt - The OSSL_STORE library E<lt>-E<gt> provider functions
6b077aed3SPierre Pronchery
7b077aed3SPierre Pronchery=head1 SYNOPSIS
8b077aed3SPierre Pronchery
9b077aed3SPierre Pronchery #include <openssl/core_dispatch.h>
10b077aed3SPierre Pronchery
11b077aed3SPierre Pronchery /*
12b077aed3SPierre Pronchery  * None of these are actual functions, but are displayed like this for
13b077aed3SPierre Pronchery  * the function signatures for functions that are offered as function
14b077aed3SPierre Pronchery  * pointers in OSSL_DISPATCH arrays.
15b077aed3SPierre Pronchery  */
16b077aed3SPierre Pronchery
17b077aed3SPierre Pronchery void *OSSL_FUNC_store_open(void *provctx, const char *uri);
18b077aed3SPierre Pronchery void *OSSL_FUNC_store_attach(void *provctx, OSSL_CORE_BIO *bio);
19b077aed3SPierre Pronchery const OSSL_PARAM *store_settable_ctx_params(void *provctx);
20b077aed3SPierre Pronchery int OSSL_FUNC_store_set_ctx_params(void *loaderctx, const OSSL_PARAM[]);
21b077aed3SPierre Pronchery int OSSL_FUNC_store_load(void *loaderctx,
22b077aed3SPierre Pronchery                          OSSL_CALLBACK *object_cb, void *object_cbarg,
23b077aed3SPierre Pronchery                          OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg);
24b077aed3SPierre Pronchery int OSSL_FUNC_store_eof(void *loaderctx);
25b077aed3SPierre Pronchery int OSSL_FUNC_store_close(void *loaderctx);
26b077aed3SPierre Pronchery
27b077aed3SPierre Pronchery int OSSL_FUNC_store_export_object
28b077aed3SPierre Pronchery     (void *loaderctx, const void *objref, size_t objref_sz,
29b077aed3SPierre Pronchery      OSSL_CALLBACK *export_cb, void *export_cbarg);
30b077aed3SPierre Pronchery
31b077aed3SPierre Pronchery=head1 DESCRIPTION
32b077aed3SPierre Pronchery
33b077aed3SPierre ProncheryThe STORE operation is the provider side of the L<ossl_store(7)> API.
34b077aed3SPierre Pronchery
35b077aed3SPierre ProncheryThe primary responsibility of the STORE operation is to load all sorts
36b077aed3SPierre Proncheryof objects from a container indicated by URI.  These objects are given
37b077aed3SPierre Proncheryto the OpenSSL library in provider-native object abstraction form (see
38b077aed3SPierre ProncheryL<provider-object(7)>).  The OpenSSL library is then responsible for
39b077aed3SPierre Proncherypassing on that abstraction to suitable provided functions.
40b077aed3SPierre Pronchery
41b077aed3SPierre ProncheryExamples of functions that the OpenSSL library can pass the abstraction to
42b077aed3SPierre Proncheryinclude OSSL_FUNC_keymgmt_load() (L<provider-keymgmt(7)>),
43b077aed3SPierre ProncheryOSSL_FUNC_store_export_object() (which exports the object in parameterized
44b077aed3SPierre Proncheryform).
45b077aed3SPierre Pronchery
46b077aed3SPierre ProncheryAll "functions" mentioned here are passed as function pointers between
47b077aed3SPierre ProncheryF<libcrypto> and the provider in L<OSSL_DISPATCH(3)> arrays via
48b077aed3SPierre ProncheryL<OSSL_ALGORITHM(3)> arrays that are returned by the provider's
49b077aed3SPierre Proncheryprovider_query_operation() function
50b077aed3SPierre Pronchery(see L<provider-base(7)/Provider Functions>).
51b077aed3SPierre Pronchery
52b077aed3SPierre ProncheryAll these "functions" have a corresponding function type definition named
53b077aed3SPierre ProncheryB<OSSL_FUNC_{name}_fn>, and a helper function to retrieve the function pointer
54b077aed3SPierre Proncheryfrom a L<OSSL_DISPATCH(3)> element named B<OSSL_get_{name}>.
55b077aed3SPierre ProncheryFor example, the "function" OSSL_FUNC_store_attach() has these:
56b077aed3SPierre Pronchery
57b077aed3SPierre Pronchery typedef void *(OSSL_FUNC_store_attach_fn)(void *provctx,
58b077aed3SPierre Pronchery                                           OSSL_CORE_BIO * bio);
59b077aed3SPierre Pronchery static ossl_inline OSSL_FUNC_store_attach_fn
60b077aed3SPierre Pronchery     OSSL_FUNC_store_attach(const OSSL_DISPATCH *opf);
61b077aed3SPierre Pronchery
62b077aed3SPierre ProncheryL<OSSL_DISPATCH(3)> arrays are indexed by numbers that are provided as macros
63b077aed3SPierre Proncheryin L<openssl-core_dispatch.h(7)>, as follows:
64b077aed3SPierre Pronchery
65b077aed3SPierre Pronchery OSSL_FUNC_store_open                 OSSL_FUNC_STORE_OPEN
66b077aed3SPierre Pronchery OSSL_FUNC_store_attach               OSSL_FUNC_STORE_ATTACH
67b077aed3SPierre Pronchery OSSL_FUNC_store_settable_ctx_params  OSSL_FUNC_STORE_SETTABLE_CTX_PARAMS
68b077aed3SPierre Pronchery OSSL_FUNC_store_set_ctx_params       OSSL_FUNC_STORE_SET_CTX_PARAMS
69b077aed3SPierre Pronchery OSSL_FUNC_store_load                 OSSL_FUNC_STORE_LOAD
70b077aed3SPierre Pronchery OSSL_FUNC_store_eof                  OSSL_FUNC_STORE_EOF
71b077aed3SPierre Pronchery OSSL_FUNC_store_close                OSSL_FUNC_STORE_CLOSE
72b077aed3SPierre Pronchery OSSL_FUNC_store_export_object        OSSL_FUNC_STORE_EXPORT_OBJECT
73b077aed3SPierre Pronchery
74b077aed3SPierre Pronchery=head2 Functions
75b077aed3SPierre Pronchery
76b077aed3SPierre ProncheryOSSL_FUNC_store_open() should create a provider side context with data based
77b077aed3SPierre Proncheryon the input I<uri>.  The implementation is entirely responsible for the
78b077aed3SPierre Proncheryinterpretation of the URI.
79b077aed3SPierre Pronchery
80b077aed3SPierre ProncheryOSSL_FUNC_store_attach() should create a provider side context with the core
81b077aed3SPierre ProncheryB<BIO> I<bio> attached.  This is an alternative to using a URI to find storage,
82b077aed3SPierre Proncherysupporting L<OSSL_STORE_attach(3)>.
83b077aed3SPierre Pronchery
84b077aed3SPierre ProncheryOSSL_FUNC_store_settable_ctx_params() should return a constant array of
85b077aed3SPierre Proncherydescriptor L<OSSL_PARAM(3)>, for parameters that OSSL_FUNC_store_set_ctx_params()
86b077aed3SPierre Proncherycan handle.
87b077aed3SPierre Pronchery
88b077aed3SPierre ProncheryOSSL_FUNC_store_set_ctx_params() should set additional parameters, such as what
89b077aed3SPierre Proncherykind of data to expect, search criteria, and so on.  More on those below, in
90b077aed3SPierre ProncheryL</Load Parameters>.  Whether unrecognised parameters are an error or simply
91b077aed3SPierre Proncheryignored is at the implementation's discretion.
92b077aed3SPierre ProncheryPassing NULL for I<params> should return true.
93b077aed3SPierre Pronchery
94b077aed3SPierre ProncheryOSSL_FUNC_store_load() loads the next object from the URI opened by
95b077aed3SPierre ProncheryOSSL_FUNC_store_open(), creates an object abstraction for it (see
96b077aed3SPierre ProncheryL<provider-object(7)>), and calls I<object_cb> with it as well as
97b077aed3SPierre ProncheryI<object_cbarg>.  I<object_cb> will then interpret the object abstraction
98b077aed3SPierre Proncheryand do what it can to wrap it or decode it into an OpenSSL structure.  In
99b077aed3SPierre Proncherycase a passphrase needs to be prompted to unlock an object, I<pw_cb> should
100b077aed3SPierre Proncherybe called.
101b077aed3SPierre Pronchery
102b077aed3SPierre ProncheryOSSL_FUNC_store_eof() indicates if the end of the set of objects from the
103b077aed3SPierre ProncheryURI has been reached.  When that happens, there's no point trying to do any
104b077aed3SPierre Proncheryfurther loading.
105b077aed3SPierre Pronchery
106b077aed3SPierre ProncheryOSSL_FUNC_store_close() frees the provider side context I<ctx>.
107b077aed3SPierre Pronchery
108b077aed3SPierre ProncheryWhen a provider-native object is created by a store manager it would be unsuitable
109b077aed3SPierre Proncheryfor direct use with a foreign provider. The export function allows for
110b077aed3SPierre Proncheryexporting the object to that foreign provider if the foreign provider
111b077aed3SPierre Proncherysupports the type of the object and provides an import function.
112b077aed3SPierre Pronchery
113b077aed3SPierre ProncheryOSSL_FUNC_store_export_object() should export the object of size I<objref_sz>
114b077aed3SPierre Proncheryreferenced by I<objref> as an L<OSSL_PARAM(3)> array and pass that to the
115b077aed3SPierre ProncheryI<export_cb> as well as the given I<export_cbarg>.
116b077aed3SPierre Pronchery
117b077aed3SPierre Pronchery=head2 Load Parameters
118b077aed3SPierre Pronchery
119b077aed3SPierre Pronchery=over 4
120b077aed3SPierre Pronchery
121b077aed3SPierre Pronchery=item "expect" (B<OSSL_STORE_PARAM_EXPECT>) <integer>
122b077aed3SPierre Pronchery
123b077aed3SPierre ProncheryIs a hint of what type of data the OpenSSL library expects to get.
124b077aed3SPierre ProncheryThis is only useful for optimization, as the library will check that the
125b077aed3SPierre Proncheryobject types match the expectation too.
126b077aed3SPierre Pronchery
127b077aed3SPierre ProncheryThe number that can be given through this parameter is found in
128b077aed3SPierre ProncheryF<< <openssl/store.h> >>, with the macros having names starting with
129b077aed3SPierre ProncheryC<OSSL_STORE_INFO_>.  These are further described in
130b077aed3SPierre ProncheryL<OSSL_STORE_INFO(3)/SUPPORTED OBJECTS>.
131b077aed3SPierre Pronchery
132b077aed3SPierre Pronchery=item "subject" (B<OSSL_STORE_PARAM_SUBJECT>) <octet string>
133b077aed3SPierre Pronchery
134b077aed3SPierre ProncheryIndicates that the caller wants to search for an object with the given
135b077aed3SPierre Proncherysubject associated.  This can be used to select specific certificates
136b077aed3SPierre Proncheryby subject.
137b077aed3SPierre Pronchery
138b077aed3SPierre ProncheryThe contents of the octet string is expected to be in DER form.
139b077aed3SPierre Pronchery
140b077aed3SPierre Pronchery=item "issuer" (B<OSSL_STORE_PARAM_ISSUER>) <octet string>
141b077aed3SPierre Pronchery
142b077aed3SPierre ProncheryIndicates that the caller wants to search for an object with the given
143b077aed3SPierre Proncheryissuer associated.  This can be used to select specific certificates
144b077aed3SPierre Proncheryby issuer.
145b077aed3SPierre Pronchery
146b077aed3SPierre ProncheryThe contents of the octet string is expected to be in DER form.
147b077aed3SPierre Pronchery
148b077aed3SPierre Pronchery=item "serial" (B<OSSL_STORE_PARAM_SERIAL>) <integer>
149b077aed3SPierre Pronchery
150b077aed3SPierre ProncheryIndicates that the caller wants to search for an object with the given
151b077aed3SPierre Proncheryserial number associated.
152b077aed3SPierre Pronchery
153b077aed3SPierre Pronchery=item "digest" (B<OSSL_STORE_PARAM_DIGEST>) <UTF8 string>
154b077aed3SPierre Pronchery
155b077aed3SPierre Pronchery=item "fingerprint" (B<OSSL_STORE_PARAM_FINGERPRINT>) <octet string>
156b077aed3SPierre Pronchery
157b077aed3SPierre ProncheryIndicates that the caller wants to search for an object with the given
158b077aed3SPierre Proncheryfingerprint, computed with the given digest.
159b077aed3SPierre Pronchery
160b077aed3SPierre Pronchery=item "alias" (B<OSSL_STORE_PARAM_ALIAS>) <UTF8 string>
161b077aed3SPierre Pronchery
162b077aed3SPierre ProncheryIndicates that the caller wants to search for an object with the given
163b077aed3SPierre Proncheryalias (some call it a "friendly name").
164b077aed3SPierre Pronchery
165*e0c4386eSCy Schubert=item "properties" (B<OSSL_STORE_PARAM_PROPERTIES>) <utf8 string>
166b077aed3SPierre Pronchery
167b077aed3SPierre ProncheryProperty string to use when querying for algorithms such as the B<OSSL_DECODER>
168b077aed3SPierre Proncherydecoder implementations.
169b077aed3SPierre Pronchery
170*e0c4386eSCy Schubert=item "input-type" (B<OSSL_STORE_PARAM_INPUT_TYPE>) <utf8 string>
171b077aed3SPierre Pronchery
172b077aed3SPierre ProncheryType of the input format as a hint to use when decoding the objects in the
173b077aed3SPierre Proncherystore.
174b077aed3SPierre Pronchery
175b077aed3SPierre Pronchery=back
176b077aed3SPierre Pronchery
177b077aed3SPierre ProncherySeveral of these search criteria may be combined.  For example, to
178b077aed3SPierre Proncherysearch for a certificate by issuer+serial, both the "issuer" and the
179b077aed3SPierre Pronchery"serial" parameters will be given.
180b077aed3SPierre Pronchery
181b077aed3SPierre Pronchery=head1 SEE ALSO
182b077aed3SPierre Pronchery
183b077aed3SPierre ProncheryL<provider(7)>
184b077aed3SPierre Pronchery
185b077aed3SPierre Pronchery=head1 HISTORY
186b077aed3SPierre Pronchery
187b077aed3SPierre ProncheryThe STORE interface was introduced in OpenSSL 3.0.
188b077aed3SPierre Pronchery
189b077aed3SPierre Pronchery=head1 COPYRIGHT
190b077aed3SPierre Pronchery
191b077aed3SPierre ProncheryCopyright 2020-2022 The OpenSSL Project Authors. All Rights Reserved.
192b077aed3SPierre Pronchery
193b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
194b077aed3SPierre Proncherythis file except in compliance with the License.  You can obtain a copy
195b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at
196b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>.
197b077aed3SPierre Pronchery
198b077aed3SPierre Pronchery=cut
199