xref: /freebsd/crypto/openssl/doc/man7/provider-keymgmt.pod (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1b077aed3SPierre Pronchery=pod
2b077aed3SPierre Pronchery
3b077aed3SPierre Pronchery=head1 NAME
4b077aed3SPierre Pronchery
5b077aed3SPierre Proncheryprovider-keymgmt - The KEYMGMT 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 /* Key object (keydata) creation and destruction */
18b077aed3SPierre Pronchery void *OSSL_FUNC_keymgmt_new(void *provctx);
19b077aed3SPierre Pronchery void OSSL_FUNC_keymgmt_free(void *keydata);
20b077aed3SPierre Pronchery
21b077aed3SPierre Pronchery /* Generation, a more complex constructor */
22b077aed3SPierre Pronchery void *OSSL_FUNC_keymgmt_gen_init(void *provctx, int selection,
23b077aed3SPierre Pronchery                                  const OSSL_PARAM params[]);
24b077aed3SPierre Pronchery int OSSL_FUNC_keymgmt_gen_set_template(void *genctx, void *template);
25b077aed3SPierre Pronchery int OSSL_FUNC_keymgmt_gen_set_params(void *genctx, const OSSL_PARAM params[]);
26b077aed3SPierre Pronchery const OSSL_PARAM *OSSL_FUNC_keymgmt_gen_settable_params(void *genctx,
27b077aed3SPierre Pronchery                                                         void *provctx);
28b077aed3SPierre Pronchery void *OSSL_FUNC_keymgmt_gen(void *genctx, OSSL_CALLBACK *cb, void *cbarg);
29b077aed3SPierre Pronchery void OSSL_FUNC_keymgmt_gen_cleanup(void *genctx);
30b077aed3SPierre Pronchery
31b077aed3SPierre Pronchery /* Key loading by object reference, also a constructor */
32b077aed3SPierre Pronchery void *OSSL_FUNC_keymgmt_load(const void *reference, size_t *reference_sz);
33b077aed3SPierre Pronchery
34b077aed3SPierre Pronchery /* Key object information */
35b077aed3SPierre Pronchery int OSSL_FUNC_keymgmt_get_params(void *keydata, OSSL_PARAM params[]);
36b077aed3SPierre Pronchery const OSSL_PARAM *OSSL_FUNC_keymgmt_gettable_params(void *provctx);
37b077aed3SPierre Pronchery int OSSL_FUNC_keymgmt_set_params(void *keydata, const OSSL_PARAM params[]);
38b077aed3SPierre Pronchery const OSSL_PARAM *OSSL_FUNC_keymgmt_settable_params(void *provctx);
39b077aed3SPierre Pronchery
40b077aed3SPierre Pronchery /* Key object content checks */
41b077aed3SPierre Pronchery int OSSL_FUNC_keymgmt_has(const void *keydata, int selection);
42b077aed3SPierre Pronchery int OSSL_FUNC_keymgmt_match(const void *keydata1, const void *keydata2,
43b077aed3SPierre Pronchery                             int selection);
44b077aed3SPierre Pronchery
45b077aed3SPierre Pronchery /* Discovery of supported operations */
46b077aed3SPierre Pronchery const char *OSSL_FUNC_keymgmt_query_operation_name(int operation_id);
47b077aed3SPierre Pronchery
48b077aed3SPierre Pronchery /* Key object import and export functions */
49b077aed3SPierre Pronchery int OSSL_FUNC_keymgmt_import(void *keydata, int selection, const OSSL_PARAM params[]);
50b077aed3SPierre Pronchery const OSSL_PARAM *OSSL_FUNC_keymgmt_import_types(int selection);
51b077aed3SPierre Pronchery int OSSL_FUNC_keymgmt_export(void *keydata, int selection,
52b077aed3SPierre Pronchery                              OSSL_CALLBACK *param_cb, void *cbarg);
53b077aed3SPierre Pronchery const OSSL_PARAM *OSSL_FUNC_keymgmt_export_types(int selection);
54b077aed3SPierre Pronchery
55b077aed3SPierre Pronchery /* Key object duplication, a constructor */
56b077aed3SPierre Pronchery void *OSSL_FUNC_keymgmt_dup(const void *keydata_from, int selection);
57b077aed3SPierre Pronchery
58b077aed3SPierre Pronchery /* Key object validation */
59b077aed3SPierre Pronchery int OSSL_FUNC_keymgmt_validate(const void *keydata, int selection, int checktype);
60b077aed3SPierre Pronchery
61b077aed3SPierre Pronchery=head1 DESCRIPTION
62b077aed3SPierre Pronchery
63b077aed3SPierre ProncheryThe KEYMGMT operation doesn't have much public visibility in OpenSSL
64b077aed3SPierre Proncherylibraries, it's rather an internal operation that's designed to work
65b077aed3SPierre Proncheryin tandem with operations that use private/public key pairs.
66b077aed3SPierre Pronchery
67b077aed3SPierre ProncheryBecause the KEYMGMT operation shares knowledge with the operations it
68b077aed3SPierre Proncheryworks with in tandem, they must belong to the same provider.
69b077aed3SPierre ProncheryThe OpenSSL libraries will ensure that they do.
70b077aed3SPierre Pronchery
71b077aed3SPierre ProncheryThe primary responsibility of the KEYMGMT operation is to hold the
72b077aed3SPierre Proncheryprovider side key data for the OpenSSL library EVP_PKEY structure.
73b077aed3SPierre Pronchery
74b077aed3SPierre ProncheryAll "functions" mentioned here are passed as function pointers between
75b077aed3SPierre ProncheryF<libcrypto> and the provider in L<OSSL_DISPATCH(3)> arrays via
76b077aed3SPierre ProncheryL<OSSL_ALGORITHM(3)> arrays that are returned by the provider's
77b077aed3SPierre Proncheryprovider_query_operation() function
78b077aed3SPierre Pronchery(see L<provider-base(7)/Provider Functions>).
79b077aed3SPierre Pronchery
80b077aed3SPierre ProncheryAll these "functions" have a corresponding function type definition
81b077aed3SPierre Proncherynamed B<OSSL_FUNC_{name}_fn>, and a helper function to retrieve the
82b077aed3SPierre Proncheryfunction pointer from a L<OSSL_DISPATCH(3)> element named
83b077aed3SPierre ProncheryB<OSSL_FUNC_{name}>.
84b077aed3SPierre ProncheryFor example, the "function" OSSL_FUNC_keymgmt_new() has these:
85b077aed3SPierre Pronchery
86b077aed3SPierre Pronchery typedef void *(OSSL_FUNC_keymgmt_new_fn)(void *provctx);
87b077aed3SPierre Pronchery static ossl_inline OSSL_FUNC_keymgmt_new_fn
88b077aed3SPierre Pronchery     OSSL_FUNC_keymgmt_new(const OSSL_DISPATCH *opf);
89b077aed3SPierre Pronchery
90b077aed3SPierre ProncheryL<OSSL_DISPATCH(3)> arrays are indexed by numbers that are provided as
91b077aed3SPierre Proncherymacros in L<openssl-core_dispatch.h(7)>, as follows:
92b077aed3SPierre Pronchery
93b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_new                  OSSL_FUNC_KEYMGMT_NEW
94b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_free                 OSSL_FUNC_KEYMGMT_FREE
95b077aed3SPierre Pronchery
96b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_gen_init             OSSL_FUNC_KEYMGMT_GEN_INIT
97b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_gen_set_template     OSSL_FUNC_KEYMGMT_GEN_SET_TEMPLATE
98b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_gen_set_params       OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS
99b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_gen_settable_params  OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS
100b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_gen                  OSSL_FUNC_KEYMGMT_GEN
101b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_gen_cleanup          OSSL_FUNC_KEYMGMT_GEN_CLEANUP
102b077aed3SPierre Pronchery
103b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_load                 OSSL_FUNC_KEYMGMT_LOAD
104b077aed3SPierre Pronchery
105b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_get_params           OSSL_FUNC_KEYMGMT_GET_PARAMS
106b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_gettable_params      OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS
107b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_set_params           OSSL_FUNC_KEYMGMT_SET_PARAMS
108b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_settable_params      OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS
109b077aed3SPierre Pronchery
110b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_query_operation_name OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME
111b077aed3SPierre Pronchery
112b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_has                  OSSL_FUNC_KEYMGMT_HAS
113b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_validate             OSSL_FUNC_KEYMGMT_VALIDATE
114b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_match                OSSL_FUNC_KEYMGMT_MATCH
115b077aed3SPierre Pronchery
116b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_import               OSSL_FUNC_KEYMGMT_IMPORT
117b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_import_types         OSSL_FUNC_KEYMGMT_IMPORT_TYPES
118b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_export               OSSL_FUNC_KEYMGMT_EXPORT
119b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_export_types         OSSL_FUNC_KEYMGMT_EXPORT_TYPES
120b077aed3SPierre Pronchery
121b077aed3SPierre Pronchery OSSL_FUNC_keymgmt_dup                  OSSL_FUNC_KEYMGMT_DUP
122b077aed3SPierre Pronchery
123b077aed3SPierre Pronchery=head2 Key Objects
124b077aed3SPierre Pronchery
125b077aed3SPierre ProncheryA key object is a collection of data for an asymmetric key, and is
126b077aed3SPierre Proncheryrepresented as I<keydata> in this manual.
127b077aed3SPierre Pronchery
128b077aed3SPierre ProncheryThe exact contents of a key object are defined by the provider, and it
129b077aed3SPierre Proncheryis assumed that different operations in one and the same provider use
130b077aed3SPierre Proncherythe exact same structure to represent this collection of data, so that
131b077aed3SPierre Proncheryfor example, a key object that has been created using the KEYMGMT
132b077aed3SPierre Proncheryinterface that we document here can be passed as is to other provider
133b077aed3SPierre Proncheryoperations, such as OP_signature_sign_init() (see
134b077aed3SPierre ProncheryL<provider-signature(7)>).
135b077aed3SPierre Pronchery
136b077aed3SPierre ProncheryWith some of the KEYMGMT functions, it's possible to select a specific
137b077aed3SPierre Proncherysubset of data to handle, governed by the bits in a I<selection>
138b077aed3SPierre Proncheryindicator.  The bits are:
139b077aed3SPierre Pronchery
140b077aed3SPierre Pronchery=over 4
141b077aed3SPierre Pronchery
142b077aed3SPierre Pronchery=item B<OSSL_KEYMGMT_SELECT_PRIVATE_KEY>
143b077aed3SPierre Pronchery
144b077aed3SPierre ProncheryIndicating that the private key data in a key object should be
145b077aed3SPierre Proncheryconsidered.
146b077aed3SPierre Pronchery
147b077aed3SPierre Pronchery=item B<OSSL_KEYMGMT_SELECT_PUBLIC_KEY>
148b077aed3SPierre Pronchery
149b077aed3SPierre ProncheryIndicating that the public key data in a key object should be
150b077aed3SPierre Proncheryconsidered.
151b077aed3SPierre Pronchery
152b077aed3SPierre Pronchery=item B<OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS>
153b077aed3SPierre Pronchery
154b077aed3SPierre ProncheryIndicating that the domain parameters in a key object should be
155b077aed3SPierre Proncheryconsidered.
156b077aed3SPierre Pronchery
157b077aed3SPierre Pronchery=item B<OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS>
158b077aed3SPierre Pronchery
159b077aed3SPierre ProncheryIndicating that other parameters in a key object should be
160b077aed3SPierre Proncheryconsidered.
161b077aed3SPierre Pronchery
162b077aed3SPierre ProncheryOther parameters are key parameters that don't fit any other
163b077aed3SPierre Proncheryclassification.  In other words, this particular selector bit works as
164b077aed3SPierre Proncherya last resort bit bucket selector.
165b077aed3SPierre Pronchery
166b077aed3SPierre Pronchery=back
167b077aed3SPierre Pronchery
168b077aed3SPierre ProncherySome selector bits have also been combined for easier use:
169b077aed3SPierre Pronchery
170b077aed3SPierre Pronchery=over 4
171b077aed3SPierre Pronchery
172b077aed3SPierre Pronchery=item B<OSSL_KEYMGMT_SELECT_ALL_PARAMETERS>
173b077aed3SPierre Pronchery
174b077aed3SPierre ProncheryIndicating that all key object parameters should be considered,
175b077aed3SPierre Proncheryregardless of their more granular classification.
176b077aed3SPierre Pronchery
177b077aed3SPierre Pronchery=for comment This should used by EVP functions such as
178b077aed3SPierre ProncheryEVP_PKEY_copy_parameters() and EVP_PKEY_parameters_eq()
179b077aed3SPierre Pronchery
180b077aed3SPierre ProncheryThis is a combination of B<OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS> and
181b077aed3SPierre ProncheryB<OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS>.
182b077aed3SPierre Pronchery
183b077aed3SPierre Pronchery=for comment If more parameter categories are added, they should be
184b077aed3SPierre Proncherymentioned here too.
185b077aed3SPierre Pronchery
186b077aed3SPierre Pronchery=item B<OSSL_KEYMGMT_SELECT_KEYPAIR>
187b077aed3SPierre Pronchery
188b077aed3SPierre ProncheryIndicating that both the whole key pair in a key object should be
189b077aed3SPierre Proncheryconsidered, i.e. the combination of public and private key.
190b077aed3SPierre Pronchery
191b077aed3SPierre ProncheryThis is a combination of B<OSSL_KEYMGMT_SELECT_PRIVATE_KEY> and
192b077aed3SPierre ProncheryB<OSSL_KEYMGMT_SELECT_PUBLIC_KEY>.
193b077aed3SPierre Pronchery
194b077aed3SPierre Pronchery=item B<OSSL_KEYMGMT_SELECT_ALL>
195b077aed3SPierre Pronchery
196b077aed3SPierre ProncheryIndicating that everything in a key object should be considered.
197b077aed3SPierre Pronchery
198b077aed3SPierre Pronchery=back
199b077aed3SPierre Pronchery
200b077aed3SPierre ProncheryThe exact interpretation of those bits or how they combine is left to
201b077aed3SPierre Proncheryeach function where you can specify a selector.
202b077aed3SPierre Pronchery
203b077aed3SPierre ProncheryIt's left to the provider implementation to decide what is reasonable
204b077aed3SPierre Proncheryto do with regards to received selector bits and how to do it.
205b077aed3SPierre ProncheryAmong others, an implementation of OSSL_FUNC_keymgmt_match() might opt
206b077aed3SPierre Proncheryto not compare the private half if it has compared the public half,
207b077aed3SPierre Proncherysince a match of one half implies a match of the other half.
208b077aed3SPierre Pronchery
209b077aed3SPierre Pronchery=head2 Constructing and Destructing Functions
210b077aed3SPierre Pronchery
211b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_new() should create a provider side key object.  The
212b077aed3SPierre Proncheryprovider context I<provctx> is passed and may be incorporated in the
213b077aed3SPierre Proncherykey object, but that is not mandatory.
214b077aed3SPierre Pronchery
215b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_free() should free the passed I<keydata>.
216b077aed3SPierre Pronchery
217b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gen_init(), OSSL_FUNC_keymgmt_gen_set_template(),
218b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gen_set_params(), OSSL_FUNC_keymgmt_gen_settable_params(),
219b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gen() and OSSL_FUNC_keymgmt_gen_cleanup() work together as a
220b077aed3SPierre Proncherymore elaborate context based key object constructor.
221b077aed3SPierre Pronchery
222b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gen_init() should create the key object generation context
223b077aed3SPierre Proncheryand initialize it with I<selections>, which will determine what kind
224b077aed3SPierre Proncheryof contents the key object to be generated should get.
225b077aed3SPierre ProncheryThe I<params>, if not NULL, should be set on the context in a manner similar to
226b077aed3SPierre Proncheryusing OSSL_FUNC_keymgmt_set_params().
227b077aed3SPierre Pronchery
228b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gen_set_template() should add I<template> to the context
229b077aed3SPierre ProncheryI<genctx>.  The I<template> is assumed to be a key object constructed
230b077aed3SPierre Proncherywith the same KEYMGMT, and from which content that the implementation
231b077aed3SPierre Proncherychooses can be used as a template for the key object to be generated.
232b077aed3SPierre ProncheryTypically, the generation of a DSA or DH key would get the domain
233b077aed3SPierre Proncheryparameters from this I<template>.
234b077aed3SPierre Pronchery
235b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gen_set_params() should set additional parameters from
236b077aed3SPierre ProncheryI<params> in the key object generation context I<genctx>.
237b077aed3SPierre Pronchery
238b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gen_settable_params() should return a constant array of
239b077aed3SPierre Proncherydescriptor L<OSSL_PARAM(3)>, for parameters that OSSL_FUNC_keymgmt_gen_set_params()
240b077aed3SPierre Proncherycan handle.
241b077aed3SPierre Pronchery
242b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gen() should perform the key object generation itself, and
243b077aed3SPierre Proncheryreturn the result.  The callback I<cb> should be called at regular
244b077aed3SPierre Proncheryintervals with indications on how the key object generation
245b077aed3SPierre Proncheryprogresses.
246b077aed3SPierre Pronchery
247b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gen_cleanup() should clean up and free the key object
248b077aed3SPierre Proncherygeneration context I<genctx>
249b077aed3SPierre Pronchery
250b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_load() creates a provider side key object based on a
251b077aed3SPierre ProncheryI<reference> object with a size of I<reference_sz> bytes, that only the
252b077aed3SPierre Proncheryprovider knows how to interpret, but that may come from other operations.
253b077aed3SPierre ProncheryOutside the provider, this reference is simply an array of bytes.
254b077aed3SPierre Pronchery
255b077aed3SPierre ProncheryAt least one of OSSL_FUNC_keymgmt_new(), OSSL_FUNC_keymgmt_gen() and
256b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_load() are mandatory, as well as OSSL_FUNC_keymgmt_free() and
257b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_has(). Additionally, if OSSL_FUNC_keymgmt_gen() is present,
258b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gen_init() and OSSL_FUNC_keymgmt_gen_cleanup() must be
259b077aed3SPierre Proncherypresent as well.
260b077aed3SPierre Pronchery
261b077aed3SPierre Pronchery=head2 Key Object Information Functions
262b077aed3SPierre Pronchery
263b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_get_params() should extract information data associated
264b077aed3SPierre Proncherywith the given I<keydata>, see L</Common Information Parameters>.
265b077aed3SPierre Pronchery
266b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gettable_params() should return a constant array of
267b077aed3SPierre Proncherydescriptor L<OSSL_PARAM(3)>, for parameters that OSSL_FUNC_keymgmt_get_params()
268b077aed3SPierre Proncherycan handle.
269b077aed3SPierre Pronchery
270b077aed3SPierre ProncheryIf OSSL_FUNC_keymgmt_gettable_params() is present, OSSL_FUNC_keymgmt_get_params()
271b077aed3SPierre Proncherymust also be present, and vice versa.
272b077aed3SPierre Pronchery
273b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_set_params() should update information data associated
274b077aed3SPierre Proncherywith the given I<keydata>, see L</Common Information Parameters>.
275b077aed3SPierre Pronchery
276b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_settable_params() should return a constant array of
277b077aed3SPierre Proncherydescriptor L<OSSL_PARAM(3)>, for parameters that OSSL_FUNC_keymgmt_set_params()
278b077aed3SPierre Proncherycan handle.
279b077aed3SPierre Pronchery
280b077aed3SPierre ProncheryIf OSSL_FUNC_keymgmt_settable_params() is present, OSSL_FUNC_keymgmt_set_params()
281b077aed3SPierre Proncherymust also be present, and vice versa.
282b077aed3SPierre Pronchery
283b077aed3SPierre Pronchery=head2 Key Object Checking Functions
284b077aed3SPierre Pronchery
285b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_query_operation_name() should return the name of the
286b077aed3SPierre Proncherysupported algorithm for the operation I<operation_id>.  This is
287b077aed3SPierre Proncherysimilar to provider_query_operation() (see L<provider-base(7)>),
288b077aed3SPierre Proncherybut only works as an advisory.  If this function is not present, or
289b077aed3SPierre Proncheryreturns NULL, the caller is free to assume that there's an algorithm
290b077aed3SPierre Proncheryfrom the same provider, of the same name as the one used to fetch the
291b077aed3SPierre Proncherykeymgmt and try to use that.
292b077aed3SPierre Pronchery
293b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_has() should check whether the given I<keydata> contains the subsets
294b077aed3SPierre Proncheryof data indicated by the I<selector>.  A combination of several
295b077aed3SPierre Proncheryselector bits must consider all those subsets, not just one.  An
296b077aed3SPierre Proncheryimplementation is, however, free to consider an empty subset of data
297b077aed3SPierre Proncheryto still be a valid subset. For algorithms where some selection is
298b077aed3SPierre Proncherynot meaningful such as B<OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS> for
299b077aed3SPierre ProncheryRSA keys the function should just return 1 as the selected subset
300b077aed3SPierre Proncheryis not really missing in the key.
301b077aed3SPierre Pronchery
302b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_validate() should check if the I<keydata> contains valid
303b077aed3SPierre Proncherydata subsets indicated by I<selection>.  Some combined selections of
304b077aed3SPierre Proncherydata subsets may cause validation of the combined data.
305b077aed3SPierre ProncheryFor example, the combination of B<OSSL_KEYMGMT_SELECT_PRIVATE_KEY> and
306b077aed3SPierre ProncheryB<OSSL_KEYMGMT_SELECT_PUBLIC_KEY> (or B<OSSL_KEYMGMT_SELECT_KEYPAIR>
307b077aed3SPierre Proncheryfor short) is expected to check that the pairwise consistency of
308b077aed3SPierre ProncheryI<keydata> is valid. The I<checktype> parameter controls what type of check is
309b077aed3SPierre Proncheryperformed on the subset of data. Two types of check are defined:
310b077aed3SPierre ProncheryB<OSSL_KEYMGMT_VALIDATE_FULL_CHECK> and B<OSSL_KEYMGMT_VALIDATE_QUICK_CHECK>.
311b077aed3SPierre ProncheryThe interpretation of how much checking is performed in a full check versus a
312b077aed3SPierre Proncheryquick check is key type specific. Some providers may have no distinction
313b077aed3SPierre Proncherybetween a full check and a quick check. For algorithms where some selection is
314b077aed3SPierre Proncherynot meaningful such as B<OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS> for
315b077aed3SPierre ProncheryRSA keys the function should just return 1 as there is nothing to validate for
316b077aed3SPierre Proncherythat selection.
317b077aed3SPierre Pronchery
318b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_match() should check if the data subset indicated by
319b077aed3SPierre ProncheryI<selection> in I<keydata1> and I<keydata2> match.  It is assumed that
320b077aed3SPierre Proncherythe caller has ensured that I<keydata1> and I<keydata2> are both owned
321b077aed3SPierre Proncheryby the implementation of this function.
322b077aed3SPierre Pronchery
323b077aed3SPierre Pronchery=head2 Key Object Import, Export and Duplication Functions
324b077aed3SPierre Pronchery
325b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_import() should import data indicated by I<selection> into
326b077aed3SPierre ProncheryI<keydata> with values taken from the L<OSSL_PARAM(3)> array I<params>.
327b077aed3SPierre Pronchery
328b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_export() should extract values indicated by I<selection>
329b077aed3SPierre Proncheryfrom I<keydata>, create an L<OSSL_PARAM(3)> array with them and call
330b077aed3SPierre ProncheryI<param_cb> with that array as well as the given I<cbarg>.
331b077aed3SPierre Pronchery
332b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_import_types() should return a constant array of descriptor
333b077aed3SPierre ProncheryL<OSSL_PARAM(3)> for data indicated by I<selection>, for parameters that
334b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_import() can handle.
335b077aed3SPierre Pronchery
336b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_export_types() should return a constant array of descriptor
337b077aed3SPierre ProncheryL<OSSL_PARAM(3)> for data indicated by I<selection>, that the
338b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_export() callback can expect to receive.
339b077aed3SPierre Pronchery
340b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_dup() should duplicate data subsets indicated by
341b077aed3SPierre ProncheryI<selection> or the whole key data I<keydata_from> and create a new
342b077aed3SPierre Proncheryprovider side key object with the data.
343b077aed3SPierre Pronchery
344b077aed3SPierre Pronchery=head2 Common Information Parameters
345b077aed3SPierre Pronchery
346b077aed3SPierre ProncherySee L<OSSL_PARAM(3)> for further details on the parameters structure.
347b077aed3SPierre Pronchery
348b077aed3SPierre ProncheryCommon information parameters currently recognised by all built-in
349b077aed3SPierre Proncherykeymgmt algorithms are as follows:
350b077aed3SPierre Pronchery
351b077aed3SPierre Pronchery=over 4
352b077aed3SPierre Pronchery
353b077aed3SPierre Pronchery=item "bits" (B<OSSL_PKEY_PARAM_BITS>) <integer>
354b077aed3SPierre Pronchery
355b077aed3SPierre ProncheryThe value should be the cryptographic length of the cryptosystem to
356b077aed3SPierre Proncherywhich the key belongs, in bits.  The definition of cryptographic
357b077aed3SPierre Proncherylength is specific to the key cryptosystem.
358b077aed3SPierre Pronchery
359b077aed3SPierre Pronchery=item "max-size" (B<OSSL_PKEY_PARAM_MAX_SIZE>) <integer>
360b077aed3SPierre Pronchery
361b077aed3SPierre ProncheryThe value should be the maximum size that a caller should allocate to
362b077aed3SPierre Proncherysafely store a signature (called I<sig> in L<provider-signature(7)>),
363*e0c4386eSCy Schubertthe result of asymmetric encryption / decryption (I<out> in
364b077aed3SPierre ProncheryL<provider-asym_cipher(7)>, a derived secret (I<secret> in
365b077aed3SPierre ProncheryL<provider-keyexch(7)>, and similar data).
366b077aed3SPierre Pronchery
367b077aed3SPierre ProncheryBecause an EVP_KEYMGMT method is always tightly bound to another method
368b077aed3SPierre Pronchery(signature, asymmetric cipher, key exchange, ...) and must be of the
369b077aed3SPierre Proncherysame provider, this number only needs to be synchronised with the
370b077aed3SPierre Proncherydimensions handled in the rest of the same provider.
371b077aed3SPierre Pronchery
372b077aed3SPierre Pronchery=item "security-bits" (B<OSSL_PKEY_PARAM_SECURITY_BITS>) <integer>
373b077aed3SPierre Pronchery
374b077aed3SPierre ProncheryThe value should be the number of security bits of the given key.
375b077aed3SPierre ProncheryBits of security is defined in SP800-57.
376b077aed3SPierre Pronchery
377b077aed3SPierre Pronchery=item "mandatory-digest" (B<OSSL_PKEY_PARAM_MANDATORY_DIGEST>) <UTF8 string>
378b077aed3SPierre Pronchery
379b077aed3SPierre ProncheryIf there is a mandatory digest for performing a signature operation with
380b077aed3SPierre Proncherykeys from this keymgmt, this parameter should get its name as value.
381b077aed3SPierre Pronchery
382b077aed3SPierre ProncheryWhen EVP_PKEY_get_default_digest_name() queries this parameter and it's
383b077aed3SPierre Proncheryfilled in by the implementation, its return value will be 2.
384b077aed3SPierre Pronchery
385b077aed3SPierre ProncheryIf the keymgmt implementation fills in the value C<""> or C<"UNDEF">,
386b077aed3SPierre ProncheryL<EVP_PKEY_get_default_digest_name(3)> will place the string C<"UNDEF"> into
387b077aed3SPierre Proncheryits argument I<mdname>.  This signifies that no digest should be specified
388b077aed3SPierre Proncherywith the corresponding signature operation.
389b077aed3SPierre Pronchery
390b077aed3SPierre Pronchery=item "default-digest" (B<OSSL_PKEY_PARAM_DEFAULT_DIGEST>) <UTF8 string>
391b077aed3SPierre Pronchery
392b077aed3SPierre ProncheryIf there is a default digest for performing a signature operation with
393b077aed3SPierre Proncherykeys from this keymgmt, this parameter should get its name as value.
394b077aed3SPierre Pronchery
395b077aed3SPierre ProncheryWhen L<EVP_PKEY_get_default_digest_name(3)> queries this parameter and it's
396b077aed3SPierre Proncheryfilled in by the implementation, its return value will be 1.  Note that if
397b077aed3SPierre ProncheryB<OSSL_PKEY_PARAM_MANDATORY_DIGEST> is responded to as well,
398b077aed3SPierre ProncheryL<EVP_PKEY_get_default_digest_name(3)> ignores the response to this
399b077aed3SPierre Proncheryparameter.
400b077aed3SPierre Pronchery
401b077aed3SPierre ProncheryIf the keymgmt implementation fills in the value C<""> or C<"UNDEF">,
402b077aed3SPierre ProncheryL<EVP_PKEY_get_default_digest_name(3)> will place the string C<"UNDEF"> into
403b077aed3SPierre Proncheryits argument I<mdname>.  This signifies that no digest has to be specified
404b077aed3SPierre Proncherywith the corresponding signature operation, but may be specified as an
405b077aed3SPierre Proncheryoption.
406b077aed3SPierre Pronchery
407b077aed3SPierre Pronchery=back
408b077aed3SPierre Pronchery
409b077aed3SPierre Pronchery=head1 RETURN VALUES
410b077aed3SPierre Pronchery
411b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_new() and OSSL_FUNC_keymgmt_dup() should return a valid
412b077aed3SPierre Proncheryreference to the newly created provider side key object, or NULL on failure.
413b077aed3SPierre Pronchery
414b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_import(), OSSL_FUNC_keymgmt_export(), OSSL_FUNC_keymgmt_get_params() and
415b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_set_params() should return 1 for success or 0 on error.
416b077aed3SPierre Pronchery
417b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_validate() should return 1 on successful validation, or 0 on
418b077aed3SPierre Proncheryfailure.
419b077aed3SPierre Pronchery
420b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_has() should return 1 if all the selected data subsets are contained
421b077aed3SPierre Proncheryin the given I<keydata> or 0 otherwise.
422b077aed3SPierre Pronchery
423b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_query_operation_name() should return a pointer to a string matching
424b077aed3SPierre Proncherythe requested operation, or NULL if the same name used to fetch the keymgmt
425b077aed3SPierre Proncheryapplies.
426b077aed3SPierre Pronchery
427b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_gettable_params() and OSSL_FUNC_keymgmt_settable_params()
428b077aed3SPierre ProncheryOSSL_FUNC_keymgmt_import_types(), OSSL_FUNC_keymgmt_export_types()
429b077aed3SPierre Proncheryshould
430b077aed3SPierre Proncheryalways return a constant L<OSSL_PARAM(3)> array.
431b077aed3SPierre Pronchery
432b077aed3SPierre Pronchery=head1 SEE ALSO
433b077aed3SPierre Pronchery
434b077aed3SPierre ProncheryL<provider(7)>,
435b077aed3SPierre ProncheryL<EVP_PKEY-X25519(7)>, L<EVP_PKEY-X448(7)>, L<EVP_PKEY-ED25519(7)>,
436b077aed3SPierre ProncheryL<EVP_PKEY-ED448(7)>, L<EVP_PKEY-EC(7)>, L<EVP_PKEY-RSA(7)>,
437b077aed3SPierre ProncheryL<EVP_PKEY-DSA(7)>, L<EVP_PKEY-DH(7)>
438b077aed3SPierre Pronchery
439b077aed3SPierre Pronchery=head1 HISTORY
440b077aed3SPierre Pronchery
441b077aed3SPierre ProncheryThe KEYMGMT interface was introduced in OpenSSL 3.0.
442b077aed3SPierre Pronchery
443b077aed3SPierre Pronchery=head1 COPYRIGHT
444b077aed3SPierre Pronchery
445*e0c4386eSCy SchubertCopyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
446b077aed3SPierre Pronchery
447b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
448b077aed3SPierre Proncherythis file except in compliance with the License.  You can obtain a copy
449b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at
450b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>.
451b077aed3SPierre Pronchery
452b077aed3SPierre Pronchery=cut
453