EVP_KDF-TLS1_PRF(7ossl)
π EVP_KDF-TLS1_PRF(7ossl) π
okay so bestie, this is a page from the OpenSSL manual set β the section 7 one (that's the "misc / concepts" section, iykyk). Sit down, hydrate, and let's talk about the TLS1 PRF π§β¨
β¨ NAME β¨
EVP_KDF-TLS1_PRF β the whole entire TLS1 PRF EVP_KDF implementation, and yes it's as iconic as it sounds π
πΈ DESCRIPTION πΈ
So basically, this is support for computing the TLS1 PRF through the EVP_KDF API. That's the vibe. π¦
The EVP_KDF-TLS1_PRF algorithm implements the PRF used by TLS versions up to and including TLS 1.2. Not 1.3, bestie β up to and including 1.2, read it again π
The output is considered to be keying material. That's important, okay, don't just throw it around π
π Identity π
"TLS1-PRF" is the name for this implementation β that's the string you feed to the EVP_KDF_fetch() function. That's it. That's the name. Slay. π
π₯ Supported parameters π₯
K so here's what you can actually pass in, the supported parameters are:
"properties"(OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>"digest"(OSSL_KDF_PARAM_DIGEST) <UTF8 string>
These parameters work as described in "PARAMETERS" in EVP_KDF(3). Go read that if you need the full lore π
And about the digest one specifically: the OSSL_KDF_PARAM_DIGEST parameter is used to set the message digest associated with the TLS PRF. But here's the cute little special case β 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. Bestie it's giving legacy but it's also giving necessary π
"secret"(OSSL_KDF_PARAM_SECRET) <octet string>
This parameter sets the secret value of the TLS PRF. And listen β any existing secret value is replaced. Gone. Poof. Not merged, not appended. Replaced. π
"seed"(OSSL_KDF_PARAM_SEED) <octet string>
This parameter sets the context seed. Important caveat though: the length of the context seed cannot exceed 1024 bytes. But honestly that should be more than enough for any normal use of the TLS PRF, so like, breathe π«Ά
The OpenSSL FIPS provider also supports the following parameters β yes, these are extra, yes, they're FIPS-flavoured, no, you can't skip them π
"fips-indicator"(OSSL_KDF_PARAM_FIPS_APPROVED_INDICATOR) <integer>
A getter that returns 1 if the operation is FIPS approved, or 0 otherwise. You'd use this after calling EVP_KDF_derive. And it returns 0 if any "***-check" related parameter is set to 0 and the check fails. So like, it's snitching on the checks. Correct behaviour honestly π
"ems_check"(OSSL_KDF_PARAM_FIPS_EMS_CHECK) <integer>
The default value of 1 causes an error during EVP_KDF_derive() if "master secret" is used instead of "extended master secret". Setting this to zero will ignore the error and set the approved "fips-indicator" to 0. This option breaks FIPS compliance if it causes the approved "fips-indicator" to return 0. Like, that's the trade, bestie, choose wisely β
"digest-check"(OSSL_KDF_PARAM_FIPS_DIGEST_CHECK) <integer>
The default value of 1 causes an error during EVP_KDF_CTX_set_params() if used digest is not approved. Setting this to zero will ignore the error and set the approved "fips-indicator" to 0. Again: this option breaks FIPS compliance if it causes the approved "fips-indicator" to return 0. π
According to SP 800-135r1, the following are approved digest algorithms: SHA2-256, SHA2-384, SHA2-512. That's the whole approved list, no I will not be adding to it πΈ
"key-check"(OSSL_KDF_PARAM_FIPS_KEY_CHECK) <integer>
The default value of 1 causes an error during EVP_KDF_CTX_set_params() if the length of used key-derivation key (OSSL_KDF_PARAM_SECRET) is shorter than 112 bits. Setting this to zero will ignore the error and set the approved "fips-indicator" to 0. And yep, you guessed it: this option breaks FIPS compliance if it causes the approved "fips-indicator" to return 0. π
π¦ NOTES π¦
Want a context for the TLS PRF? Iconic. You get one by calling:
EVP_KDF *kdf = EVP_KDF_fetch(NULL, "TLS1-PRF", NULL);
EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
Now the serious part, no cap: the digest, secret value and seed must be set before a key is derived β otherwise an error will occur. All three. Before. Don't test me on this π
The output length of the PRF is specified by the keylen parameter to the EVP_KDF_derive() function. That's how you control how much keying material you get out. Periodt π
π EXAMPLES π
This example derives 10 bytes using SHA-256 with the secret key "secret" and seed value "seed" β truly the most self-documenting example ever written, we love a clear naming convention π
EVP_KDF *kdf;
EVP_KDF_CTX *kctx;
unsigned char out[10];
OSSL_PARAM params[4], *p = params;
kdf = EVP_KDF_fetch(NULL, "TLS1-PRF", NULL);
kctx = EVP_KDF_CTX_new(kdf);
EVP_KDF_free(kdf);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
SN_sha256, strlen(SN_sha256));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET,
"secret", (size_t)6);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
"seed", (size_t)4);
*p = OSSL_PARAM_construct_end();
if (EVP_KDF_derive(kctx, out, sizeof(out), params) <= 0) {
error("EVP_KDF_derive");
}
EVP_KDF_CTX_free(kctx);
(Notice the 4 in params[4]? Three params plus the end marker. Chef's kiss, the math is mathing π₯)
π CONFORMING TO π
RFC 2246, RFC 5246 and NIST SP 800-135 r1 β the holy trinity of receipts, we love a citation π
π SEE ALSO π
EVP_KDF(3), EVP_KDF_CTX_new(3), EVP_KDF_CTX_free(3), EVP_KDF_CTX_set_params(3), EVP_KDF_derive(3), and "PARAMETERS" in EVP_KDF(3). Go read them, they're literally all connected, iykyk π¦
β HISTORY β
This functionality was added in OpenSSL 3.0. Oldie but a goodie πΈ
π COPYRIGHT π
Copyright 2018-2024 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>.
okay that's the whole page bestie, go forth and derive π«Άβ¨
version 3.5.0, dated 2026-09-25 β that's the OpenSSL version and the date this page was dated, mwah, bye ππ
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 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