Debian Codegraph @

upstream/debian-trixie/man7/provider-kdf.7ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "PROVIDER-KDF 7SSL"
58 .TH PROVIDER-KDF 7SSL 2026-04-07 3.5.6 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 provider\-kdf \- The KDF library <\-> provider functions
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 .Vb 2
68 \& #include <openssl/core_dispatch.h>
69 \& #include <openssl/core_names.h>
70 \&
71 \& /*
72 \& * None of these are actual functions, but are displayed like this for
73 \& * the function signatures for functions that are offered as function
74 \& * pointers in OSSL_DISPATCH arrays.
75 \& */
76 \&
77 \& /* Context management */
78 \& void *OSSL_FUNC_kdf_newctx(void *provctx);
79 \& void OSSL_FUNC_kdf_freectx(void *kctx);
80 \& void *OSSL_FUNC_kdf_dupctx(void *src);
81 \&
82 \& /* Encryption/decryption */
83 \& int OSSL_FUNC_kdf_reset(void *kctx);
84 \& int OSSL_FUNC_kdf_derive(void *kctx, unsigned char *key, size_t keylen,
85 \& const OSSL_PARAM params[]);
86 \&
87 \& /* KDF parameter descriptors */
88 \& const OSSL_PARAM *OSSL_FUNC_kdf_gettable_params(void *provctx);
89 \& const OSSL_PARAM *OSSL_FUNC_kdf_gettable_ctx_params(void *kcxt, void *provctx);
90 \& const OSSL_PARAM *OSSL_FUNC_kdf_settable_ctx_params(void *kcxt, void *provctx);
91 \&
92 \& /* KDF parameters */
93 \& int OSSL_FUNC_kdf_get_params(OSSL_PARAM params[]);
94 \& int OSSL_FUNC_kdf_get_ctx_params(void *kctx, OSSL_PARAM params[]);
95 \& int OSSL_FUNC_kdf_set_ctx_params(void *kctx, const OSSL_PARAM params[]);
96 .Ve
97 .SH DESCRIPTION
98 .IX Header "DESCRIPTION"
99 This documentation is primarily aimed at provider authors. See \fBprovider\fR\|(7)
100 for further information.
101 .PP
102 The KDF operation enables providers to implement KDF algorithms and make
103 them available to applications via the API functions \fBEVP_KDF_CTX_reset\fR\|(3),
104 and \fBEVP_KDF_derive\fR\|(3).
105 .PP
106 All "functions" mentioned here are passed as function pointers between
107 \&\fIlibcrypto\fR and the provider in \fBOSSL_DISPATCH\fR\|(3) arrays via
108 \&\fBOSSL_ALGORITHM\fR\|(3) arrays that are returned by the provider's
109 \&\fBprovider_query_operation()\fR function
110 (see "Provider Functions" in \fBprovider\-base\fR\|(7)).
111 .PP
112 All these "functions" have a corresponding function type definition
113 named \fBOSSL_FUNC_{name}_fn\fR, and a helper function to retrieve the
114 function pointer from an \fBOSSL_DISPATCH\fR\|(3) element named
115 \&\fBOSSL_FUNC_{name}\fR.
116 For example, the "function" \fBOSSL_FUNC_kdf_newctx()\fR has these:
117 .PP
118 .Vb 3
119 \& typedef void *(OSSL_FUNC_kdf_newctx_fn)(void *provctx);
120 \& static ossl_inline OSSL_FUNC_kdf_newctx_fn
121 \& OSSL_FUNC_kdf_newctx(const OSSL_DISPATCH *opf);
122 .Ve
123 .PP
124 \&\fBOSSL_DISPATCH\fR\|(3) array entries are identified by numbers that are provided as
125 macros in \fBopenssl\-core_dispatch.h\fR\|(7), as follows:
126 .PP
127 .Vb 3
128 \& OSSL_FUNC_kdf_newctx OSSL_FUNC_KDF_NEWCTX
129 \& OSSL_FUNC_kdf_freectx OSSL_FUNC_KDF_FREECTX
130 \& OSSL_FUNC_kdf_dupctx OSSL_FUNC_KDF_DUPCTX
131 \&
132 \& OSSL_FUNC_kdf_reset OSSL_FUNC_KDF_RESET
133 \& OSSL_FUNC_kdf_derive OSSL_FUNC_KDF_DERIVE
134 \&
135 \& OSSL_FUNC_kdf_get_params OSSL_FUNC_KDF_GET_PARAMS
136 \& OSSL_FUNC_kdf_get_ctx_params OSSL_FUNC_KDF_GET_CTX_PARAMS
137 \& OSSL_FUNC_kdf_set_ctx_params OSSL_FUNC_KDF_SET_CTX_PARAMS
138 \&
139 \& OSSL_FUNC_kdf_gettable_params OSSL_FUNC_KDF_GETTABLE_PARAMS
140 \& OSSL_FUNC_kdf_gettable_ctx_params OSSL_FUNC_KDF_GETTABLE_CTX_PARAMS
141 \& OSSL_FUNC_kdf_settable_ctx_params OSSL_FUNC_KDF_SETTABLE_CTX_PARAMS
142 .Ve
143 .PP
144 A KDF algorithm implementation may not implement all of these functions.
145 In order to be a consistent set of functions, at least the following functions
146 must be implemented: \fBOSSL_FUNC_kdf_newctx()\fR, \fBOSSL_FUNC_kdf_freectx()\fR,
147 \&\fBOSSL_FUNC_kdf_set_ctx_params()\fR, \fBOSSL_FUNC_kdf_derive()\fR.
148 All other functions are optional.
149 .SS "Context Management Functions"
150 .IX Subsection "Context Management Functions"
151 \&\fBOSSL_FUNC_kdf_newctx()\fR should create and return a pointer to a provider side
152 structure for holding context information during a KDF operation.
153 A pointer to this context will be passed back in a number of the other KDF
154 operation function calls.
155 The parameter \fIprovctx\fR is the provider context generated during provider
156 initialisation (see \fBprovider\fR\|(7)).
157 .PP
158 \&\fBOSSL_FUNC_kdf_freectx()\fR is passed a pointer to the provider side KDF context in
159 the \fIkctx\fR parameter.
160 If it receives NULL as \fIkctx\fR value, it should not do anything other than
161 return.
162 This function should free any resources associated with that context.
163 .PP
164 \&\fBOSSL_FUNC_kdf_dupctx()\fR should duplicate the provider side KDF context in the
165 \&\fIkctx\fR parameter and return the duplicate copy.
166 .SS "Encryption/Decryption Functions"
167 .IX Subsection "Encryption/Decryption Functions"
168 \&\fBOSSL_FUNC_kdf_reset()\fR initialises a KDF operation given a provider
169 side KDF context in the \fIkctx\fR parameter.
170 .PP
171 \&\fBOSSL_FUNC_kdf_derive()\fR performs the KDF operation after processing the
172 \&\fIparams\fR as per \fBOSSL_FUNC_kdf_set_ctx_params()\fR.
173 The \fIkctx\fR parameter contains a pointer to the provider side context.
174 The resulting key of the desired \fIkeylen\fR should be written to \fIkey\fR.
175 If the algorithm does not support the requested \fIkeylen\fR the function must
176 return error.
177 .SS "KDF Parameters"
178 .IX Subsection "KDF Parameters"
179 See \fBOSSL_PARAM\fR\|(3) for further details on the parameters structure used by
180 these functions.
181 .PP
182 \&\fBOSSL_FUNC_kdf_get_params()\fR gets details of parameter values associated with the
183 provider algorithm and stores them in \fIparams\fR.
184 .PP
185 \&\fBOSSL_FUNC_kdf_set_ctx_params()\fR sets KDF parameters associated with the given
186 provider side KDF context \fIkctx\fR to \fIparams\fR.
187 Any parameter settings are additional to any that were previously set.
188 Passing NULL for \fIparams\fR should return true.
189 .PP
190 \&\fBOSSL_FUNC_kdf_get_ctx_params()\fR retrieves gettable parameter values associated
191 with the given provider side KDF context \fIkctx\fR and stores them in \fIparams\fR.
192 Passing NULL for \fIparams\fR should return true.
193 .PP
194 \&\fBOSSL_FUNC_kdf_gettable_params()\fR, \fBOSSL_FUNC_kdf_gettable_ctx_params()\fR,
195 and \fBOSSL_FUNC_kdf_settable_ctx_params()\fR all return constant \fBOSSL_PARAM\fR\|(3)
196 arrays as descriptors of the parameters that \fBOSSL_FUNC_kdf_get_params()\fR,
197 \&\fBOSSL_FUNC_kdf_get_ctx_params()\fR, and \fBOSSL_FUNC_kdf_set_ctx_params()\fR
198 can handle, respectively. \fBOSSL_FUNC_kdf_gettable_ctx_params()\fR and
199 \&\fBOSSL_FUNC_kdf_settable_ctx_params()\fR will return the parameters associated
200 with the provider side context \fIkctx\fR in its current state if it is
201 not NULL. Otherwise, they return the parameters associated with the
202 provider side algorithm \fIprovctx\fR.
203 .PP
204 Parameters currently recognised by built-in KDFs are as follows. Not all
205 parameters are relevant to, or are understood by all KDFs:
206 .IP """size"" (\fBOSSL_KDF_PARAM_SIZE\fR) <unsigned integer>" 4
207 .IX Item """size"" (OSSL_KDF_PARAM_SIZE) <unsigned integer>"
208 Gets the output size from the associated KDF ctx.
209 If the algorithm produces a variable amount of output, SIZE_MAX should be
210 returned.
211 If the input parameters required to calculate the fixed output size have not yet
212 been supplied, 0 should be returned indicating an error.
213 .IP """key"" (\fBOSSL_KDF_PARAM_KEY\fR) <octet string>" 4
214 .IX Item """key"" (OSSL_KDF_PARAM_KEY) <octet string>"
215 Sets the key in the associated KDF ctx.
216 .IP """secret"" (\fBOSSL_KDF_PARAM_SECRET\fR) <octet string>" 4
217 .IX Item """secret"" (OSSL_KDF_PARAM_SECRET) <octet string>"
218 Sets the secret in the associated KDF ctx.
219 .IP """pass"" (\fBOSSL_KDF_PARAM_PASSWORD\fR) <octet string>" 4
220 .IX Item """pass"" (OSSL_KDF_PARAM_PASSWORD) <octet string>"
221 Sets the password in the associated KDF ctx.
222 .IP """cipher"" (\fBOSSL_KDF_PARAM_CIPHER\fR) <UTF8 string>" 4
223 .IX Item """cipher"" (OSSL_KDF_PARAM_CIPHER) <UTF8 string>"
224 .PD 0
225 .IP """digest"" (\fBOSSL_KDF_PARAM_DIGEST\fR) <UTF8 string>" 4
226 .IX Item """digest"" (OSSL_KDF_PARAM_DIGEST) <UTF8 string>"
227 .IP """mac"" (\fBOSSL_KDF_PARAM_MAC\fR) <UTF8 string>" 4
228 .IX Item """mac"" (OSSL_KDF_PARAM_MAC) <UTF8 string>"
229 .PD
230 Sets the name of the underlying cipher, digest or MAC to be used.
231 It must name a suitable algorithm for the KDF that's being used.
232 .IP """maclen"" (\fBOSSL_KDF_PARAM_MAC_SIZE\fR) <octet string>" 4
233 .IX Item """maclen"" (OSSL_KDF_PARAM_MAC_SIZE) <octet string>"
234 Sets the length of the MAC in the associated KDF ctx.
235 .IP """properties"" (\fBOSSL_KDF_PARAM_PROPERTIES\fR) <UTF8 string>" 4
236 .IX Item """properties"" (OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>"
237 Sets the properties to be queried when trying to fetch the underlying algorithm.
238 This must be given together with the algorithm naming parameter to be
239 considered valid.
240 .IP """iter"" (\fBOSSL_KDF_PARAM_ITER\fR) <unsigned integer>" 4
241 .IX Item """iter"" (OSSL_KDF_PARAM_ITER) <unsigned integer>"
242 Sets the number of iterations in the associated KDF ctx.
243 .IP """mode"" (\fBOSSL_KDF_PARAM_MODE\fR) <UTF8 string>" 4
244 .IX Item """mode"" (OSSL_KDF_PARAM_MODE) <UTF8 string>"
245 Sets the mode in the associated KDF ctx.
246 .IP """pkcs5"" (\fBOSSL_KDF_PARAM_PKCS5\fR) <integer>" 4
247 .IX Item """pkcs5"" (OSSL_KDF_PARAM_PKCS5) <integer>"
248 Enables or disables the SP800\-132 compliance checks.
249 A mode of 0 enables the compliance checks.
250 .Sp
251 The checks performed are:
252 .RS 4
253 .IP "\- the iteration count is at least 1000." 4
254 .IX Item "- the iteration count is at least 1000."
255 .PD 0
256 .IP "\- the salt length is at least 128 bits." 4
257 .IX Item "- the salt length is at least 128 bits."
258 .IP "\- the derived key length is at least 112 bits." 4
259 .IX Item "- the derived key length is at least 112 bits."
260 .RE
261 .RS 4
262 .RE
263 .IP """ukm"" (\fBOSSL_KDF_PARAM_UKM\fR) <octet string>" 4
264 .IX Item """ukm"" (OSSL_KDF_PARAM_UKM) <octet string>"
265 .PD
266 Sets an optional random string that is provided by the sender called
267 "partyAInfo". In CMS this is the user keying material.
268 .IP """cekalg"" (\fBOSSL_KDF_PARAM_CEK_ALG\fR) <UTF8 string>" 4
269 .IX Item """cekalg"" (OSSL_KDF_PARAM_CEK_ALG) <UTF8 string>"
270 Sets the CEK wrapping algorithm name in the associated KDF ctx.
271 .IP """n"" (\fBOSSL_KDF_PARAM_SCRYPT_N\fR) <unsigned integer>" 4
272 .IX Item """n"" (OSSL_KDF_PARAM_SCRYPT_N) <unsigned integer>"
273 Sets the scrypt work factor parameter N in the associated KDF ctx.
274 .IP """r"" (\fBOSSL_KDF_PARAM_SCRYPT_R\fR) <unsigned integer>" 4
275 .IX Item """r"" (OSSL_KDF_PARAM_SCRYPT_R) <unsigned integer>"
276 Sets the scrypt work factor parameter r in the associated KDF ctx.
277 .IP """p"" (\fBOSSL_KDF_PARAM_SCRYPT_P\fR) <unsigned integer>" 4
278 .IX Item """p"" (OSSL_KDF_PARAM_SCRYPT_P) <unsigned integer>"
279 Sets the scrypt work factor parameter p in the associated KDF ctx.
280 .IP """maxmem_bytes"" (\fBOSSL_KDF_PARAM_SCRYPT_MAXMEM\fR) <unsigned integer>" 4
281 .IX Item """maxmem_bytes"" (OSSL_KDF_PARAM_SCRYPT_MAXMEM) <unsigned integer>"
282 Sets the scrypt work factor parameter maxmem in the associated KDF ctx.
283 .IP """prefix"" (\fBOSSL_KDF_PARAM_PREFIX\fR) <octet string>" 4
284 .IX Item """prefix"" (OSSL_KDF_PARAM_PREFIX) <octet string>"
285 Sets the prefix string using by the TLS 1.3 version of HKDF in the
286 associated KDF ctx.
287 .IP """label"" (\fBOSSL_KDF_PARAM_LABEL\fR) <octet string>" 4
288 .IX Item """label"" (OSSL_KDF_PARAM_LABEL) <octet string>"
289 Sets the label string using by the TLS 1.3 version of HKDF in the
290 associated KDF ctx.
291 .IP """data"" (\fBOSSL_KDF_PARAM_DATA\fR) <octet string>" 4
292 .IX Item """data"" (OSSL_KDF_PARAM_DATA) <octet string>"
293 Sets the context string using by the TLS 1.3 version of HKDF in the
294 associated KDF ctx.
295 .IP """info"" (\fBOSSL_KDF_PARAM_INFO\fR) <octet string>" 4
296 .IX Item """info"" (OSSL_KDF_PARAM_INFO) <octet string>"
297 Sets the optional shared info in the associated KDF ctx.
298 .IP """seed"" (\fBOSSL_KDF_PARAM_SEED\fR) <octet string>" 4
299 .IX Item """seed"" (OSSL_KDF_PARAM_SEED) <octet string>"
300 Sets the IV in the associated KDF ctx.
301 .IP """xcghash"" (\fBOSSL_KDF_PARAM_SSHKDF_XCGHASH\fR) <octet string>" 4
302 .IX Item """xcghash"" (OSSL_KDF_PARAM_SSHKDF_XCGHASH) <octet string>"
303 Sets the xcghash in the associated KDF ctx.
304 .IP """session_id"" (\fBOSSL_KDF_PARAM_SSHKDF_SESSION_ID\fR) <octet string>" 4
305 .IX Item """session_id"" (OSSL_KDF_PARAM_SSHKDF_SESSION_ID) <octet string>"
306 Sets the session ID in the associated KDF ctx.
307 .IP """type"" (\fBOSSL_KDF_PARAM_SSHKDF_TYPE\fR) <UTF8 string>" 4
308 .IX Item """type"" (OSSL_KDF_PARAM_SSHKDF_TYPE) <UTF8 string>"
309 Sets the SSH KDF type parameter in the associated KDF ctx.
310 There are six supported types:
311 .RS 4
312 .IP EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV 4
313 .IX Item "EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV"
314 The Initial IV from client to server.
315 A single char of value 65 (ASCII char 'A').
316 .IP EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI 4
317 .IX Item "EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI"
318 The Initial IV from server to client
319 A single char of value 66 (ASCII char 'B').
320 .IP EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRV 4
321 .IX Item "EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRV"
322 The Encryption Key from client to server
323 A single char of value 67 (ASCII char 'C').
324 .IP EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLI 4
325 .IX Item "EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLI"
326 The Encryption Key from server to client
327 A single char of value 68 (ASCII char 'D').
328 .IP EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV 4
329 .IX Item "EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV"
330 The Integrity Key from client to server
331 A single char of value 69 (ASCII char 'E').
332 .IP EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI 4
333 .IX Item "EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI"
334 The Integrity Key from client to server
335 A single char of value 70 (ASCII char 'F').
336 .RE
337 .RS 4
338 .RE
339 .IP """constant"" (\fBOSSL_KDF_PARAM_CONSTANT\fR) <octet string>" 4
340 .IX Item """constant"" (OSSL_KDF_PARAM_CONSTANT) <octet string>"
341 Sets the constant value in the associated KDF ctx.
342 .IP """id"" (\fBOSSL_KDF_PARAM_PKCS12_ID\fR) <integer>" 4
343 .IX Item """id"" (OSSL_KDF_PARAM_PKCS12_ID) <integer>"
344 Sets the intended usage of the output bits in the associated KDF ctx.
345 It is defined as per RFC 7292 section B.3.
346 .SH "RETURN VALUES"
347 .IX Header "RETURN VALUES"
348 \&\fBOSSL_FUNC_kdf_newctx()\fR and \fBOSSL_FUNC_kdf_dupctx()\fR should return the newly created
349 provider side KDF context, or NULL on failure.
350 .PP
351 \&\fBOSSL_FUNC_kdf_derive()\fR, \fBOSSL_FUNC_kdf_get_params()\fR,
352 \&\fBOSSL_FUNC_kdf_get_ctx_params()\fR and \fBOSSL_FUNC_kdf_set_ctx_params()\fR should return 1 for
353 success or 0 on error.
354 .PP
355 \&\fBOSSL_FUNC_kdf_gettable_params()\fR, \fBOSSL_FUNC_kdf_gettable_ctx_params()\fR and
356 \&\fBOSSL_FUNC_kdf_settable_ctx_params()\fR should return a constant \fBOSSL_PARAM\fR\|(3)
357 array, or NULL if none is offered.
358 .SH NOTES
359 .IX Header "NOTES"
360 The KDF life-cycle is described in \fBlife_cycle\-kdf\fR\|(7). Providers should
361 ensure that the various transitions listed there are supported. At some point
362 the EVP layer will begin enforcing the listed transitions.
363 .SH "SEE ALSO"
364 .IX Header "SEE ALSO"
365 \&\fBprovider\fR\|(7), \fBlife_cycle\-kdf\fR\|(7), \fBEVP_KDF\fR\|(3).
366 .SH HISTORY
367 .IX Header "HISTORY"
368 The provider KDF interface was introduced in OpenSSL 3.0.
369 .SH COPYRIGHT
370 .IX Header "COPYRIGHT"
371 Copyright 2020\-2022 The OpenSSL Project Authors. All Rights Reserved.
372 .PP
373 Licensed under the Apache License 2.0 (the "License"). You may not use
374 this file except in compliance with the License. You can obtain a copy
375 in the file LICENSE in the source distribution or at
376 <https://www.openssl.org/source/license.html>.