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