wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
hkdf.h File Reference

RFC 5869 HKDF over HMAC-SHA-256, plus the TLS 1.3 / QUIC HKDF-Expand-Label construction (RFC 8446 7.1, RFC 9001 5.1). More...

Go to the source code of this file.

Data Structures

struct  hkdf_label
 HkdfLabel inputs (RFC 8446 7.1): the label (without the "tls13 " prefix) and the context (may be empty: {0, 0}). More...

Macros

#define HKDF_PRK   SHA256_DIGEST
 pseudorandom key length
#define HKDF_PRK_384   SHA384_DIGEST
 pseudorandom key length for the SHA-384 instantiation

Functions

void hkdf_extract (wired_span salt, wired_span ikm, u8 prk[HKDF_PRK])
 prk = HKDF-Extract(salt, ikm).
int hkdf_expand (const u8 prk[HKDF_PRK], wired_span info, wired_mspan okm)
 okm = HKDF-Expand(prk, info, okm.n).
int hkdf_expand_label (const u8 prk[HKDF_PRK], const hkdf_label *l, wired_mspan okm)
 okm = HKDF-Expand-Label(prk, label, context, okm.n) with the "tls13 " prefix.
void hkdf_extract_384 (wired_span salt, wired_span ikm, u8 prk[HKDF_PRK_384])
 prk = HKDF-Extract(salt, ikm) instantiated with HMAC-SHA-384 (RFC 5869 2.2, TLS_AES_256_GCM_SHA384).
int hkdf_expand_384 (const u8 prk[HKDF_PRK_384], wired_span info, wired_mspan okm)
 okm = HKDF-Expand(prk, info, okm.n) instantiated with HMAC-SHA-384 (RFC 5869 2.3).
int hkdf_expand_label_384 (const u8 prk[HKDF_PRK_384], const hkdf_label *l, wired_mspan okm)
 okm = HKDF-Expand-Label(prk, label, context, okm.n) with the "tls13 " prefix, instantiated with HMAC-SHA-384 (RFC 8446 7.1, RFC 9001 5.1).

Detailed Description

RFC 5869 HKDF over HMAC-SHA-256, plus the TLS 1.3 / QUIC HKDF-Expand-Label construction (RFC 8446 7.1, RFC 9001 5.1).

Function Documentation

◆ hkdf_expand()

int hkdf_expand ( const u8 prk[HKDF_PRK],
wired_span info,
wired_mspan okm )

okm = HKDF-Expand(prk, info, okm.n).

okm.n must be <= 255*32.

Parameters
prk32-byte pseudorandom key from hkdf_extract()
infocontext/application-specific info (may be empty)
okmreceives exactly okm.n bytes of output keying material
Returns
1 on success, 0 if the length is out of range.

◆ hkdf_expand_384()

int hkdf_expand_384 ( const u8 prk[HKDF_PRK_384],
wired_span info,
wired_mspan okm )

okm = HKDF-Expand(prk, info, okm.n) instantiated with HMAC-SHA-384 (RFC 5869 2.3).

okm.n must be <= 255*48.

Parameters
prk48-byte pseudorandom key from hkdf_extract_384()
infocontext/application-specific info (may be empty)
okmreceives exactly okm.n bytes of output keying material
Returns
1 on success, 0 if the length is out of range.

◆ hkdf_expand_label()

int hkdf_expand_label ( const u8 prk[HKDF_PRK],
const hkdf_label * l,
wired_mspan okm )

okm = HKDF-Expand-Label(prk, label, context, okm.n) with the "tls13 " prefix.

Parameters
prk32-byte pseudorandom key
llabel and context inputs (see hkdf_label)
okmreceives exactly okm.n bytes of output keying material
Returns
1 on success, 0 if the label/context/length do not fit.

◆ hkdf_expand_label_384()

int hkdf_expand_label_384 ( const u8 prk[HKDF_PRK_384],
const hkdf_label * l,
wired_mspan okm )

okm = HKDF-Expand-Label(prk, label, context, okm.n) with the "tls13 " prefix, instantiated with HMAC-SHA-384 (RFC 8446 7.1, RFC 9001 5.1).

Parameters
prk48-byte pseudorandom key
llabel and context inputs (see hkdf_label)
okmreceives exactly okm.n bytes of output keying material
Returns
1 on success, 0 if the label/context/length do not fit.

◆ hkdf_extract()

void hkdf_extract ( wired_span salt,
wired_span ikm,
u8 prk[HKDF_PRK] )

prk = HKDF-Extract(salt, ikm).

Parameters
saltoptional salt (may be empty)
ikminput keying material
prkreceives the 32-byte pseudorandom key

◆ hkdf_extract_384()

void hkdf_extract_384 ( wired_span salt,
wired_span ikm,
u8 prk[HKDF_PRK_384] )

prk = HKDF-Extract(salt, ikm) instantiated with HMAC-SHA-384 (RFC 5869 2.2, TLS_AES_256_GCM_SHA384).

Parameters
saltoptional salt (may be empty)
ikminput keying material
prkreceives the 48-byte pseudorandom key