1EVP_KDF-KRB5KDF(7ossl) OpenSSL EVP_KDF-KRB5KDF(7ossl)
2
3
4
6 EVP_KDF-KRB5KDF - The RFC3961 Krb5 KDF EVP_KDF implementation
7
9 Support for computing the KRB5KDF KDF through the EVP_KDF API.
10
11 The EVP_KDF-KRB5KDF algorithm implements the key derivation function
12 defined in RFC 3961, section 5.1 and is used by Krb5 to derive session
13 keys. Three inputs are required to perform key derivation: a cipher,
14 (for example AES-128-CBC), the initial key, and a constant.
15
16 Identity
17 "KRB5KDF" is the name for this implementation; it can be used with the
18 EVP_KDF_fetch() function.
19
20 Supported parameters
21 The supported parameters are:
22
23 "properties" (OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>
24 "cipher" (OSSL_KDF_PARAM_CIPHER) <UTF8 string>
25 "key" (OSSL_KDF_PARAM_KEY) <octet string>
26 These parameters work as described in "PARAMETERS" in EVP_KDF(3).
27
28 "constant" (OSSL_KDF_PARAM_CONSTANT) <octet string>
29 This parameter sets the constant value for the KDF. If a value is
30 already set, the contents are replaced.
31
33 A context for KRB5KDF can be obtained by calling:
34
35 EVP_KDF *kdf = EVP_KDF_fetch(NULL, "KRB5KDF", NULL);
36 EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
37
38 The output length of the KRB5KDF derivation is specified via the keylen
39 parameter to the EVP_KDF_derive(3) function, and MUST match the key
40 length for the chosen cipher or an error is returned. Moreover, the
41 constant's length must not exceed the block size of the cipher. Since
42 the KRB5KDF output length depends on the chosen cipher, calling
43 EVP_KDF_CTX_get_kdf_size(3) to obtain the requisite length returns the
44 correct length only after the cipher is set. Prior to that
45 EVP_MAX_KEY_LENGTH is returned. The caller must allocate a buffer of
46 the correct length for the chosen cipher, and pass that buffer to the
47 EVP_KDF_derive(3) function along with that length.
48
50 This example derives a key using the AES-128-CBC cipher:
51
52 EVP_KDF *kdf;
53 EVP_KDF_CTX *kctx;
54 unsigned char key[16] = "01234...";
55 unsigned char constant[] = "I'm a constant";
56 unsigned char out[16];
57 size_t outlen = sizeof(out);
58 OSSL_PARAM params[4], *p = params;
59
60 kdf = EVP_KDF_fetch(NULL, "KRB5KDF", NULL);
61 kctx = EVP_KDF_CTX_new(kdf);
62 EVP_KDF_free(kdf);
63
64 *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_CIPHER,
65 SN_aes_128_cbc,
66 strlen(SN_aes_128_cbc));
67 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
68 key, (size_t)16);
69 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_CONSTANT,
70 constant, strlen(constant));
71 *p = OSSL_PARAM_construct_end();
72 if (EVP_KDF_derive(kctx, out, outlen, params) <= 0)
73 /* Error */
74
75 EVP_KDF_CTX_free(kctx);
76
78 RFC 3961
79
81 EVP_KDF(3), EVP_KDF_CTX_free(3), EVP_KDF_CTX_get_kdf_size(3),
82 EVP_KDF_derive(3), "PARAMETERS" in EVP_KDF(3)
83
85 This functionality was added to OpenSSL 3.0.
86
88 Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
89
90 Licensed under the Apache License 2.0 (the "License"). You may not use
91 this file except in compliance with the License. You can obtain a copy
92 in the file LICENSE in the source distribution or at
93 <https://www.openssl.org/source/license.html>.
94
95
96
973.0.5 2022-11-01 EVP_KDF-KRB5KDF(7ossl)