Make BIGNUM rand functions available within the FIPS module
[openssl.git] / doc / man7 / EVP_KDF_TLS1_PRF.pod
1 =pod
2
3 =head1 NAME
4
5 EVP_KDF_TLS1_PRF - The TLS1 PRF EVP_KDF implementation
6
7 =head1 DESCRIPTION
8
9 Support for computing the B<TLS1> PRF through the B<EVP_KDF> API.
10
11 The EVP_KDF_TLS1_PRF algorithm implements the PRF used by TLS versions up to
12 and including TLS 1.2.
13
14 =head2 Numeric identity
15
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.
18
19 =head2 Supported controls
20
21 The supported controls are:
22
23 =over 4
24
25 =item B<EVP_KDF_CTRL_SET_MD>
26
27 This control works as described in L<EVP_KDF_CTX(3)/CONTROLS>.
28
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.
32
33 =item B<EVP_KDF_CTRL_SET_TLS_SECRET>
34
35 This control expects two arguments: C<unsigned char *sec>, C<size_t seclen>
36
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.
39
40 EVP_KDF_ctrl_str() takes two type strings for this control:
41
42 =over 4
43
44 =item "secret"
45
46 The value string is used as is.
47
48 =item "hexsecret"
49
50 The value string is expected to be a hexadecimal number, which will be
51 decoded before being passed on as the control value.
52
53 =back
54
55 =item B<EVP_KDF_CTRL_RESET_TLS_SEED>
56
57 This control does not expect any arguments.
58
59 Resets the context seed buffer to zero length.
60
61 =item B<EVP_KDF_CTRL_ADD_TLS_SEED>
62
63 This control expects two arguments: C<unsigned char *seed>, C<size_t seedlen>
64
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.
67
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.
70
71 EVP_KDF_ctrl_str() takes two type strings for this control:
72
73 =over 4
74
75 =item "seed"
76
77 The value string is used as is.
78
79 =item "hexseed"
80
81 The value string is expected to be a hexadecimal number, which will be
82 decoded before being passed on as the control value.
83
84 =back
85
86 =back
87
88 =head1 NOTES
89
90 A context for the TLS PRF can be obtained by calling:
91
92  EVP_KDF_CTX *kctx = EVP_KDF_CTX_new_id(EVP_KDF_TLS1_PRF, NULL);
93
94 The digest, secret value and seed must be set before a key is derived otherwise
95 an error will occur.
96
97 The output length of the PRF is specified by the C<keylen> parameter to the
98 EVP_KDF_derive() function.
99
100 =head1 EXAMPLE
101
102 This example derives 10 bytes using SHA-256 with the secret key "secret"
103 and seed value "seed":
104
105  EVP_KDF_CTX *kctx;
106  unsigned char out[10];
107
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");
111  }
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");
115  }
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");
118  }
119  if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
120      error("EVP_KDF_derive");
121  }
122  EVP_KDF_CTX_free(kctx);
123
124 =head1 CONFORMING TO
125
126 RFC 2246, RFC 5246 and NIST SP 800-135 r1
127
128 =head1 SEE ALSO
129
130 L<EVP_KDF_CTX>,
131 L<EVP_KDF_CTX_new_id(3)>,
132 L<EVP_KDF_CTX_free(3)>,
133 L<EVP_KDF_ctrl(3)>,
134 L<EVP_KDF_derive(3)>,
135 L<EVP_KDF_CTX(3)/CONTROLS>
136
137 =head1 COPYRIGHT
138
139 Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
140
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>.
145
146 =cut