Debian Codegraph @

upstream/debian-trixie/man3/EVP_KDF.3ssl

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 "EVP_KDF 3SSL"
58 .TH EVP_KDF 3SSL 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 EVP_KDF, EVP_KDF_fetch, EVP_KDF_free, EVP_KDF_up_ref,
65 EVP_KDF_CTX, EVP_KDF_CTX_new, EVP_KDF_CTX_free, EVP_KDF_CTX_dup,
66 EVP_KDF_CTX_reset, EVP_KDF_derive,
67 EVP_KDF_CTX_get_kdf_size,
68 EVP_KDF_get0_provider, EVP_KDF_CTX_kdf, EVP_KDF_is_a,
69 EVP_KDF_get0_name, EVP_KDF_names_do_all, EVP_KDF_get0_description,
70 EVP_KDF_CTX_get_params, EVP_KDF_CTX_set_params, EVP_KDF_do_all_provided,
71 EVP_KDF_get_params, EVP_KDF_gettable_params,
72 EVP_KDF_gettable_ctx_params, EVP_KDF_settable_ctx_params,
73 EVP_KDF_CTX_gettable_params, EVP_KDF_CTX_settable_params \- EVP KDF routines
74 .SH SYNOPSIS
75 .IX Header "SYNOPSIS"
76 .Vb 1
77 \& #include <openssl/kdf.h>
78 \&
79 \& typedef struct evp_kdf_st EVP_KDF;
80 \& typedef struct evp_kdf_ctx_st EVP_KDF_CTX;
81 \&
82 \& EVP_KDF_CTX *EVP_KDF_CTX_new(EVP_KDF *kdf);
83 \& const EVP_KDF *EVP_KDF_CTX_kdf(EVP_KDF_CTX *ctx);
84 \& void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx);
85 \& EVP_KDF_CTX *EVP_KDF_CTX_dup(const EVP_KDF_CTX *src);
86 \& void EVP_KDF_CTX_reset(EVP_KDF_CTX *ctx);
87 \& size_t EVP_KDF_CTX_get_kdf_size(EVP_KDF_CTX *ctx);
88 \& int EVP_KDF_derive(EVP_KDF_CTX *ctx, unsigned char *key, size_t keylen,
89 \& const OSSL_PARAM params[]);
90 \& int EVP_KDF_up_ref(EVP_KDF *kdf);
91 \& void EVP_KDF_free(EVP_KDF *kdf);
92 \& EVP_KDF *EVP_KDF_fetch(OSSL_LIB_CTX *libctx, const char *algorithm,
93 \& const char *properties);
94 \& int EVP_KDF_is_a(const EVP_KDF *kdf, const char *name);
95 \& const char *EVP_KDF_get0_name(const EVP_KDF *kdf);
96 \& const char *EVP_KDF_get0_description(const EVP_KDF *kdf);
97 \& const OSSL_PROVIDER *EVP_KDF_get0_provider(const EVP_KDF *kdf);
98 \& void EVP_KDF_do_all_provided(OSSL_LIB_CTX *libctx,
99 \& void (*fn)(EVP_KDF *kdf, void *arg),
100 \& void *arg);
101 \& int EVP_KDF_names_do_all(const EVP_KDF *kdf,
102 \& void (*fn)(const char *name, void *data),
103 \& void *data);
104 \& int EVP_KDF_get_params(EVP_KDF *kdf, OSSL_PARAM params[]);
105 \& int EVP_KDF_CTX_get_params(EVP_KDF_CTX *ctx, OSSL_PARAM params[]);
106 \& int EVP_KDF_CTX_set_params(EVP_KDF_CTX *ctx, const OSSL_PARAM params[]);
107 \& const OSSL_PARAM *EVP_KDF_gettable_params(const EVP_KDF *kdf);
108 \& const OSSL_PARAM *EVP_KDF_gettable_ctx_params(const EVP_KDF *kdf);
109 \& const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf);
110 \& const OSSL_PARAM *EVP_KDF_CTX_gettable_params(const EVP_KDF *kdf);
111 \& const OSSL_PARAM *EVP_KDF_CTX_settable_params(const EVP_KDF *kdf);
112 \& const OSSL_PROVIDER *EVP_KDF_get0_provider(const EVP_KDF *kdf);
113 .Ve
114 .SH DESCRIPTION
115 .IX Header "DESCRIPTION"
116 The EVP KDF routines are a high-level interface to Key Derivation Function
117 algorithms and should be used instead of algorithm-specific functions.
118 .PP
119 After creating a \fBEVP_KDF_CTX\fR for the required algorithm using
120 \&\fBEVP_KDF_CTX_new()\fR, inputs to the algorithm are supplied either by
121 passing them as part of the \fBEVP_KDF_derive()\fR call or using calls
122 to \fBEVP_KDF_CTX_set_params()\fR before calling \fBEVP_KDF_derive()\fR to derive
123 the key.
124 .SS Types
125 .IX Subsection "Types"
126 \&\fBEVP_KDF\fR is a type that holds the implementation of a KDF.
127 .PP
128 \&\fBEVP_KDF_CTX\fR is a context type that holds the algorithm inputs.
129 .SS "Algorithm implementation fetching"
130 .IX Subsection "Algorithm implementation fetching"
131 \&\fBEVP_KDF_fetch()\fR fetches an implementation of a KDF \fIalgorithm\fR, given
132 a library context \fIlibctx\fR and a set of \fIproperties\fR.
133 See "ALGORITHM FETCHING" in \fBcrypto\fR\|(7) for further information.
134 .PP
135 See "Key Derivation Function (KDF)" in \fBOSSL_PROVIDER\-default\fR\|(7) for the lists of
136 algorithms supported by the default provider.
137 .PP
138 The returned value must eventually be freed with
139 \&\fBEVP_KDF_free\fR\|(3).
140 .PP
141 \&\fBEVP_KDF_up_ref()\fR increments the reference count of an already fetched
142 KDF.
143 .PP
144 \&\fBEVP_KDF_free()\fR frees a fetched algorithm.
145 NULL is a valid parameter, for which this function is a no-op.
146 .SS "Context manipulation functions"
147 .IX Subsection "Context manipulation functions"
148 \&\fBEVP_KDF_CTX_new()\fR creates a new context for the KDF implementation \fIkdf\fR.
149 .PP
150 \&\fBEVP_KDF_CTX_free()\fR frees up the context \fIctx\fR. If \fIctx\fR is NULL, nothing
151 is done.
152 .PP
153 \&\fBEVP_KDF_CTX_kdf()\fR returns the \fBEVP_KDF\fR associated with the context
154 \&\fIctx\fR.
155 .SS "Computing functions"
156 .IX Subsection "Computing functions"
157 \&\fBEVP_KDF_CTX_reset()\fR resets the context to the default state as if the context
158 had just been created.
159 .PP
160 \&\fBEVP_KDF_derive()\fR processes any parameters in \fIParams\fR and then derives
161 \&\fIkeylen\fR bytes of key material and places it in the \fIkey\fR buffer.
162 If the algorithm produces a fixed amount of output then an error will
163 occur unless the \fIkeylen\fR parameter is equal to that output size,
164 as returned by \fBEVP_KDF_CTX_get_kdf_size()\fR.
165 .PP
166 \&\fBEVP_KDF_get_params()\fR retrieves details about the implementation
167 \&\fIkdf\fR.
168 The set of parameters given with \fIparams\fR determine exactly what
169 parameters should be retrieved.
170 Note that a parameter that is unknown in the underlying context is
171 simply ignored.
172 .PP
173 \&\fBEVP_KDF_CTX_get_params()\fR retrieves chosen parameters, given the
174 context \fIctx\fR and its underlying context.
175 The set of parameters given with \fIparams\fR determine exactly what
176 parameters should be retrieved.
177 Note that a parameter that is unknown in the underlying context is
178 simply ignored.
179 .PP
180 \&\fBEVP_KDF_CTX_set_params()\fR passes chosen parameters to the underlying
181 context, given a context \fIctx\fR.
182 The set of parameters given with \fIparams\fR determine exactly what
183 parameters are passed down.
184 Note that a parameter that is unknown in the underlying context is
185 simply ignored.
186 Also, what happens when a needed parameter isn't passed down is
187 defined by the implementation.
188 .PP
189 \&\fBEVP_KDF_gettable_params()\fR returns an \fBOSSL_PARAM\fR\|(3) array that describes
190 the retrievable and settable parameters. \fBEVP_KDF_gettable_params()\fR
191 returns parameters that can be used with \fBEVP_KDF_get_params()\fR.
192 .PP
193 \&\fBEVP_KDF_gettable_ctx_params()\fR and \fBEVP_KDF_CTX_gettable_params()\fR
194 return constant \fBOSSL_PARAM\fR\|(3) arrays that describe the retrievable
195 parameters that can be used with \fBEVP_KDF_CTX_get_params()\fR.
196 \&\fBEVP_KDF_gettable_ctx_params()\fR returns the parameters that can be retrieved
197 from the algorithm, whereas \fBEVP_KDF_CTX_gettable_params()\fR returns
198 the parameters that can be retrieved in the context's current state.
199 .PP
200 \&\fBEVP_KDF_settable_ctx_params()\fR and \fBEVP_KDF_CTX_settable_params()\fR return
201 constant \fBOSSL_PARAM\fR\|(3) arrays that describe the settable parameters that
202 can be used with \fBEVP_KDF_CTX_set_params()\fR. \fBEVP_KDF_settable_ctx_params()\fR
203 returns the parameters that can be retrieved from the algorithm,
204 whereas \fBEVP_KDF_CTX_settable_params()\fR returns the parameters that can
205 be retrieved in the context's current state.
206 .SS "Information functions"
207 .IX Subsection "Information functions"
208 \&\fBEVP_KDF_CTX_get_kdf_size()\fR returns the output size if the algorithm produces a fixed amount
209 of output and \fBSIZE_MAX\fR otherwise. If an error occurs then 0 is returned.
210 For some algorithms an error may result if input parameters necessary to
211 calculate a fixed output size have not yet been supplied.
212 .PP
213 \&\fBEVP_KDF_is_a()\fR returns 1 if \fIkdf\fR is an implementation of an
214 algorithm that's identifiable with \fIname\fR, otherwise 0.
215 .PP
216 \&\fBEVP_KDF_get0_provider()\fR returns the provider that holds the implementation
217 of the given \fIkdf\fR.
218 .PP
219 \&\fBEVP_KDF_do_all_provided()\fR traverses all KDF implemented by all activated
220 providers in the given library context \fIlibctx\fR, and for each of the
221 implementations, calls the given function \fIfn\fR with the implementation method
222 and the given \fIarg\fR as argument.
223 .PP
224 \&\fBEVP_KDF_get0_name()\fR return the name of the given KDF. For fetched KDFs
225 with multiple names, only one of them is returned; it's
226 recommended to use \fBEVP_KDF_names_do_all()\fR instead.
227 .PP
228 \&\fBEVP_KDF_names_do_all()\fR traverses all names for \fIkdf\fR, and calls
229 \&\fIfn\fR with each name and \fIdata\fR.
230 .PP
231 \&\fBEVP_KDF_get0_description()\fR returns a description of the \fIkdf\fR, meant for
232 display and human consumption. The description is at the discretion of
233 the \fIkdf\fR implementation.
234 .SH PARAMETERS
235 .IX Header "PARAMETERS"
236 The standard parameter names are:
237 .IP """pass"" (\fBOSSL_KDF_PARAM_PASSWORD\fR) <octet string>" 4
238 .IX Item """pass"" (OSSL_KDF_PARAM_PASSWORD) <octet string>"
239 Some KDF implementations require a password.
240 For those KDF implementations that support it, this parameter sets the password.
241 .IP """salt"" (\fBOSSL_KDF_PARAM_SALT\fR) <octet string>" 4
242 .IX Item """salt"" (OSSL_KDF_PARAM_SALT) <octet string>"
243 Some KDF implementations can take a non-secret unique cryptographic salt.
244 For those KDF implementations that support it, this parameter sets the salt.
245 .Sp
246 The default value, if any, is implementation dependent.
247 .IP """iter"" (\fBOSSL_KDF_PARAM_ITER\fR) <unsigned integer>" 4
248 .IX Item """iter"" (OSSL_KDF_PARAM_ITER) <unsigned integer>"
249 Some KDF implementations require an iteration count.
250 For those KDF implementations that support it, this parameter sets the
251 iteration count.
252 .Sp
253 The default value, if any, is implementation dependent.
254 .IP """properties"" (\fBOSSL_KDF_PARAM_PROPERTIES\fR) <UTF8 string>" 4
255 .IX Item """properties"" (OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>"
256 .PD 0
257 .IP """mac"" (\fBOSSL_KDF_PARAM_MAC\fR) <UTF8 string>" 4
258 .IX Item """mac"" (OSSL_KDF_PARAM_MAC) <UTF8 string>"
259 .IP """digest"" (\fBOSSL_KDF_PARAM_DIGEST\fR) <UTF8 string>" 4
260 .IX Item """digest"" (OSSL_KDF_PARAM_DIGEST) <UTF8 string>"
261 .IP """cipher"" (\fBOSSL_KDF_PARAM_CIPHER\fR) <UTF8 string>" 4
262 .IX Item """cipher"" (OSSL_KDF_PARAM_CIPHER) <UTF8 string>"
263 .PD
264 For KDF implementations that use an underlying computation MAC, digest or
265 cipher, these parameters set what the algorithm should be.
266 .Sp
267 The value is always the name of the intended algorithm,
268 or the properties.
269 .Sp
270 Note that not all algorithms may support all possible underlying
271 implementations.
272 .IP """key"" (\fBOSSL_KDF_PARAM_KEY\fR) <octet string>" 4
273 .IX Item """key"" (OSSL_KDF_PARAM_KEY) <octet string>"
274 Some KDF implementations require a key.
275 For those KDF implementations that support it, this octet string parameter
276 sets the key.
277 .IP """info"" (\fBOSSL_KDF_PARAM_INFO\fR) <octet string>" 4
278 .IX Item """info"" (OSSL_KDF_PARAM_INFO) <octet string>"
279 Some KDF implementations, such as \fBEVP_KDF\-HKDF\fR\|(7), take an 'info' parameter
280 for binding the derived key material
281 to application\- and context-specific information.
282 This parameter sets the info, fixed info, other info or shared info argument.
283 You can specify this parameter multiple times, and each instance will
284 be concatenated to form the final value.
285 .IP """maclen"" (\fBOSSL_KDF_PARAM_MAC_SIZE\fR) <unsigned integer>" 4
286 .IX Item """maclen"" (OSSL_KDF_PARAM_MAC_SIZE) <unsigned integer>"
287 Used by implementations that use a MAC with a variable output size (KMAC).
288 For those KDF implementations that support it, this parameter
289 sets the MAC output size.
290 .Sp
291 The default value, if any, is implementation dependent.
292 The length must never exceed what can be given with a \fBsize_t\fR.
293 .IP """maxmem_bytes"" (\fBOSSL_KDF_PARAM_SCRYPT_MAXMEM\fR) <unsigned integer>" 4
294 .IX Item """maxmem_bytes"" (OSSL_KDF_PARAM_SCRYPT_MAXMEM) <unsigned integer>"
295 Memory-hard password-based KDF algorithms, such as scrypt, use an amount of
296 memory that depends on the load factors provided as input.
297 For those KDF implementations that support it, this \fBuint64_t\fR parameter sets
298 an upper limit on the amount of memory that may be consumed while performing
299 a key derivation.
300 If this memory usage limit is exceeded because the load factors are chosen
301 too high, the key derivation will fail.
302 .Sp
303 The default value is implementation dependent.
304 The memory size must never exceed what can be given with a \fBsize_t\fR.
305 .SH "RETURN VALUES"
306 .IX Header "RETURN VALUES"
307 \&\fBEVP_KDF_fetch()\fR returns a pointer to a newly fetched \fBEVP_KDF\fR, or
308 NULL if allocation failed.
309 .PP
310 \&\fBEVP_KDF_get0_provider()\fR returns a pointer to the provider for the KDF, or
311 NULL on error.
312 .PP
313 \&\fBEVP_KDF_up_ref()\fR returns 1 on success, 0 on error.
314 .PP
315 \&\fBEVP_KDF_CTX_new()\fR returns either the newly allocated
316 \&\fBEVP_KDF_CTX\fR structure or NULL if an error occurred.
317 .PP
318 \&\fBEVP_KDF_CTX_free()\fR and \fBEVP_KDF_CTX_reset()\fR do not return a value.
319 .PP
320 \&\fBEVP_KDF_CTX_get_kdf_size()\fR returns the output size. \fBSIZE_MAX\fR is returned to indicate
321 that the algorithm produces a variable amount of output; 0 to indicate failure.
322 .PP
323 \&\fBEVP_KDF_get0_name()\fR returns the name of the KDF, or NULL on error.
324 .PP
325 \&\fBEVP_KDF_names_do_all()\fR returns 1 if the callback was called for all names. A
326 return value of 0 means that the callback was not called for any names.
327 .PP
328 The remaining functions return 1 for success and 0 for failure.
329 .SH NOTES
330 .IX Header "NOTES"
331 The KDF life-cycle is described in \fBlife_cycle\-kdf\fR\|(7). In the future,
332 the transitions described there will be enforced. When this is done, it will
333 not be considered a breaking change to the API.
334 .SH "SEE ALSO"
335 .IX Header "SEE ALSO"
336 "Key Derivation Function (KDF)" in \fBOSSL_PROVIDER\-default\fR\|(7),
337 \&\fBlife_cycle\-kdf\fR\|(7).
338 .SH HISTORY
339 .IX Header "HISTORY"
340 This functionality was added in OpenSSL 3.0.
341 .SH COPYRIGHT
342 .IX Header "COPYRIGHT"
343 Copyright 2019\-2024 The OpenSSL Project Authors. All Rights Reserved.
344 .PP
345 Licensed under the Apache License 2.0 (the "License"). You may not use
346 this file except in compliance with the License. You can obtain a copy
347 in the file LICENSE in the source distribution or at
348 <https://www.openssl.org/source/license.html>.