Skip to content
Crypto2026-10-04Shuai Li8 min read

ML-KEM, Explained: How Kyber Got Into Your TLS Handshake

From encryption to encapsulation: a different way to deliver a key

Establishing a symmetric TLS session key always comes back to one problem: how do two parties agree on a secret over a public channel? Classical answers came in two generations — the RSA era encrypted a pre-master secret with the server's public key; the ECDH era had both sides publish ephemeral keys and run a Diffie-Hellman exchange. Both generations share a foundation — factoring and elliptic-curve discrete log — that collapses under Shor's algorithm (background in the previous post).

ML-KEM is the third generation: a key encapsulation mechanism. Three steps:

  1. KeyGen: produce an encapsulation key ek (public) and a decapsulation key dk (private)
  2. Encapsulate: anyone holding the public key runs encapsulation, which outputs a ciphertext ct and a fresh random shared secret ss
  3. Decapsulate: the private-key holder recovers the same ss from ct

The difference from RSA-OAEP's "pick a key, then encrypt and send it" is who controls the key's birth: in a KEM the shared secret is derived inside the algorithm, so you never choose a key and then figure out how to ship it — eliminating an entire class of "the key wasn't random enough" engineering incidents.

Encapsulate / decapsulate: a stronger goal than "encrypt a key"

It is tempting to picture a KEM as "a box that carries 32 bytes of session material." A few sharper points:

  • Shared-secret length is fixed: all three ML-KEM parameter sets produce a 32-byte ss. What grows across 512/768/1024 is public key and ciphertext size — not "a longer key means stronger."
  • The ciphertext is not a literal encryption of ss: ct lets a legitimate private key recover ss without revealing ss to an attacker. Treating ct like an RSA ciphertext you "decrypt into the plaintext key" is the wrong mental model.
  • The security target is IND-CCA: even with adaptive decapsulation queries, an attacker should not distinguish the real shared secret from a random string. FIPS 203 wraps a CPA-secure lattice core in a Fujisaki–Okamoto-style transform (hash domain separation, failure handling). Skip input validation or silent-failure paths in an implementation and the CCA claim collapses.

In the TLS hybrid handshake the roles are fixed: the client generates an ephemeral ML-KEM key pair and puts the public key in the ClientHello key_share; the server encapsulates to that key and returns the ciphertext in the ServerHello key_share; the client decapsulates. Servers do not hang a long-lived ML-KEM private key on the certificate — identity and signatures are a slower track (ML-DSA).

Kyber → ML-KEM: rename carefully, match the standard

ML-KEM's predecessor is the competition submission CRYSTALS-Kyber (NIST's post-quantum project launched in 2016; selected as the KEM basis in July 2022). When FIPS 203 shipped in August 2024, the family was renamed ML-KEM (Module-Lattice-Based Key-Encapsulation Mechanism). The ML stands for module lattice — the mathematical ground shifts from factoring to noisy linear problems over lattices, where quantum algorithms currently hold no structural advantage. The engineering profile in three lines: software speed in the same league as ECDH, keys/ciphertexts roughly an order of magnitude larger than X25519, quantum-resistant.

What matters for migration is not "Kyber won" but not mixing draft names with the standardized ones:

StageCommon labelsNotes
Competition / draft TLSKyber768, X25519Kyber768Draft00, etc.Early Chrome canaries used draft hybrid group names
FIPS 203 finalML-KEM-512/768/1024, X25519MLKEM768OpenSSL 3.5+, current browser defaults

FIPS 203 also differs from Round-3 Kyber in implementation-relevant details (hash domain separation, input validation, failure paths). Wiring an old Kyber vector suite or pre-standard library against an ML-KEM peer can fail the handshake — or worse, disagree silently on the shared secret. Select implementations that claim FIPS 203 / ML-KEM and ship matching test vectors, not "someone said it was Kyber."

Three parameter sets and their sizes: the root of friction

Parameter setRough classical strengthPublic keyCiphertextShared secretvs. X25519 public key
ML-KEM-512AES-128 class800 B768 B32 B32 B
ML-KEM-768AES-192 class1,184 B1,088 B32 B32 B
ML-KEM-1024AES-256 class1,568 B1,568 B32 B32 B

TLS deployments today mostly run ML-KEM-768. Public key plus ciphertext totals about 2.3KB — over thirty times an X25519 public key. That number drives nearly all the engineering friction below. "Bigger parameter set is stronger" only trades lattice hardness against ciphertext bloat; ML-KEM-1024 inflates ClientHello further and usually raises middlebox failure rates, so public HTTPS defaults settle on 768 as a size/security compromise — not an arbitrary middle tier.

The hybrid handshake: redundancy by design, not a stopgap

