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:
- KeyGen: produce an encapsulation key
ek(public) and a decapsulation keydk(private) - Encapsulate: anyone holding the public key runs encapsulation, which outputs a ciphertext
ctand a fresh random shared secretss - Decapsulate: the private-key holder recovers the same
ssfromct
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:ctlets a legitimate private key recoversswithout revealingssto an attacker. Treatingctlike 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:
| Stage | Common labels | Notes |
|---|---|---|
| Competition / draft TLS | Kyber768, X25519Kyber768Draft00, etc. | Early Chrome canaries used draft hybrid group names |
| FIPS 203 final | ML-KEM-512/768/1024, X25519MLKEM768 | OpenSSL 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 set | Rough classical strength | Public key | Ciphertext | Shared secret | vs. X25519 public key |
|---|---|---|---|---|---|
| ML-KEM-512 | AES-128 class | 800 B | 768 B | 32 B | 32 B |
| ML-KEM-768 | AES-192 class | 1,184 B | 1,088 B | 32 B | 32 B |
| ML-KEM-1024 | AES-256 class | 1,568 B | 1,568 B | 32 B | 32 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:
- The ClientHello
key_sharecarries both an X25519 ephemeral public key (32B) and an ML-KEM-768 ephemeral public key (1,184B) - The server finishes ECDHE and encapsulates to the ML-KEM public key, yielding two shared secrets (each on the order of 32 bytes)
- 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
X25519MLKEM768group (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:
- WebCrypto has no ML-KEM:
crypto.subtlestill 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. - AdSense freeze: no new slugs: even if wasm size were acceptable, adding a
/tools/...page is out of scope for this deepening pass. - 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.
- 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.
Related reading
- Harvest now, decrypt later: whose data moves first
- Post-quantum migration self-check: 12 items
- HKDF: TLS 1.3's key tree
- Miping × post-quantum: dual-stack assessment
- Chinese-crypto HTTPS / nginx guide
- RSA encryption, explained properly
- HMAC and key derivation
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.
Related Tools
Related Articles
Post-Quantum Migration Self-Check: From Algorithm Inventory to Hybrid TLS — 12 Things to Do in 2026
A practical self-check framework for PQC migration: why three overlapping regulatory timelines make 2026 the starting line, how to build a cryptographic bill of materials (CBOM), ranking by HNDL exposure, enabling X25519+ML-KEM hybrid TLS, and what crypto-agility means in practice. With a 12-item checklist.
Passkeys, Explained: Why the Server Can No Longer Hold a Copy of Your Password
Passkeys (WebAuthn/FIDO2) deepened: registration vs assertion ceremonies, platform authenticators and roaming keys, synced passkeys, how they relate to passwords/TOTP/JWT, and why origin binding makes phishing resistance structural. Servers store public keys only; note that this site has no dedicated Passkey tool page.
Miping × Post-Quantum: A Dual-Stack Assessment Framework for Chinese Compliance Systems
SM2's elliptic-curve foundation sits on Shor's list right next to RSA — Chinese cryptographic compliance carries no quantum exemption. This post lays out a dual-stack evaluation framework on top of miping (GB/T 39786): an algorithmic quantum-exposure inventory, parallel TLCP + hybrid TLS deployment, dual protection for long-lived data, and where the domestic standards process currently stands. A forward-looking guide for compliance teams and critical-infrastructure operators.