The EVP_KDF_TLS1_PRF algorithm implements the PRF used by TLS versions up to and including TLS 1.2.
The "EVP_KDF_CTRL_SET_MD" control is used to set 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.
Sets the secret value of the TLS PRF to seclen bytes of the buffer sec. Any existing secret value is replaced.
EVP_KDF_ctrl_str() takes two type strings for this control:
Resets the context seed buffer to zero length.
Sets the seed to seedlen bytes of seed. If a seed is already set it is appended to the existing value.
The total length of the context seed buffer cannot exceed 1024 bytes; this should be more than enough for any normal use of the TLS PRF.
EVP_KDF_ctrl_str() takes two type strings for this control:
EVP_KDF_CTX *kctx = EVP_KDF_CTX_new_id(EVP_KDF_TLS1_PRF, NULL);
The digest, secret value and seed must be set before a key is derived otherwise an error will occur.
The output length of the PRF is specified by the "keylen" parameter to the EVP_KDF_derive() function.
EVP_KDF_CTX *kctx; unsigned char out[10]; kctx = EVP_KDF_CTX_new_id(EVP_KDF_TLS1_PRF); if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()) <= 0) { error("EVP_KDF_CTRL_SET_MD"); } if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_TLS_SECRET, "secret", (size_t)6) <= 0) { error("EVP_KDF_CTRL_SET_TLS_SECRET"); } if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_ADD_TLS_SEED, "seed", (size_t)4) <= 0) { error("EVP_KDF_CTRL_ADD_TLS_SEED"); } if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) { error("EVP_KDF_derive"); } EVP_KDF_CTX_free(kctx);
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>.