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.
16 "TLS1-PRF" is the name for this implementation; it
17 can be used with the EVP_KDF_fetch() function.
19 =head2 Supported parameters
21 The supported parameters are:
25 =item B<OSSL_KDF_PARAM_PROPERTIES> ("properties") <UTF8 string>
27 =item B<OSSL_KDF_PARAM_DIGEST> ("digest") <UTF8 string>
29 These parameters work as described in L<EVP_KDF(3)/PARAMETERS>.
31 The C<OSSL_KDF_PARAM_DIGEST> parameter is used to set the message digest
32 associated with the TLS PRF.
33 EVP_md5_sha1() is treated as a special case which uses the
34 PRF algorithm using both B<MD5> and B<SHA1> as used in TLS 1.0 and 1.1.
36 =item B<OSSL_KDF_PARAM_SECRET> ("secret") <octet string>
38 This parameter sets the secret value of the TLS PRF.
39 Any existing secret value is replaced.
41 =item B<OSSL_KDF_PARAM_SEED> ("seed") <octet string>
43 This parameter sets the context seed.
44 The length of the context seed cannot exceed 1024 bytes;
45 this should be more than enough for any normal use of the TLS PRF.
51 A context for the TLS PRF can be obtained by calling:
53 EVP_KDF *kdf = EVP_KDF_fetch(NULL, "TLS1-PRF", NULL);
54 EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
56 The digest, secret value and seed must be set before a key is derived otherwise
59 The output length of the PRF is specified by the C<keylen> parameter to the
60 EVP_KDF_derive() function.
64 This example derives 10 bytes using SHA-256 with the secret key "secret"
65 and seed value "seed":
69 unsigned char out[10];
70 OSSL_PARAM params[4], *p = params;
72 kdf = EVP_KDF_fetch(NULL, "TLS1-PRF", NULL);
73 kctx = EVP_KDF_CTX_new(kdf);
76 *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
77 SN_sha256, strlen(SN_sha256));
78 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET,
80 *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
82 *p = OSSL_PARAM_construct_end();
83 if (EVP_KDF_set_params(kctx, params) <= 0) {
84 error("EVP_KDF_set_params");
86 if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
87 error("EVP_KDF_derive");
89 EVP_KDF_CTX_free(kctx);
93 RFC 2246, RFC 5246 and NIST SP 800-135 r1
98 L<EVP_KDF-CTX_new_id(3)>,
99 L<EVP_KDF-CTX_free(3)>,
101 L<EVP_KDF-derive(3)>,
102 L<EVP_KDF-CTX(3)/PARAMETERS>
106 Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved.
108 Licensed under the Apache License 2.0 (the "License"). You may not use
109 this file except in compliance with the License. You can obtain a copy
110 in the file LICENSE in the source distribution or at
111 L<https://www.openssl.org/source/license.html>.