Home | History | Annotate | Line # | Download | only in man3
      1      1.1  christos =pod
      2      1.1  christos 
      3      1.1  christos =head1 NAME
      4      1.1  christos 
      5  1.1.1.4  christos OSSL_STORE_CTX, OSSL_STORE_post_process_info_fn,
      6  1.1.1.4  christos OSSL_STORE_open, OSSL_STORE_open_ex,
      7  1.1.1.4  christos OSSL_STORE_ctrl, OSSL_STORE_load, OSSL_STORE_eof,
      8  1.1.1.4  christos OSSL_STORE_error, OSSL_STORE_close
      9  1.1.1.4  christos - Types and functions to read objects from a URI
     10      1.1  christos 
     11      1.1  christos =head1 SYNOPSIS
     12      1.1  christos 
     13      1.1  christos  #include <openssl/store.h>
     14      1.1  christos 
     15      1.1  christos  typedef struct ossl_store_ctx_st OSSL_STORE_CTX;
     16      1.1  christos 
     17      1.1  christos  typedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *,
     18      1.1  christos                                                              void *);
     19      1.1  christos 
     20      1.1  christos  OSSL_STORE_CTX *OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method,
     21      1.1  christos                                  void *ui_data,
     22      1.1  christos                                  OSSL_STORE_post_process_info_fn post_process,
     23      1.1  christos                                  void *post_process_data);
     24  1.1.1.4  christos  OSSL_STORE_CTX *
     25  1.1.1.4  christos  OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, const char *propq,
     26  1.1.1.4  christos                     const UI_METHOD *ui_method, void *ui_data,
     27  1.1.1.4  christos                     const OSSL_PARAM params[],
     28  1.1.1.4  christos                     OSSL_STORE_post_process_info_fn post_process,
     29  1.1.1.4  christos                     void *post_process_data);
     30  1.1.1.4  christos 
     31      1.1  christos  OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx);
     32      1.1  christos  int OSSL_STORE_eof(OSSL_STORE_CTX *ctx);
     33      1.1  christos  int OSSL_STORE_error(OSSL_STORE_CTX *ctx);
     34      1.1  christos  int OSSL_STORE_close(OSSL_STORE_CTX *ctx);
     35      1.1  christos 
     36  1.1.1.4  christos The following function has been deprecated since OpenSSL 3.0, and can be
     37  1.1.1.4  christos hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
     38  1.1.1.4  christos see L<openssl_user_macros(7)>:
     39  1.1.1.4  christos 
     40  1.1.1.4  christos  int OSSL_STORE_ctrl(OSSL_STORE_CTX *ctx, int cmd, ... /* args */);
     41  1.1.1.4  christos 
     42      1.1  christos =head1 DESCRIPTION
     43      1.1  christos 
     44      1.1  christos These functions help the application to fetch supported objects (see
     45      1.1  christos L<OSSL_STORE_INFO(3)/SUPPORTED OBJECTS> for information on which those are)
     46  1.1.1.4  christos from a given URI.
     47      1.1  christos The general method to do so is to "open" the URI using OSSL_STORE_open(),
     48      1.1  christos read each available and supported object using OSSL_STORE_load() as long as
     49      1.1  christos OSSL_STORE_eof() hasn't been reached, and finish it off with OSSL_STORE_close().
     50      1.1  christos 
     51      1.1  christos The retrieved information is stored in a B<OSSL_STORE_INFO>, which is further
     52      1.1  christos described in L<OSSL_STORE_INFO(3)>.
     53      1.1  christos 
     54      1.1  christos =head2 Types
     55      1.1  christos 
     56      1.1  christos B<OSSL_STORE_CTX> is a context variable that holds all the internal
     57  1.1.1.4  christos information for OSSL_STORE_open(), OSSL_STORE_open_ex(),
     58  1.1.1.4  christos OSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close() to work
     59  1.1.1.4  christos together.
     60      1.1  christos 
     61      1.1  christos =head2 Functions
     62      1.1  christos 
     63  1.1.1.4  christos OSSL_STORE_open_ex() takes a uri or path I<uri>, password UI method
     64  1.1.1.3  christos I<ui_method> with associated data I<ui_data>, and post processing
     65  1.1.1.3  christos callback I<post_process> with associated data I<post_process_data>,
     66  1.1.1.4  christos a library context I<libctx> with an associated property query I<propq>,
     67  1.1.1.4  christos and opens a channel to the data located at the URI and returns a
     68      1.1  christos B<OSSL_STORE_CTX> with all necessary internal information.
     69  1.1.1.3  christos The given I<ui_method> and I<ui_data> will be reused by all
     70  1.1.1.3  christos functions that use B<OSSL_STORE_CTX> when interaction is needed,
     71  1.1.1.3  christos for instance to provide a password.
     72  1.1.1.4  christos The auxiliary L<OSSL_PARAM(3)> parameters in I<params> can be set to further
     73  1.1.1.4  christos modify the store operation.
     74  1.1.1.3  christos The given I<post_process> and I<post_process_data> will be reused by
     75      1.1  christos OSSL_STORE_load() to manipulate or drop the value to be returned.
     76  1.1.1.3  christos The I<post_process> function drops values by returning NULL, which
     77      1.1  christos will cause OSSL_STORE_load() to start its process over with loading
     78  1.1.1.3  christos the next object, until I<post_process> returns something other than
     79  1.1.1.3  christos NULL, or the end of data is reached as indicated by OSSL_STORE_eof().
     80      1.1  christos 
     81  1.1.1.4  christos OSSL_STORE_open() is similar to OSSL_STORE_open_ex() but uses NULL for
     82  1.1.1.4  christos the I<params>, the library context I<libctx> and property query I<propq>.
     83  1.1.1.4  christos 
     84  1.1.1.3  christos OSSL_STORE_ctrl() takes a B<OSSL_STORE_CTX>, and command number I<cmd> and
     85      1.1  christos more arguments not specified here.
     86      1.1  christos The available loader specific command numbers and arguments they each
     87      1.1  christos take depends on the loader that's used and is documented together with
     88      1.1  christos that loader.
     89      1.1  christos 
     90      1.1  christos There are also global controls available:
     91      1.1  christos 
     92      1.1  christos =over 4
     93      1.1  christos 
     94      1.1  christos =item B<OSSL_STORE_C_USE_SECMEM>
     95      1.1  christos 
     96      1.1  christos Controls if the loader should attempt to use secure memory for any
     97      1.1  christos allocated B<OSSL_STORE_INFO> and its contents.
     98  1.1.1.4  christos This control expects one argument, a pointer to an I<int> that is expected to
     99      1.1  christos have the value 1 (yes) or 0 (no).
    100      1.1  christos Any other value is an error.
    101      1.1  christos 
    102      1.1  christos =back
    103      1.1  christos 
    104  1.1.1.4  christos OSSL_STORE_load() takes a B<OSSL_STORE_CTX> and tries to load the next
    105  1.1.1.4  christos available object and return it wrapped with B<OSSL_STORE_INFO>.
    106      1.1  christos 
    107      1.1  christos OSSL_STORE_eof() takes a B<OSSL_STORE_CTX> and checks if we've reached the end
    108      1.1  christos of data.
    109      1.1  christos 
    110      1.1  christos OSSL_STORE_error() takes a B<OSSL_STORE_CTX> and checks if an error occurred in
    111      1.1  christos the last OSSL_STORE_load() call.
    112      1.1  christos Note that it may still be meaningful to try and load more objects, unless
    113      1.1  christos OSSL_STORE_eof() shows that the end of data has been reached.
    114      1.1  christos 
    115      1.1  christos OSSL_STORE_close() takes a B<OSSL_STORE_CTX>, closes the channel that was opened
    116      1.1  christos by OSSL_STORE_open() and frees all other information that was stored in the
    117      1.1  christos B<OSSL_STORE_CTX>, as well as the B<OSSL_STORE_CTX> itself.
    118  1.1.1.3  christos If I<ctx> is NULL it does nothing.
    119      1.1  christos 
    120      1.1  christos =head1 NOTES
    121      1.1  christos 
    122      1.1  christos A string without a scheme prefix (that is, a non-URI string) is
    123      1.1  christos implicitly interpreted as using the F<file:> scheme.
    124      1.1  christos 
    125      1.1  christos There are some tools that can be used together with
    126      1.1  christos OSSL_STORE_open() to determine if any failure is caused by an unparsable
    127      1.1  christos URI, or if it's a different error (such as memory allocation
    128      1.1  christos failures); if the URI was parsable but the scheme unregistered, the
    129      1.1  christos top error will have the reason C<OSSL_STORE_R_UNREGISTERED_SCHEME>.
    130      1.1  christos 
    131      1.1  christos These functions make no direct assumption regarding the pass phrase received
    132      1.1  christos from the password callback.
    133      1.1  christos The loaders may make assumptions, however.
    134      1.1  christos For example, the B<file:> scheme loader inherits the assumptions made by
    135      1.1  christos OpenSSL functionality that handles the different file types; this is mostly
    136      1.1  christos relevant for PKCS#12 objects.
    137      1.1  christos See L<passphrase-encoding(7)> for further information.
    138      1.1  christos 
    139      1.1  christos =head1 RETURN VALUES
    140      1.1  christos 
    141      1.1  christos OSSL_STORE_open() returns a pointer to a B<OSSL_STORE_CTX> on success, or
    142  1.1.1.3  christos NULL on failure.
    143      1.1  christos 
    144  1.1.1.4  christos OSSL_STORE_load() returns a pointer to a B<OSSL_STORE_INFO> on success, or NULL
    145  1.1.1.4  christos on error or when end of data is reached.
    146      1.1  christos Use OSSL_STORE_error() and OSSL_STORE_eof() to determine the meaning of a
    147  1.1.1.3  christos returned NULL.
    148      1.1  christos 
    149  1.1.1.4  christos OSSL_STORE_eof() returns 1 if the end of data has been reached
    150  1.1.1.4  christos or an error occurred, 0 otherwise.
    151      1.1  christos 
    152      1.1  christos OSSL_STORE_error() returns 1 if an error occurred in an OSSL_STORE_load() call,
    153      1.1  christos otherwise 0.
    154      1.1  christos 
    155      1.1  christos OSSL_STORE_ctrl() and OSSL_STORE_close() returns 1 on success, or 0 on failure.
    156      1.1  christos 
    157      1.1  christos =head1 SEE ALSO
    158      1.1  christos 
    159      1.1  christos L<ossl_store(7)>, L<OSSL_STORE_INFO(3)>, L<OSSL_STORE_register_loader(3)>,
    160      1.1  christos L<passphrase-encoding(7)>
    161      1.1  christos 
    162      1.1  christos =head1 HISTORY
    163      1.1  christos 
    164  1.1.1.4  christos OSSL_STORE_open_ex() was added in OpenSSL 3.0.
    165  1.1.1.4  christos 
    166  1.1.1.4  christos B<OSSL_STORE_CTX>, OSSL_STORE_post_process_info_fn(), OSSL_STORE_open(),
    167      1.1  christos OSSL_STORE_ctrl(), OSSL_STORE_load(), OSSL_STORE_eof() and OSSL_STORE_close()
    168  1.1.1.2  christos were added in OpenSSL 1.1.1.
    169      1.1  christos 
    170  1.1.1.3  christos Handling of NULL I<ctx> argument for OSSL_STORE_close()
    171  1.1.1.3  christos was introduced in OpenSSL 1.1.1h.
    172  1.1.1.3  christos 
    173  1.1.1.4  christos OSSL_STORE_open_ex() was added in OpenSSL 3.0.
    174  1.1.1.4  christos 
    175  1.1.1.4  christos OSSL_STORE_ctrl() and OSSL_STORE_vctrl() were deprecated in OpenSSL 3.0.
    176  1.1.1.4  christos 
    177      1.1  christos =head1 COPYRIGHT
    178      1.1  christos 
    179  1.1.1.4  christos Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
    180      1.1  christos 
    181  1.1.1.4  christos Licensed under the Apache License 2.0 (the "License").  You may not use
    182      1.1  christos this file except in compliance with the License.  You can obtain a copy
    183      1.1  christos in the file LICENSE in the source distribution or at
    184      1.1  christos L<https://www.openssl.org/source/license.html>.
    185      1.1  christos 
    186      1.1  christos =cut
    187