1EVP_KDF-KB(7ossl)                   OpenSSL                  EVP_KDF-KB(7ossl)
2
3
4

NAME

6       EVP_KDF-KB - The Key-Based EVP_KDF implementation
7

DESCRIPTION

9       The EVP_KDF-KB algorithm implements the Key-Based key derivation
10       function (KBKDF).  KBKDF derives a key from repeated application of a
11       keyed MAC to an input secret (and other optional values).
12
13   Identity
14       "KBKDF" is the name for this implementation; it can be used with the
15       EVP_KDF_fetch() function.
16
17   Supported parameters
18       The supported parameters are:
19
20       "mode" (OSSL_KDF_PARAM_MODE) <UTF8 string>
21           The mode parameter determines which flavor of KBKDF to use -
22           currently the choices are "counter" and "feedback". "counter" is
23           the default, and will be used if unspecified.
24
25       "mac" (OSSL_KDF_PARAM_MAC) <UTF8 string>
26           The value is either CMAC, HMAC, KMAC128 or KMAC256.
27
28       "digest" (OSSL_KDF_PARAM_DIGEST) <UTF8 string>
29       "cipher" (OSSL_KDF_PARAM_CIPHER) <UTF8 string>
30       "properties" (OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>
31       "key" (OSSL_KDF_PARAM_KEY) <octet string>
32       "salt" (OSSL_KDF_PARAM_SALT) <octet string>
33       "info (OSSL_KDF_PARAM_INFO) <octet string>
34       "seed" (OSSL_KDF_PARAM_SEED) <octet string>
35           The seed parameter is unused in counter mode.
36
37       "use-l" (OSSL_KDF_PARAM_KBKDF_USE_L) <integer>
38           Set to 0 to disable use of the optional Fixed Input data 'L' (see
39           SP800-108).  The default value of 1 will be used if unspecified.
40
41       "use-separator" (OSSL_KDF_PARAM_KBKDF_USE_SEPARATOR) <integer>
42           Set to 0 to disable use of the optional Fixed Input data 'zero
43           separator' (see SP800-108) that is placed between the Label and
44           Context.  The default value of 1 will be used if unspecified.
45
46       "r" (OSSL_KDF_PARAM_KBKDF_R) <integer>
47           Set the fixed value 'r', indicating the length of the counter in
48           bits.
49
50           Supported values are 8, 16, 24, and 32.  The default value of 32
51           will be used if unspecified.
52
53       Depending on whether mac is CMAC or HMAC, either digest or cipher is
54       required (respectively) and the other is unused. They are unused for
55       KMAC128 and KMAC256.
56
57       The parameters key, salt, info, and seed correspond to KI, Label,
58       Context, and IV (respectively) in SP800-108.  As in that document,
59       salt, info, and seed are optional and may be omitted.
60
61       "mac", "digest", cipher" and "properties" are described in "PARAMETERS"
62       in EVP_KDF(3).
63

NOTES

65       A context for KBKDF can be obtained by calling:
66
67        EVP_KDF *kdf = EVP_KDF_fetch(NULL, "KBKDF", NULL);
68        EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
69
70       The output length of an KBKDF is specified via the "keylen" parameter
71       to the EVP_KDF_derive(3) function.
72
73       Note that currently OpenSSL only implements counter and feedback modes.
74       Other variants may be supported in the future.
75

EXAMPLES

77       This example derives 10 bytes using COUNTER-HMAC-SHA256, with KI
78       "secret", Label "label", and Context "context".
79
80        EVP_KDF *kdf;
81        EVP_KDF_CTX *kctx;
82        unsigned char out[10];
83        OSSL_PARAM params[6], *p = params;
84
85        kdf = EVP_KDF_fetch(NULL, "KBKDF", NULL);
86        kctx = EVP_KDF_CTX_new(kdf);
87        EVP_KDF_free(kdf);
88
89        *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
90                                                "SHA2-256", 0);
91        *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC,
92                                                "HMAC", 0);
93        *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
94                                                 "secret", strlen("secret"));
95        *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
96                                                 "label", strlen("label"));
97        *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
98                                                 "context", strlen("context"));
99        *p = OSSL_PARAM_construct_end();
100        if (EVP_KDF_derive(kctx, out, sizeof(out), params) <= 0)
101            error("EVP_KDF_derive");
102
103        EVP_KDF_CTX_free(kctx);
104
105       This example derives 10 bytes using FEEDBACK-CMAC-AES256, with KI
106       "secret", Label "label", and IV "sixteen bytes iv".
107
108        EVP_KDF *kdf;
109        EVP_KDF_CTX *kctx;
110        unsigned char out[10];
111        OSSL_PARAM params[8], *p = params;
112        unsigned char *iv = "sixteen bytes iv";
113
114        kdf = EVP_KDF_fetch(NULL, "KBKDF", NULL);
115        kctx = EVP_KDF_CTX_new(kdf);
116        EVP_KDF_free(kdf);
117
118        *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_CIPHER, "AES256", 0);
119        *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC, "CMAC", 0);
120        *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MODE, "FEEDBACK", 0);
121        *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
122                                                 "secret", strlen("secret"));
123        *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
124                                                 "label", strlen("label"));
125        *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
126                                                 "context", strlen("context"));
127        *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
128                                                 iv, strlen(iv));
129        *p = OSSL_PARAM_construct_end();
130        if (EVP_KDF_derive(kctx, out, sizeof(out), params) <= 0)
131            error("EVP_KDF_derive");
132
133        EVP_KDF_CTX_free(kctx);
134

CONFORMING TO

136       NIST SP800-108, IETF RFC 6803, IETF RFC 8009.
137

SEE ALSO

139       EVP_KDF(3), EVP_KDF_CTX_free(3), EVP_KDF_CTX_get_kdf_size(3),
140       EVP_KDF_derive(3), "PARAMETERS" in EVP_KDF(3)
141

HISTORY

143       This functionality was added in OpenSSL 3.0.
144
145       Support for KMAC was added in OpenSSL 3.1.
146
148       Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
149       Copyright 2019 Red Hat, Inc.
150
151       Licensed under the Apache License 2.0 (the "License").  You may not use
152       this file except in compliance with the License.  You can obtain a copy
153       in the file LICENSE in the source distribution or at
154       <https://www.openssl.org/source/license.html>.
155
156
157
1583.1.1                             2023-08-31                 EVP_KDF-KB(7ossl)
Impressum