What browsers and servers run today is not "pure ML-KEM" but the X25519MLKEM768 hybrid named group in TLS 1.3:

  1. The ClientHello key_share carries both an X25519 ephemeral public key (32B) and an ML-KEM-768 ephemeral public key (1,184B)
  2. The server finishes ECDHE and encapsulates to the ML-KEM public key, yielding two shared secrets (each on the order of 32 bytes)
  3. The two secrets are concatenated as specified, then fed as input keying material into the TLS 1.3 HKDF schedule (the Early → Handshake → Master tree)

The key property: an attacker must break both the lattice problem and the elliptic-curve problem to recover the session. If quantum breaks the classical side, ML-KEM holds; if ML-KEM turns out to have a weakness, X25519 still holds. "Hybrid" is often misread as a transitional compromise — in standards and browser policy it is intentional redundancy that will not be retired soon.

After concatenation, HKDF does the rest: Extract to concentrate, Expand with labels into write keys / IVs / Finished keys. Hybrid changes which IKM enters the schedule, not the shape of the TLS 1.3 tree. For how one (or two) secrets grow into a key tree, see the HKDF post.

The ClientHello-bloat middlebox trap

The extra ~1.1KB often pushes the ClientHello past a single TCP segment. Chrome hit this for real while rolling out X25519Kyber768 (the hybrid's predecessor): some enterprise firewalls dropped oversized or "unfamiliar" handshakes outright. Hence the deployment order — canary at the CDN/edge first, watch handshake success rates, then full rollout. That is why the migration checklist lists "canary + handshake monitoring" as mandatory.

How to turn it on (October 2026)

  • Browsers: Chrome and Firefox already negotiate the current hybrid group by default — nothing to flip
  • OpenSSL 3.5+: ships the X25519MLKEM768 group (confirm your build actually includes ML-KEM, not only legacy draft symbols)
  • nginx (linked against OpenSSL 3.5+): ssl_ecdh_curve X25519MLKEM768:X25519; (keep X25519 as fallback for clients that do not offer hybrid key shares)
  • CDNs: Cloudflare and peers expose edge toggles; if the origin sits behind a CDN, upgrading origin TLS buys little for public negotiation — it happens at the edge
  • Verify: check the key-exchange group name in the browser Security panel, or inspect the negotiated group with a hybrid-capable openssl s_client. The certificate itself (visible in the certificate decoder) is still RSA/ECDSA for now — moving certificates and code signing to PQC is the slower timeline (signatures wait on the ML-DSA ecosystem)

Chinese commercial cryptography compliance and international PQC are not mutually exclusive: critical-infrastructure stacks can run TLCP / SM-family endpoints in parallel with hybrid TLS — see the miping × PQC dual-stack frame and the Chinese-crypto HTTPS / nginx guide.

Implementation boundary (why this site has no ML-KEM tool)

Across the tool matrix and src/utils/tools: there is no standalone ML-KEM / Kyber online tool. That boundary is real, not editorial laziness:

  1. WebCrypto has no ML-KEM: crypto.subtle still lists classical RSA / ECDH / AES. Browser-side encapsulate/decapsulate means a liboqs-class wasm build — often multi-megabyte — which fights the "open and use" tool-page goal.
  2. AdSense freeze: no new slugs: even if wasm size were acceptable, adding a /tools/... page is out of scope for this deepening pass.
  3. Tools you can use as anchors today: transport negotiation still surfaces classical certs and algorithms — certificate decoder, RSA encrypt/decrypt (RSA-OAEP overhead for a small key vs ML-KEM-768's 1,088-byte ciphertext is a concrete size-tax comparison). On the KDF side, site HMAC flows help frame HKDF's fast-path role; details in the HKDF post.
  4. Library boundary: on servers, prefer OpenSSL 3.5+ or other implementations verified against FIPS 203 test vectors; do not treat competition-era Kyber reference code or unlabeled "Kyber" bindings as production peers.

When WebCrypto (or an equally stable native API) ships ML-KEM at a usable payload size, encapsulate/decapsulate demos belong in the tool matrix. Until then this post covers concepts, hybrid-TLS operations, and the explicit boundary.

Triage notes

RSA-OAEP is the comparison anchor, and the article keeps correcting one mental model: the encapsulation is not 'the shared secret, encrypted' — treating it like an RSA ciphertext to decrypt into a plaintext key is wrong, because in a KEM the key is derived inside the encapsulation algorithm, which incidentally eliminates an entire class of 'the key itself was not random enough' engineering accidents. The line after the size table — roughly 2.3KB decides almost all the engineering friction of the migration — is the article's spine: the public web parking on ML-KEM-768 by default is a size-versus-security tradeoff, not an arbitrary middle tier, and the middlebox pitfalls of ClientHello bloat (which Chrome's staged rollout genuinely stepped in) grow from the same root. The 'Implementation boundary' section even states why this site offers no ML-KEM tool — WebCrypto has no native support and wasm sizes in at megabytes — so the boundary is real, not documentation laziness.