1EVP_PKEY_CTX_SET_TLS1_PRF_MD(3ossl) OpenSSLEVP_PKEY_CTX_SET_TLS1_PRF_MD(3ossl)
2
3
4

NAME

6       EVP_PKEY_CTX_set_tls1_prf_md, EVP_PKEY_CTX_set1_tls1_prf_secret,
7       EVP_PKEY_CTX_add1_tls1_prf_seed - TLS PRF key derivation algorithm
8

SYNOPSIS

10        #include <openssl/kdf.h>
11
12        int EVP_PKEY_CTX_set_tls1_prf_md(EVP_PKEY_CTX *pctx, const EVP_MD *md);
13        int EVP_PKEY_CTX_set1_tls1_prf_secret(EVP_PKEY_CTX *pctx,
14                                              unsigned char *sec, int seclen);
15        int EVP_PKEY_CTX_add1_tls1_prf_seed(EVP_PKEY_CTX *pctx,
16                                            unsigned char *seed, int seedlen);
17

DESCRIPTION

19       The EVP_PKEY_TLS1_PRF algorithm implements the PRF key derivation
20       function for TLS. It has no associated private key and only implements
21       key derivation using EVP_PKEY_derive(3).
22
23       EVP_PKEY_set_tls1_prf_md() sets the message digest associated with the
24       TLS PRF. EVP_md5_sha1() is treated as a special case which uses the PRF
25       algorithm using both MD5 and SHA1 as used in TLS 1.0 and 1.1.
26
27       EVP_PKEY_CTX_set_tls1_prf_secret() sets the secret value of the TLS PRF
28       to seclen bytes of the buffer sec. Any existing secret value is
29       replaced and any seed is reset.
30
31       EVP_PKEY_CTX_add1_tls1_prf_seed() sets the seed to seedlen bytes of
32       seed.  If a seed is already set it is appended to the existing value.
33

STRING CTRLS

35       The TLS PRF also supports string based control operations using
36       EVP_PKEY_CTX_ctrl_str(3).  The type parameter "md" uses the supplied
37       value as the name of the digest algorithm to use.  The type parameters
38       "secret" and "seed" use the supplied value parameter as a secret or
39       seed value.  The names "hexsecret" and "hexseed" are similar except
40       they take a hex string which is converted to binary.
41

NOTES

43       A context for the TLS PRF can be obtained by calling:
44
45        EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
46
47       The digest, secret value and seed must be set before a key is derived
48       or an error occurs.
49
50       The total length of all seeds cannot exceed 1024 bytes in length: this
51       should be more than enough for any normal use of the TLS PRF.
52
53       The output length of the PRF is specified by the length parameter in
54       the EVP_PKEY_derive() function. Since the output length is variable,
55       setting the buffer to NULL is not meaningful for the TLS PRF.
56
57       Optimised versions of the TLS PRF can be implemented in an ENGINE.
58

RETURN VALUES

60       All these functions return 1 for success and 0 or a negative value for
61       failure.  In particular a return value of -2 indicates the operation is
62       not supported by the public key algorithm.
63

EXAMPLES

65       This example derives 10 bytes using SHA-256 with the secret key
66       "secret" and seed value "seed":
67
68        EVP_PKEY_CTX *pctx;
69        unsigned char out[10];
70        size_t outlen = sizeof(out);
71
72        pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
73        if (EVP_PKEY_derive_init(pctx) <= 0)
74            /* Error */
75        if (EVP_PKEY_CTX_set_tls1_prf_md(pctx, EVP_sha256()) <= 0)
76            /* Error */
77        if (EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, "secret", 6) <= 0)
78            /* Error */
79        if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, "seed", 4) <= 0)
80            /* Error */
81        if (EVP_PKEY_derive(pctx, out, &outlen) <= 0)
82            /* Error */
83

SEE ALSO

85       EVP_PKEY_CTX_new(3), EVP_PKEY_CTX_ctrl_str(3), EVP_PKEY_derive(3)
86

HISTORY

88       All of the functions described here were converted from macros to
89       functions in OpenSSL 3.0.
90
92       Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
93
94       Licensed under the Apache License 2.0 (the "License").  You may not use
95       this file except in compliance with the License.  You can obtain a copy
96       in the file LICENSE in the source distribution or at
97       <https://www.openssl.org/source/license.html>.
98
99
100
1013.0.5                             2022-07-05EVP_PKEY_CTX_SET_TLS1_PRF_MD(3ossl)
Impressum