kdf: make function naming consistent.
[openssl.git] / doc / man7 / EVP_KDF-KRB5KDF.pod
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_new_ctx(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_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_new_ctx(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_set_params(kctx, params) <= 0)
85      /* Error */
86
87  if (EVP_KDF_derive(kctx, out, outlen) <= 0)
88      /* Error */
89
90  EVP_KDF_free_ctx(kctx);
91
92 =head1 CONFORMING TO
93
94 RFC 3961
95
96 =head1 SEE ALSO
97
98 L<EVP_KDF(3)>,
99 L<EVP_KDF_free_ctx(3)>,
100 L<EVP_KDF_ctrl(3)>,
101 L<EVP_KDF_size(3)>,
102 L<EVP_KDF_derive(3)>,
103 L<EVP_KDF(3)/PARAMETERS>
104
105 =head1 HISTORY
106
107 This functionality was added to OpenSSL 3.0.
108
109 =head1 COPYRIGHT
110
111 Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
112
113 Licensed under the Apache License 2.0 (the "License").  You may not use
114 this file except in compliance with the License.  You can obtain a copy
115 in the file LICENSE in the source distribution or at
116 L<https://www.openssl.org/source/license.html>.
117
118 =cut
119