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

RETURN VALUES

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

EXAMPLES

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

SEE ALSO

87       EVP_PKEY_CTX_new(3), EVP_PKEY_CTX_ctrl_str(3), EVP_PKEY_derive(3)
88
90       Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
91
92       Licensed under the OpenSSL license (the "License").  You may not use
93       this file except in compliance with the License.  You can obtain a copy
94       in the file LICENSE in the source distribution or at
95       <https://www.openssl.org/source/license.html>.
96
97
98
991.1.1q                            2022-07-07   EVP_PKEY_CTX_SET_TLS1_PRF_MD(3)
Impressum