# info > EVP_KDF-TLS13_KDF

---
type: CommandReference
command: TLS13-KDF
mode: man
section: 7
source: man-pages
---

## Quick Reference

- `EVP_KDF *kdf = EVP_KDF_fetch(NULL, "TLS13-KDF", NULL);` — obtain the KDF implementation
- `EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);` — create a KDF context
- Set parameters via `EVP_KDF_CTX_set_params()` or the `params` argument to `EVP_KDF_derive()`
- `EVP_KDF_derive(kctx, key, keylen, params);` — derive key material
- Two modes: `EXTRACT_ONLY` (produces intermediate fixed-length pseudorandom key K) and `EXPAND_ONLY` (expands K to output)
- For `EXTRACT_ONLY`, `keylen` must equal the size of K; obtain via `EVP_KDF_CTX_get_kdf_size()` after setting mode and digest
- All parameters must be set in a single `OSSL_PARAM` array; piecemeal setting is not supported
- Intended for use by libssl; not all HKDF options are supported

## Name

TLS13-KDF — The TLS 1.3 EVP_KDF implementation

## Synopsis

c
EVP_KDF *kdf = EVP_KDF_fetch(NULL, "TLS13-KDF", NULL);
EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
// Set parameters via OSSL_PARAM array, then:
EVP_KDF_derive(kctx, key, keylen, params);
## Options

Parameters are set via an `OSSL_PARAM` array passed to `EVP_KDF_derive()` or `EVP_KDF_CTX_set_params()`. All parameters must be specified at once; piecemeal setting is not supported.

- `"properties"` (`OSSL_KDF_PARAM_PROPERTIES`) — UTF8 string; works as described in `EVP_KDF(3)`
- `"digest"` (`OSSL_KDF_PARAM_DIGEST`) — UTF8 string; works as described in `EVP_KDF(3)`
- `"key"` (`OSSL_KDF_PARAM_KEY`) — octet string; works as described in `EVP_KDF(3)`
- `"salt"` (`OSSL_KDF_PARAM_SALT`) — octet string; works as described in `EVP_KDF(3)`
- `"prefix"` (`OSSL_KDF_PARAM_PREFIX`) — octet string; sets the label prefix. For TLS 1.3, should be the ASCII string `"tls13 "` without trailing zero byte. (RFC 8446 section 7.1)
- `"label"` (`OSSL_KDF_PARAM_LABEL`) — octet string; sets the label. (RFC 8446 section 7.1)
- `"data"` (`OSSL_KDF_PARAM_DATA`) — octet string; sets the context data. (RFC 8446 section 7.1)
- `"mode"` (`OSSL_KDF_PARAM_MODE`) — UTF8 string or integer; sets the KDF mode. Two modes:
  - `"EXTRACT_ONLY"` or `EVP_KDF_HKDF_MODE_EXTRACT_ONLY` — performs only the extract operation; returns fixed-length pseudorandom key K. `keylen` must match K's size. Digest, key, and salt must be set.
  - `"EXPAND_ONLY"` or `EVP_KDF_HKDF_MODE_EXPAND_ONLY` — performs only the expand operation. Input key must be the intermediate K from a previous extract. Digest, key, and info must be set.

## Examples

Obtain a context for TLS 1.3 KDF:

c
EVP_KDF *kdf = EVP_KDF_fetch(NULL, "TLS13-KDF", NULL);
EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
For `EXTRACT_ONLY`, the output size can be looked up after setting mode and digest:

c
size_t outlen = EVP_KDF_CTX_get_kdf_size(kctx);
## Conforming to

RFC 8446

## See Also

- [EVP_KDF(3)](https://www.chedong.com/phpMan.php/man/EVPKDF/3/markdown)
- [EVP_KDF_CTX_new(3)](https://www.chedong.com/phpMan.php/man/EVPKDFCTXnew/3/markdown)
- [EVP_KDF_CTX_free(3)](https://www.chedong.com/phpMan.php/man/EVPKDFCTXfree/3/markdown)
- [EVP_KDF_CTX_get_kdf_size(3)](https://www.chedong.com/phpMan.php/man/EVPKDFCTXgetkdfsize/3/markdown)
- [EVP_KDF_CTX_set_params(3)](https://www.chedong.com/phpMan.php/man/EVPKDFCTXsetparams/3/markdown)
- [EVP_KDF_derive(3)](https://www.chedong.com/phpMan.php/man/EVPKDFderive/3/markdown)
- [EVP_KDF-HKDF(7)](https://www.chedong.com/phpMan.php/man/EVPKDF-HKDF/7/markdown)