RFC-0012: HPKE Public-Key Recipients in the Core Package¶
Status: Proposed; amends the RFC-0006 provider support table by adding a core recipient type. Cloud and HSM providers remain separate distributions. Amended by RFC-0017 (post-quantum hybrid KEMs).
Owner: Format and security leads.
Last updated: 2026-11-29
Context¶
RFC-0006 keeps every provider integration in a separate distribution so that cloud SDKs never enter the core dependency tree (dependency rule 16), and it forbids shipping a “local development” provider as a production tier. As a result an installed core package could not protect anything without a third-party provider, and there was no way to name an offline recovery key.
Two needs are not served by a cloud KMS:
Producers that must not be able to decrypt. A log shipper, an edge device, or a batch export should hold a key that can seal but not open.
Escrow and air-gapped readers. A recovery key kept offline, or a reader with no network access to a key service.
Both are public-key encryption of the data key. RFC 9180 (HPKE) is the standard construction for exactly that, with independent implementations in the major languages, and pyca/cryptography — already the core dependency — implements it.
Binding decision¶
cryptography_suite.providers.hpke.HpkeRecipientProvider is a core
KeyProvider with no dependency beyond pyca/cryptography:
KEM |
HPKE suite |
Wrapping algorithm identifier |
|---|---|---|
|
DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, AES-256-GCM |
|
|
DHKEM(P-384, HKDF-SHA384), HKDF-SHA384, AES-256-GCM |
|
Keys. A logical
key_idgroups immutable versions. A version is the public key’s fingerprint,<kem>-followed by the lowercase hex SHA-256 of"cryptography-suite/v4 hpke public key" || 0x00 || u16(kem_id) || pk, wherepkis the raw X25519 key or the uncompressed P-384 point. Adding a key pair under an existingkey_idis rotation; the most recently added version is the one an unversionedKeyRefresolves to.Capabilities. A registered public key (
add_recipient) can wrap only. A registered private key (add_identity) can wrap and unwrap. Re-adding a version can add the private key but never removes it.Binding. The wrapped key is the HPKE single-shot ciphertext (
enc || ct) of the 32-byte data key, withinfo = L || SHA-256(L || lp(algorithm) || lp(key_id) || lp(version) || lp(SHA-256(binding))), whereLis"cryptography-suite/v4 hpke wrap" || 0x00,lp(x)isu32(len(x)) || x, andbindingis the envelope’s protected bytes. A wrapped key therefore cannot be moved to another envelope, key identifier, version, or algorithm.Encodings. Public keys are shared as
cs4hpke1-<kem>:<base64url without padding>; only the canonical spelling is accepted. Private keys are standard PKCS #8 PEM, optionally encrypted, soopenssl genpkey -algorithm X25519and existing HSM export tooling work.Errors. Unknown provider, key, or version:
KEY_NOT_FOUND. Wrap-only key or a different algorithm:CAPABILITY_UNSUPPORTED. Any HPKE decryption failure, including a binding mismatch:AUTHENTICATION_FAILED.
Post-quantum readiness¶
RFC-0017 adds the hybrid
mlkem768-x25519 and mlkem1024-p384 KEMs now that pyca/cryptography’s
default wheels support ML-KEM. The identifier scheme and the version
fingerprint already included the KEM, so the addition changed no existing
envelope or key.
Security consequences¶
Sealers that hold only public keys cannot open what they seal.
HPKE base mode does not authenticate the sender. Envelope integrity comes from the key commitment and the recipient-manifest MAC, as for every recipient; sender authentication remains out of scope (specification section 11).
Private keys live in process memory for as long as the provider holds them. Keep escrow identities offline and load them only into the process that performs a recovery.
Alternatives considered¶
A raw symmetric-key provider. Rejected for the core package: it puts an unwrapping secret in every sealer and is the “local development” provider RFC-0006 keeps out of production tiers.
age or OpenPGP recipients. Rejected: both define their own file formats; HPKE is the primitive they share, standardized on its own.
RSA-OAEP. Rejected: larger keys and ciphertexts, slower, and no advantage over X25519 or P-384 for this use.
Test and validation requirements¶
tests/integration/test_hpke_provider.py covers both KEMs end to end, the
seal-only property, KMS-plus-escrow, rotation and rewrap, binding to header,
key identifier, version, and ciphertext, every refusal path, the text and PEM
encodings, and unsupported key types.
Supersession rules¶
New KEMs or AEADs require an amendment with a new algorithm identifier; an existing identifier’s meaning never changes.