]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/EVP_KDF.pod
Fix typos and repeated words
[thirdparty/openssl.git] / doc / man3 / EVP_KDF.pod
CommitLineData
65ce7e65
P
1=pod
2
3=head1 NAME
4
251e610c 5EVP_KDF, EVP_KDF_fetch, EVP_KDF_free, EVP_KDF_up_ref,
765d04c9 6EVP_KDF_CTX, EVP_KDF_new_ctx, EVP_KDF_free_ctx, EVP_KDF_dup_ctx,
251e610c 7EVP_KDF_reset, EVP_KDF_derive,
765d04c9 8EVP_KDF_size, EVP_KDF_provider, EVP_KDF_get_ctx_kdf, EVP_KDF_is_a,
506cb0f6 9EVP_KDF_number, EVP_KDF_names_do_all,
765d04c9 10EVP_KDF_get_ctx_params, EVP_KDF_set_ctx_params, EVP_KDF_do_all_provided,
41f7ecf3 11EVP_KDF_get_params, EVP_KDF_gettable_ctx_params, EVP_KDF_settable_ctx_params,
65ce7e65
P
12EVP_KDF_gettable_params - EVP KDF routines
13
14=head1 SYNOPSIS
15
16 #include <openssl/kdf.h>
17
18 typedef struct evp_kdf_st EVP_KDF;
19 typedef struct evp_kdf_ctx_st EVP_KDF_CTX;
20
765d04c9
P
21 EVP_KDF_CTX *EVP_KDF_new_ctx(const EVP_KDF *kdf);
22 const EVP_KDF *EVP_KDF_get_ctx_kdf(EVP_KDF_CTX *ctx);
23 void EVP_KDF_free_ctx(EVP_KDF_CTX *ctx);
24 EVP_KDF_CTX *EVP_KDF_dup_ctx(const EVP_KDF_CTX *src);
65ce7e65
P
25 void EVP_KDF_reset(EVP_KDF_CTX *ctx);
26 size_t EVP_KDF_size(EVP_KDF_CTX *ctx);
27 int EVP_KDF_derive(EVP_KDF_CTX *ctx, unsigned char *key, size_t keylen);
65ce7e65
P
28 int EVP_KDF_up_ref(EVP_KDF *kdf);
29 void EVP_KDF_free(EVP_KDF *kdf);
30 EVP_KDF *EVP_KDF_fetch(OPENSSL_CTX *libctx, const char *algorithm,
31 const char *properties);
506cb0f6 32 int EVP_KDF_number(const EVP_KDF *kdf);
251e610c
RL
33 int EVP_KDF_is_a(const EVP_KDF *kdf, const char *name);
34 const OSSL_PROVIDER *EVP_KDF_provider(const EVP_KDF *kdf);
35 void EVP_KDF_do_all_provided(OPENSSL_CTX *libctx,
36 void (*fn)(EVP_KDF *kdf, void *arg),
37 void *arg);
f651c727
RL
38 void EVP_KDF_names_do_all(const EVP_KDF *kdf,
39 void (*fn)(const char *name, void *data),
40 void *data);
65ce7e65 41 int EVP_KDF_get_params(EVP_KDF *kdf, OSSL_PARAM params[]);
765d04c9
P
42 int EVP_KDF_get_ctx_params(EVP_KDF_CTX *ctx, OSSL_PARAM params[]);
43 int EVP_KDF_set_ctx_params(EVP_KDF_CTX *ctx, const OSSL_PARAM params[]);
65ce7e65 44 const OSSL_PARAM *EVP_KDF_gettable_params(const EVP_KDF *kdf);
41f7ecf3
P
45 const OSSL_PARAM *EVP_KDF_gettable_ctx_params(const EVP_KDF *kdf);
46 const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf);
65ce7e65
P
47 const OSSL_PROVIDER *EVP_KDF_provider(const EVP_KDF *kdf);
48
49=head1 DESCRIPTION
50
8c1cbc72 51The EVP KDF routines are a high-level interface to Key Derivation Function
65ce7e65
P
52algorithms and should be used instead of algorithm-specific functions.
53
54After creating a B<EVP_KDF_CTX> for the required algorithm using
765d04c9
P
55EVP_KDF_new_ctx(), inputs to the algorithm are supplied
56using calls to EVP_KDF_set_ctx_params() before
65ce7e65
P
57calling EVP_KDF_derive() to derive the key.
58
59=head2 Types
60
61B<EVP_KDF> is a type that holds the implementation of a KDF.
62
63B<EVP_KDF_CTX> is a context type that holds the algorithm inputs.
64
65=head2 Algorithm implementation fetching
66
67EVP_KDF_fetch() fetches an implementation of a KDF I<algorithm>, given
68a library context I<libctx> and a set of I<properties>.
69See L<provider(7)/Fetching algorithms> for further information.
70
b8086652
SL
71See L<OSSL_PROVIDER-default(7)/Key Derivation Function (KDF)> for the lists of
72algorithms supported by the default provider.
73
65ce7e65
P
74The returned value must eventually be freed with
75L<EVP_KDF_free(3)>.
76
77EVP_KDF_up_ref() increments the reference count of an already fetched
78KDF.
79
80EVP_KDF_free() frees a fetched algorithm.
81NULL is a valid parameter, for which this function is a no-op.
82
83=head2 Context manipulation functions
84
765d04c9 85EVP_KDF_new_ctx() creates a new context for the KDF implementation I<kdf>.
65ce7e65 86
765d04c9 87EVP_KDF_free_ctx() frees up the context I<ctx>. If I<ctx> is NULL, nothing
65ce7e65
P
88is done.
89
765d04c9 90EVP_KDF_get_ctx_kdf() returns the B<EVP_KDF> associated with the context
65ce7e65
P
91I<ctx>.
92
93=head2 Computing functions
94
95EVP_KDF_reset() resets the context to the default state as if the context
96had just been created.
97
ee2161e8 98EVP_KDF_derive() derives I<keylen> bytes of key material and places it in the
65ce7e65 99I<key> buffer. If the algorithm produces a fixed amount of output then an
ee2161e8 100error will occur unless the I<keylen> parameter is equal to that output size,
65ce7e65
P
101as returned by EVP_KDF_size().
102
103EVP_KDF_get_params() retrieves details about the implementation
104I<kdf>.
105The set of parameters given with I<params> determine exactly what
106parameters should be retrieved.
107Note that a parameter that is unknown in the underlying context is
108simply ignored.
109
765d04c9 110EVP_KDF_get_ctx_params() retrieves chosen parameters, given the
65ce7e65
P
111context I<ctx> and its underlying context.
112The set of parameters given with I<params> determine exactly what
113parameters should be retrieved.
114Note that a parameter that is unknown in the underlying context is
115simply ignored.
116
765d04c9 117EVP_KDF_set_ctx_params() passes chosen parameters to the underlying
65ce7e65
P
118context, given a context I<ctx>.
119The set of parameters given with I<params> determine exactly what
120parameters are passed down.
121Note that a parameter that is unknown in the underlying context is
122simply ignored.
123Also, what happens when a needed parameter isn't passed down is
124defined by the implementation.
125
41f7ecf3
P
126EVP_KDF_gettable_params(), EVP_KDF_gettable_ctx_params() and
127EVP_KDF_settable_ctx_params() get a constant B<OSSL_PARAM> array that
79c44b4e 128describes the retrievable and settable parameters, i.e. parameters that
765d04c9
P
129can be used with EVP_KDF_get_params(), EVP_KDF_get_ctx_params()
130and EVP_KDF_set_ctx_params(), respectively.
65ce7e65
P
131See L<OSSL_PARAM(3)> for the use of B<OSSL_PARAM> as parameter descriptor.
132
133=head2 Information functions
134
135EVP_KDF_size() returns the output size if the algorithm produces a fixed amount
136of output and B<SIZE_MAX> otherwise. If an error occurs then 0 is returned.
137For some algorithms an error may result if input parameters necessary to
138calculate a fixed output size have not yet been supplied.
139
251e610c
RL
140EVP_KDF_is_a() returns 1 if I<kdf> is an implementation of an
141algorithm that's identifiable with I<name>, otherwise 0.
142
65ce7e65
P
143EVP_KDF_provider() returns the provider that holds the implementation
144of the given I<kdf>.
145
251e610c 146EVP_KDF_do_all_provided() traverses all KDF implemented by all activated
65ce7e65
P
147providers in the given library context I<libctx>, and for each of the
148implementations, calls the given function I<fn> with the implementation method
149and the given I<arg> as argument.
150
506cb0f6
RL
151EVP_KDF_number() returns the internal dynamic number assigned to
152I<kdf>.
153
f651c727
RL
154EVP_KDF_names_do_all() traverses all names for I<kdf>, and calls
155I<fn> with each name and I<data>.
156
b1cabee8 157=head1 PARAMETERS
65ce7e65
P
158
159The standard parameter names are:
160
161=over 4
162
0c452a51 163=item "pass" (B<OSSL_KDF_PARAM_PASSWORD>) <octet string>
65ce7e65
P
164
165Some KDF implementations require a password.
166For those KDF implementations that support it, this parameter sets the password.
167
0c452a51 168=item "salt" (B<OSSL_KDF_PARAM_SALT>) <octet string>
65ce7e65
P
169
170Some KDF implementations can take a salt.
171For those KDF implementations that support it, this parameter sets the salt.
172
173The default value, if any, is implementation dependent.
174
0c452a51 175=item "iter" (B<OSSL_KDF_PARAM_ITER>) <unsigned integer>
65ce7e65
P
176
177Some KDF implementations require an iteration count.
178For those KDF implementations that support it, this parameter sets the
179iteration count.
180
181The default value, if any, is implementation dependent.
182
0c452a51 183=item "properties" (B<OSSL_KDF_PARAM_PROPERTIES>) <UTF8 string>
65ce7e65 184
0c452a51 185=item "mac" (B<OSSL_KDF_PARAM_MAC>) <UTF8 string>
65ce7e65 186
0c452a51 187=item "digest" (B<OSSL_KDF_PARAM_DIGEST>) <UTF8 string>
65ce7e65 188
33f54da3
SS
189=item "cipher" (B<OSSL_KDF_PARAM_CIPHER>) <UTF8 string>
190
191For KDF implementations that use an underlying computation MAC, digest or
192cipher, these parameters set what the algorithm should be.
c69561de 193
9bd9c440 194The value is always the name of the intended algorithm,
c69561de
P
195or the properties.
196
197Note that not all algorithms may support all possible underlying
198implementations.
65ce7e65 199
0c452a51 200=item "key" (B<OSSL_KDF_PARAM_KEY>) <octet string>
65ce7e65
P
201
202Some KDF implementations require a key.
203For those KDF implementations that support it, this octet string parameter
204sets the key.
205
0c452a51 206=item "maclen" (B<OSSL_KDF_PARAM_MAC_SIZE>) <unsigned integer>
65ce7e65
P
207
208Used by implementations that use a MAC with a variable output size (KMAC).
209For those KDF implementations that support it, this parameter
210sets the MAC output size.
211
212The default value, if any, is implementation dependent.
f4651268 213The length must never exceed what can be given with a B<size_t>.
65ce7e65 214
0c452a51 215=item "maxmem_bytes" (B<OSSL_KDF_PARAM_SCRYPT_MAXMEM>) <unsigned integer>
65ce7e65
P
216
217Memory-hard password-based KDF algorithms, such as scrypt, use an amount of
218memory that depends on the load factors provided as input.
560ac83b 219For those KDF implementations that support it, this B<uint64_t> parameter sets
65ce7e65
P
220an upper limit on the amount of memory that may be consumed while performing
221a key derivation.
222If this memory usage limit is exceeded because the load factors are chosen
223too high, the key derivation will fail.
224
225The default value is implementation dependent.
f4651268 226The memory size must never exceed what can be given with a B<size_t>.
65ce7e65
P
227
228=back
229
230=head1 RETURN VALUES
231
ee2161e8 232EVP_KDF_fetch() returns a pointer to a newly fetched B<EVP_KDF>, or
65ce7e65
P
233NULL if allocation failed.
234
65ce7e65
P
235EVP_KDF_provider() returns a pointer to the provider for the KDF, or
236NULL on error.
237
ee2161e8 238EVP_KDF_up_ref() returns 1 on success, 0 on error.
65ce7e65 239
765d04c9 240EVP_KDF_new_ctx() returns either the newly allocated
ee2161e8 241B<EVP_KDF_CTX> structure or NULL if an error occurred.
65ce7e65 242
765d04c9 243EVP_KDF_free_ctx() and EVP_KDF_reset() do not return a value.
65ce7e65 244
ee2161e8 245EVP_KDF_size() returns the output size. B<SIZE_MAX> is returned to indicate
65ce7e65
P
246that the algorithm produces a variable amount of output; 0 to indicate failure.
247
248The remaining functions return 1 for success and 0 or a negative value for
249failure. In particular, a return value of -2 indicates the operation is not
250supported by the KDF algorithm.
251
252=head1 SEE ALSO
253
b8086652 254L<OSSL_PROVIDER-default(7)/Key Derivation Function (KDF)>
65ce7e65
P
255
256=head1 HISTORY
257
258This functionality was added to OpenSSL 3.0.
259
260=head1 COPYRIGHT
261
00c405b3 262Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
65ce7e65
P
263
264Licensed under the Apache License 2.0 (the "License"). You may not use
265this file except in compliance with the License. You can obtain a copy
266in the file LICENSE in the source distribution or at
267L<https://www.openssl.org/source/license.html>.
268
269=cut