EVP_PKEY_CTX_SET_TLS1_PRF_MD(3ossl)
๐ NAME ๐
Okay bestie, welcome to the EVP_PKEY_CTX_SET_TLS1_PRF_MD(3ossl) page from OpenSSL โ this is the whole vibe guide for the TLS PRF key derivation algorithm. The main characters are EVP_PKEY_CTX_set_tls1_prf_md, EVP_PKEY_CTX_set1_tls1_prf_secret, and EVP_PKEY_CTX_add1_tls1_prf_seed. โจ
๐ SYNOPSIS ๐
#include <openssl/kdf.h>
int EVP_PKEY_CTX_set_tls1_prf_md(EVP_PKEY_CTX *pctx, const EVP_MD *md);
int EVP_PKEY_CTX_set1_tls1_prf_secret(EVP_PKEY_CTX *pctx,
unsigned char *sec, int seclen);
int EVP_PKEY_CTX_add1_tls1_prf_seed(EVP_PKEY_CTX *pctx,
unsigned char *seed, int seedlen);
๐ธ DESCRIPTION ๐ธ
The EVP_PKEY_TLS1_PRF algorithm implements the PRF key derivation function for TLS. It has no associated private key, and it only implements key derivation using EVP_PKEY_derive(3). ๐
EVP_PKEY_set_tls1_prf_md()โ sets the message digest associated with the TLS PRF.EVP_md5_sha1()is treated as a special case which uses the PRF algorithm using both MD5 and SHA1 as used in TLS 1.0 and 1.1. ๐EVP_PKEY_CTX_set_tls1_prf_secret()โ sets the secret value of the TLS PRF toseclenbytes of the buffersec. Any existing secret value is replaced and any seed is reset. ๐ซถEVP_PKEY_CTX_add1_tls1_prf_seed()โ sets the seed toseedlenbytes ofseed. If a seed is already set it is appended to the existing value. ๐ฑ
๐ฎ STRING CTRLS ๐ฎ
The TLS PRF also supports string based control operations using EVP_PKEY_CTX_ctrl_str(3). Hereโs the ctrl-str tea, bestie: โ
- The type parameter
"md"uses the supplied value as the name of the digest algorithm to use. - The type parameters
"secret"and"seed"use the supplied value parameter as a secret or seed value. - The names
"hexsecret"and"hexseed"are similar except they take a hex string which is converted to binary. ๐ง
๐ง NOTES ๐ง
A context for the TLS PRF can be obtained by calling:
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
The digest, secret value and seed must be set before a key is derived or an error occurs. No skip-the-line energy here, okay? ๐ญ
The total length of all seeds cannot exceed 1024 bytes in length: this should be more than enough for any normal use of the TLS PRF. ๐
The output length of the PRF is specified by the length parameter in the EVP_PKEY_derive() function. Since the output length is variable, setting the buffer to NULL is not meaningful for the TLS PRF. ๐ฆ
Optimised versions of the TLS PRF can be implemented in an ENGINE. โ๏ธโจ
๐ซถ RETURN VALUES ๐ซถ
All these functions return 1 for success and 0 or a negative value for failure. In particular a return value of -2 indicates the operation is not supported by the public key algorithm. Periodt. ๐
๐ EXAMPLES ๐
This example derives 10 bytes using SHA-256 with the secret key "secret" and seed value "seed":
EVP_PKEY_CTX *pctx;
unsigned char out[10];
size_t outlen = sizeof(out);
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
if (EVP_PKEY_derive_init(pctx) <= 0)
/* Error */
if (EVP_PKEY_CTX_set_tls1_prf_md(pctx, EVP_sha256()) <= 0)
/* Error */
if (EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, "secret", 6) <= 0)
/* Error */
if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, "seed", 4) <= 0)
/* Error */
if (EVP_PKEY_derive(pctx, out, &outlen) <= 0)
/* Error */
๐ SEE ALSO ๐
๐ HISTORY ๐
All of the functions described here were converted from macros to functions in OpenSSL 3.0. Character development, honestly. ๐
๐ COPYRIGHT ๐
Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
โจ Source/version/date vibe check: OpenSSL 3.5.0, dated 2026-09-2 โ bye bestie, mwah! ๐๐
๐ฆ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 ยท Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms