Class Hkdf
HKDF-Expand-Label of TLS 1.3 (RFC 8446 section 7.1)
that QUIC uses for its secrets and keys (RFC 9001 section 5.1).
The functional result of every operation is produced by the Dafny-verified kernel compiled to
io.github.mahmoudimus.quic.internal.verifiedhkdf.VerifiedHkdf; this class preserves the
historical Java API and exception surface. The verified kernel, the reviewed Java/JCE bridge,
the Dafny compiler/runtime, the JDK cryptographic provider and JVM timing remain trusted. The
proof establishes functional equations relative to an abstract HMAC; it makes no claim about
HMAC security, provider correctness, constant-time execution or secret erasure.
Instances are immutable and thread-safe; no provider Mac is shared between calls.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbyte[]expand(byte[] prk, byte[] info, int length) HKDF-Expand(prk, info, length).byte[]expandLabel(byte[] secret, String label, byte[] context, int length) TLS 1.3'sHKDF-Expand-Label(secret, label, context, length), with the"tls13 "prefix added tolabel.byte[]extract(byte[] salt, byte[] ikm) HKDF-Extract(salt, ikm).intThe length of the hash, which is also the length ofextract(byte[], byte[])output.
-
Field Details
-
SHA256
HKDF with HMAC-SHA256, for the SHA-256 cipher suites and QUIC's Initial secrets. -
SHA384
HKDF with HMAC-SHA384, forTLS_AES_256_GCM_SHA384.
-
-
Method Details
-
hashLength
public int hashLength()The length of the hash, which is also the length ofextract(byte[], byte[])output.- Returns:
- the hash length in bytes
-
extract
public byte[] extract(byte[] salt, byte[] ikm) HKDF-Extract(salt, ikm).For compatibility with the previous JCE-backed implementation, a
nullIKM is treated as an empty IKM, exactly asMac.doFinal(null)was. A null salt remains aNullPointerException.- Parameters:
salt- the salt; empty means a string ofhashLength()zerosikm- the input keying material- Returns:
- the pseudorandom key,
hashLength()bytes
-
expand
public byte[] expand(byte[] prk, byte[] info, int length) HKDF-Expand(prk, info, length).For compatibility with the previous JCE-backed implementation, a
nullinfo is treated as empty (asMac.update(null)was), while a null PRK retains the historicalIllegalArgumentException. Empty PRKs, negative lengths and lengths above255 * hashLengthremain rejected.- Parameters:
prk- the pseudorandom key, at leasthashLength()bytesinfo- the contextlength- the output length, at most 255 timeshashLength()- Returns:
- the output keying material
-
expandLabel
TLS 1.3'sHKDF-Expand-Label(secret, label, context, length), with the"tls13 "prefix added tolabel.- Parameters:
secret- the secret to expandlabel- the label without its prefix, such as"quic key"context- the context, often empty or a transcript hashlength- the output length, at most 65535- Returns:
- the derived bytes
- Throws:
IllegalArgumentException- if the label is not ASCII or a length exceeds its encoding
-