5 EVP_KDF_TLS1_PRF - The TLS1 PRF EVP_KDF implementation
9 Support for computing the B<TLS1> PRF through the B<EVP_KDF> API.
11 The EVP_KDF_TLS1_PRF algorithm implements the PRF used by TLS versions up to
12 and including TLS 1.2.
14 =head2 Numeric identity
16 B<EVP_KDF_TLS1_PRF> is the numeric identity for this implementation; it
17 can be used with the EVP_KDF_CTX_new_id() function.
19 =head2 Supported controls
21 The supported controls are:
25 =item B<EVP_KDF_CTRL_SET_MD>
27 This control works as described in L<EVP_KDF_CTX(3)/CONTROLS>.
29 The C<EVP_KDF_CTRL_SET_MD> control is used to set the message digest associated
30 with the TLS PRF. EVP_md5_sha1() is treated as a special case which uses the
31 PRF algorithm using both B<MD5> and B<SHA1> as used in TLS 1.0 and 1.1.
33 =item B<EVP_KDF_CTRL_SET_TLS_SECRET>
35 This control expects two arguments: C<unsigned char *sec>, C<size_t seclen>
37 Sets the secret value of the TLS PRF to B<seclen> bytes of the buffer B<sec>.
38 Any existing secret value is replaced.
40 EVP_KDF_ctrl_str() takes two type strings for this control:
46 The value string is used as is.
50 The value string is expected to be a hexadecimal number, which will be
51 decoded before being passed on as the control value.
55 =item B<EVP_KDF_CTRL_RESET_TLS_SEED>
57 This control does not expect any arguments.
59 Resets the context seed buffer to zero length.
61 =item B<EVP_KDF_CTRL_ADD_TLS_SEED>
63 This control expects two arguments: C<unsigned char *seed>, C<size_t seedlen>
65 Sets the seed to B<seedlen> bytes of B<seed>. If a seed is already set it is
66 appended to the existing value.
68 The total length of the context seed buffer cannot exceed 1024 bytes;
69 this should be more than enough for any normal use of the TLS PRF.
71 EVP_KDF_ctrl_str() takes two type strings for this control:
77 The value string is used as is.
81 The value string is expected to be a hexadecimal number, which will be
82 decoded before being passed on as the control value.
90 A context for the TLS PRF can be obtained by calling:
92 EVP_KDF_CTX *kctx = EVP_KDF_CTX_new_id(EVP_KDF_TLS1_PRF, NULL);
94 The digest, secret value and seed must be set before a key is derived otherwise
97 The output length of the PRF is specified by the C<keylen> parameter to the
98 EVP_KDF_derive() function.
102 This example derives 10 bytes using SHA-256 with the secret key "secret"
103 and seed value "seed":
106 unsigned char out[10];
108 kctx = EVP_KDF_CTX_new_id(EVP_KDF_TLS1_PRF);
109 if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()) <= 0) {
110 error("EVP_KDF_CTRL_SET_MD");
112 if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_TLS_SECRET,
113 "secret", (size_t)6) <= 0) {
114 error("EVP_KDF_CTRL_SET_TLS_SECRET");
116 if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_ADD_TLS_SEED, "seed", (size_t)4) <= 0) {
117 error("EVP_KDF_CTRL_ADD_TLS_SEED");
119 if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
120 error("EVP_KDF_derive");
122 EVP_KDF_CTX_free(kctx);
126 RFC 2246, RFC 5246 and NIST SP 800-135 r1
131 L<EVP_KDF_CTX_new_id(3)>,
132 L<EVP_KDF_CTX_free(3)>,
134 L<EVP_KDF_derive(3)>,
135 L<EVP_KDF_CTX(3)/CONTROLS>
139 Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
141 Licensed under the Apache License 2.0 (the "License"). You may not use
142 this file except in compliance with the License. You can obtain a copy
143 in the file LICENSE in the source distribution or at
144 L<https://www.openssl.org/source/license.html>.