RFC-0017: Post-Quantum Hybrid HPKE Recipients¶
Status: Proposed; amends RFC-0012 by adding two hybrid KEMs to its table.
Owner: Format and security leads.
Last updated: 2026-11-29
Context¶
An envelope’s data key is only as confidential as the weakest recipient that wraps it. Every classical recipient (X25519, P-384, RSA, and the ECDH inside cloud KMS public-key APIs) can be broken by a large quantum computer. That threat already applies to data with a long confidentiality life: ciphertext copied today can be stored and decrypted later (“harvest now, decrypt later”). NIST standardized ML-KEM in FIPS 203 (August 2024). National migration timelines such as CNSA 2.0 expect quantum-resistant key establishment for new systems this decade.
RFC-0012 deferred a hybrid KEM until pyca/cryptography’s default wheels supported ML-KEM. Release 50.0.2 does, through OpenSSL 4.0, and it exposes HPKE with the hybrid KEMs registered by IANA.
Binding decision¶
HpkeRecipientProvider gains two KEMs. Each hybrid wraps the data key under
an ML-KEM key and a classical key in one HPKE KEM. The data key stays
confidential while either component is unbroken, so adopting ML-KEM does not
mean trusting it alone.
KEM |
IANA KEM id |
HPKE suite |
Wrapping algorithm identifier |
|---|---|---|---|
|
|
ML-KEM-768 + X25519, HKDF-SHA256, AES-256-GCM |
|
|
|
ML-KEM-1024 + P-384, HKDF-SHA384, AES-256-GCM |
|
Choice of KEM.
mlkem768-x25519is the general recommendation: small and fast, with a component combination analysed in the X-Wing paper.mlkem1024-p384uses the largest ML-KEM parameter set, AES-256, and SHA-384, for deployments that need those parameter sizes or a NIST curve for the classical half. This RFC makes no compliance claim for either.Keys.
HybridPublicKey(mlkem_key, classical_key)andHybridPrivateKey(mlkem_key, classical_key)hold the two halves. The constructors accept only the pairings in the table and raiseTypeErrorotherwise.generate_private_key(HpkeKem.MLKEM768_X25519)creates both halves from the operating-system CSPRNG.Versions. The RFC-0012 fingerprint is unchanged:
pkis the raw ML-KEM encapsulation key followed by the classical public key (raw X25519, or the uncompressed P-384 point), andu16(kem_id)is the IANA identifier above. A hybrid version is therefore never equal to a classical one.Binding. Unchanged from RFC-0012: the HPKE
infobinds the algorithm identifier, key identifier, version, and envelope protected bytes.Encodings. Public keys use the RFC-0012 text form
cs4hpke1-<kem>:<base64url>over the samepkbytes, which are 1,216 bytes formlkem768-x25519and 1,665 formlkem1024-p384; the maximum text length rises from 512 to 4,096 characters. A hybrid private key is a PEM bundle of exactly two PKCS #8 keys, the ML-KEM key and its classical partner, in either order. An encrypted bundle uses one password for both.private_key_pem()writes this bundle (the ML-KEM key in the 64-byte seed form) andload_private_key_pem()reads it; any PKCS #8 ML-KEM encoding the backend can parse is accepted.Sizes. A wrapped data key is 1,168 bytes (
mlkem768-x25519) or 1,713 bytes (mlkem1024-p384), well inside the default 16 KiB recipient entry limit; nothing in the envelope format changes.Capability detection.
post_quantum_available()reports whether the linked backend implements ML-KEM. Without it, generating a hybrid key or loading a hybrid public key raisesProviderError(CAPABILITY_UNSUPPORTED), and a hybrid private key bundle does not load. Nothing falls back to a classical key.cryptosuite doctorreportsml_kem_available.Errors. As RFC-0012. Any decapsulation or AEAD failure, including a swapped component, is
AUTHENTICATION_FAILED.
Migration¶
Adding a hybrid recipient needs no format change and no flag day:
Generate a hybrid identity and register its public key as an additional recipient (RFC-0011) next to the existing primary key. New envelopes are then readable by either.
rewraporrewrap_streamexisting envelopes to the hybrid key. Only the recipient section is rewritten; records are copied unchanged.Retire classical-only recipients once no reader depends on them.
Security consequences¶
Confidentiality of the data key holds while either ML-KEM or the classical KEM holds. Envelope integrity is unchanged: it comes from the key commitment and the recipient-manifest MAC, which are symmetric (HKDF-SHA-512 and HMAC-SHA-256 with 256-bit keys) and not weakened by a quantum computer beyond the generic square-root search bound.
Authentication of the sender remains out of scope, as in RFC-0012.
A hybrid private key held in memory exposes both halves; keep escrow identities offline, as for any identity.
Alternatives considered¶
Pure ML-KEM recipients. Rejected for now: a defect in a new scheme or its implementation would then expose the data key with no classical fallback. The hybrid costs about 1 KB per recipient.
A custom combiner over separate ML-KEM and X25519 encapsulations. Rejected: the IANA-registered hybrid KEMs are standardized constructions with published analysis and independent implementations.
Waiting for cloud KMS post-quantum key wrapping. Rejected: an offline hybrid recipient protects data today and works with every KMS primary.
Test and validation requirements¶
tests/integration/test_hpke_post_quantum.py covers both hybrids end to end
through Protector, the provider conformance kit, binding of each component
(swapping either half fails), tampering and truncation of every region of the
wrapped key, pairing validation, the canonical text encoding and its
rejections, PEM bundles (encrypted and plain, either order, invalid
mixtures), and the refusal on a backend without ML-KEM, which runs on every
backend. tests/cli/test_cli.py runs a password-protected hybrid identity
through cryptosuite encrypt and decrypt.
Tests that need ML-KEM are skipped on a backend without it; the oldest supported dependency job (cryptography 47.0.0) runs that way. The 100% combined coverage gate fails unless the platform matrix executes every hybrid path, so CI proves the hybrids ran on the supported platforms.
Supersession rules¶
As RFC-0012: new KEMs require an amendment with a new algorithm identifier, and an existing identifier’s meaning never changes.