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