![]() |
![]()
| ![]() |
![]()
NAME
SYNOPSIS
int
int
int
DESCRIPTIONThe
STRING CTRLSThe TLS PRF also supports string based control operations using EVP_PKEY_CTX_ctrl_str(3). 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. NOTESAll these functions are implemented as macros. 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. 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(3)
function. Since the output length is variable, setting the buffer to
RETURN VALUESAll 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. EXAMPLESThis 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 ALSOEVP_PKEY_CTX_ctrl_str(3), EVP_PKEY_CTX_new(3), EVP_PKEY_derive(3) HISTORYThese functions first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 7.6.
|