1e1051a39Sopenharmony_ci=pod
2e1051a39Sopenharmony_ci
3e1051a39Sopenharmony_ci=head1 NAME
4e1051a39Sopenharmony_ci
5e1051a39Sopenharmony_ciOSSL_METHOD_STORE, ossl_method_store_new, ossl_method_store_free,
6e1051a39Sopenharmony_ciossl_method_store_init, ossl_method_store_cleanup,
7e1051a39Sopenharmony_ciossl_method_store_add, ossl_method_store_fetch,
8e1051a39Sopenharmony_ciossl_method_store_remove, ossl_method_store_remove_all_provided, 
9e1051a39Sopenharmony_ciossl_method_store_cache_get, ossl_method_store_cache_set,
10e1051a39Sopenharmony_ciossl_method_store_cache_flush_all
11e1051a39Sopenharmony_ci- implementation method store and query
12e1051a39Sopenharmony_ci
13e1051a39Sopenharmony_ci=head1 SYNOPSIS
14e1051a39Sopenharmony_ci
15e1051a39Sopenharmony_ci #include "internal/property.h"
16e1051a39Sopenharmony_ci
17e1051a39Sopenharmony_ci typedef struct ossl_method_store_st OSSL_METHOD_STORE;
18e1051a39Sopenharmony_ci
19e1051a39Sopenharmony_ci OSSL_METHOD_STORE *ossl_method_store_new(OSSL_LIB_CTX *ctx);
20e1051a39Sopenharmony_ci void ossl_method_store_free(OSSL_METHOD_STORE *store);
21e1051a39Sopenharmony_ci int ossl_method_store_init(OSSL_LIB_CTX *ctx);
22e1051a39Sopenharmony_ci void ossl_method_store_cleanup(OSSL_LIB_CTX *ctx);
23e1051a39Sopenharmony_ci int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov,
24e1051a39Sopenharmony_ci                           int nid, const char *properties, void *method,
25e1051a39Sopenharmony_ci                           int (*method_up_ref)(void *),
26e1051a39Sopenharmony_ci                           void (*method_destruct)(void *));
27e1051a39Sopenharmony_ci int ossl_method_store_remove(OSSL_METHOD_STORE *store,
28e1051a39Sopenharmony_ci                              int nid, const void *method);
29e1051a39Sopenharmony_ci int ossl_method_store_fetch(OSSL_METHOD_STORE *store,
30e1051a39Sopenharmony_ci                             int nid, const char *properties,
31e1051a39Sopenharmony_ci                             void **method, const OSSL_PROVIDER **prov_rw);
32e1051a39Sopenharmony_ci int ossl_method_store_remove_all_provided(OSSL_METHOD_STORE *store,
33e1051a39Sopenharmony_ci                                           const OSSL_PROVIDER *prov);
34e1051a39Sopenharmony_ci
35e1051a39Sopenharmony_ci int ossl_method_store_cache_get(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov,
36e1051a39Sopenharmony_ci                                 int nid, const char *prop_query, void **method);
37e1051a39Sopenharmony_ci int ossl_method_store_cache_set(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov,
38e1051a39Sopenharmony_ci                                 int nid, const char *prop_query, void *method,
39e1051a39Sopenharmony_ci                                 int (*method_up_ref)(void *),
40e1051a39Sopenharmony_ci                                 void (*method_destruct)(void *));
41e1051a39Sopenharmony_ci void ossl_method_store_cache_flush_all(OSSL_METHOD_STORE *store);
42e1051a39Sopenharmony_ci
43e1051a39Sopenharmony_ci=head1 DESCRIPTION
44e1051a39Sopenharmony_ci
45e1051a39Sopenharmony_ciOSSL_METHOD_STORE stores methods that can be queried using properties and a
46e1051a39Sopenharmony_cinumeric identity (nid).
47e1051a39Sopenharmony_ci
48e1051a39Sopenharmony_ciMethods are expected to be library internal structures.
49e1051a39Sopenharmony_ciIt's left to the caller to define the exact contents.
50e1051a39Sopenharmony_ci
51e1051a39Sopenharmony_ciNumeric identities are expected to be an algorithm identity for the methods.
52e1051a39Sopenharmony_ciIt's left to the caller to define exactly what an algorithm is, and to allocate
53e1051a39Sopenharmony_cithese numeric identities accordingly.
54e1051a39Sopenharmony_ci
55e1051a39Sopenharmony_ciThe B<OSSL_METHOD_STORE> also holds an internal query cache, which is accessed
56e1051a39Sopenharmony_ciseparately (see L</Cache Functions> below).
57e1051a39Sopenharmony_ci
58e1051a39Sopenharmony_ci=head2 Store Functions
59e1051a39Sopenharmony_ci
60e1051a39Sopenharmony_ciossl_method_store_init() initialises the method store subsystem in the scope of
61e1051a39Sopenharmony_cithe library context I<ctx>.
62e1051a39Sopenharmony_ci
63e1051a39Sopenharmony_ciossl_method_store_cleanup() cleans up and shuts down the implementation method
64e1051a39Sopenharmony_cistore subsystem in the scope of the library context I<ctx>.
65e1051a39Sopenharmony_ci
66e1051a39Sopenharmony_ciossl_method_store_new() create a new empty method store using the supplied
67e1051a39Sopenharmony_ciI<ctx> to allow access to the required underlying property data.
68e1051a39Sopenharmony_ci
69e1051a39Sopenharmony_ciossl_method_store_free() frees resources allocated to I<store>.
70e1051a39Sopenharmony_ci
71e1051a39Sopenharmony_ciossl_method_store_add() adds the I<method> constructed from an implementation in
72e1051a39Sopenharmony_cithe provider I<prov> to the I<store> as an instance of an algorithm indicated by
73e1051a39Sopenharmony_ciI<nid> and the property definition I<properties>, unless the I<store> already
74e1051a39Sopenharmony_cihas a method from the same provider with the same I<nid> and I<properties>.
75e1051a39Sopenharmony_ciIf the I<method_up_ref> function is given, it's called to increment the
76e1051a39Sopenharmony_cireference count of the method.
77e1051a39Sopenharmony_ciIf the I<method_destruct> function is given, it's called when this function
78e1051a39Sopenharmony_cifails to add the method to the store, or later on when it is being released from
79e1051a39Sopenharmony_cithe I<store>.
80e1051a39Sopenharmony_ci
81e1051a39Sopenharmony_ciossl_method_store_remove() removes the I<method> identified by I<nid> from the
82e1051a39Sopenharmony_ciI<store>.
83e1051a39Sopenharmony_ci
84e1051a39Sopenharmony_ciossl_method_store_fetch() queries I<store> for a method identified by I<nid>
85e1051a39Sopenharmony_cithat matches the property query I<prop_query>.
86e1051a39Sopenharmony_ciI<*prop> may be a pointer to a provider, which will narrow the search
87e1051a39Sopenharmony_cito methods from that provider.
88e1051a39Sopenharmony_ciThe result, if any, is returned in I<*method>, and its provider in I<*prov>.
89e1051a39Sopenharmony_ci
90e1051a39Sopenharmony_ciossl_method_store_remove_all_provided() removes all methods from I<store>
91e1051a39Sopenharmony_cithat are provided by I<prov>.
92e1051a39Sopenharmony_ciWhen doing so, it also flushes the corresponding cache entries.
93e1051a39Sopenharmony_ci
94e1051a39Sopenharmony_ci=head2 Cache Functions
95e1051a39Sopenharmony_ci
96e1051a39Sopenharmony_ciossl_method_store_cache_get() queries the cache associated with the I<store>
97e1051a39Sopenharmony_cifor a method identified by I<nid> that matches the property query
98e1051a39Sopenharmony_ciI<prop_query>.
99e1051a39Sopenharmony_ciAdditionally, if I<prov> isn't NULL, it will be used to narrow the search
100e1051a39Sopenharmony_cito only include methods from that provider.
101e1051a39Sopenharmony_ciThe result, if any, is returned in I<method>.
102e1051a39Sopenharmony_ci
103e1051a39Sopenharmony_ciossl_method_store_cache_set() sets a cache entry identified by I<nid> from the
104e1051a39Sopenharmony_ciprovider I<prov>, with the property query I<prop_query> in the I<store>.
105e1051a39Sopenharmony_ciFuture calls to ossl_method_store_cache_get() will return the specified I<method>.
106e1051a39Sopenharmony_ciThe I<method_up_ref> function is called to increment the
107e1051a39Sopenharmony_cireference count of the method and the I<method_destruct> function is called
108e1051a39Sopenharmony_cito decrement it.
109e1051a39Sopenharmony_ci
110e1051a39Sopenharmony_ciossl_method_store_cache_flush_all() flushes all cached entries associated with
111e1051a39Sopenharmony_ciI<store>.
112e1051a39Sopenharmony_ci
113e1051a39Sopenharmony_ci=head1 NOTES
114e1051a39Sopenharmony_ci
115e1051a39Sopenharmony_ciThe I<prop_query> argument to ossl_method_store_cache_get() and
116e1051a39Sopenharmony_ciossl_method_store_cache_set() is not allowed to be NULL.  Use "" for an
117e1051a39Sopenharmony_ciempty property definition or query.
118e1051a39Sopenharmony_ci
119e1051a39Sopenharmony_ci=head1 RETURN VALUES
120e1051a39Sopenharmony_ci
121e1051a39Sopenharmony_ciossl_method_store_new() returns a new method store object or NULL on failure.
122e1051a39Sopenharmony_ci
123e1051a39Sopenharmony_ciossl_method_store_free(), ossl_method_store_add(),
124e1051a39Sopenharmony_ciossl_method_store_remove(), ossl_method_store_fetch(),
125e1051a39Sopenharmony_ciossl_method_store_cache_get(), ossl_method_store_cache_set() and
126e1051a39Sopenharmony_ciossl_method_store_flush_cache() return B<1> on success and B<0> on error.
127e1051a39Sopenharmony_ci
128e1051a39Sopenharmony_ciossl_method_store_free() and ossl_method_store_cleanup() do not return any value.
129e1051a39Sopenharmony_ci
130e1051a39Sopenharmony_ci=head1 HISTORY
131e1051a39Sopenharmony_ci
132e1051a39Sopenharmony_ciThis functionality was added to OpenSSL 3.0.
133e1051a39Sopenharmony_ci
134e1051a39Sopenharmony_ci=head1 COPYRIGHT
135e1051a39Sopenharmony_ci
136e1051a39Sopenharmony_ciCopyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
137e1051a39Sopenharmony_ciCopyright (c) 2019, Oracle and/or its affiliates.  All rights reserved.
138e1051a39Sopenharmony_ci
139e1051a39Sopenharmony_ciLicensed under the Apache License 2.0 (the "License").  You may not use this
140e1051a39Sopenharmony_cifile except in compliance with the License.  You can obtain a copy in the file
141e1051a39Sopenharmony_ciLICENSE in the source distribution or at
142e1051a39Sopenharmony_ciL<https://www.openssl.org/source/license.html>.
143e1051a39Sopenharmony_ci
144e1051a39Sopenharmony_ci=cut
145