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 or HMAC.
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.
55
56       The parameters key, salt, info, and seed correspond to KI, Label,
57       Context, and IV (respectively) in SP800-108.  As in that document,
58       salt, info, and seed are optional and may be omitted.
59
60       "mac", "digest", cipher" and "properties" are described in "PARAMETERS"
61       in EVP_KDF(3).
62

NOTES

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

EXAMPLES

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

CONFORMING TO

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

SEE ALSO

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

HISTORY

142       This functionality was added to OpenSSL 3.0.
143
145       Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
146       Copyright 2019 Red Hat, Inc.
147
148       Licensed under the Apache License 2.0 (the "License").  You may not use
149       this file except in compliance with the License.  You can obtain a copy
150       in the file LICENSE in the source distribution or at
151       <https://www.openssl.org/source/license.html>.
152
153
154
1553.0.5                             2022-07-05                 EVP_KDF-KB(7ossl)
Impressum