# 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: 1. **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. 2. **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 | | --- | --- | --- | | `x25519` (default) | DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, AES-256-GCM | `cs4-hpke-x25519-hkdf-sha256-aes-256-gcm` | | `p384` | DHKEM(P-384, HKDF-SHA384), HKDF-SHA384, AES-256-GCM | `cs4-hpke-p384-hkdf-sha384-aes-256-gcm` | - **Keys.** A logical `key_id` groups immutable versions. A version is the public key's fingerprint, `-` followed by the lowercase hex SHA-256 of `"cryptography-suite/v4 hpke public key" || 0x00 || u16(kem_id) || pk`, where `pk` is the raw X25519 key or the uncompressed P-384 point. Adding a key pair under an existing `key_id` is rotation; the most recently added version is the one an unversioned `KeyRef` resolves 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, with `info = L || SHA-256(L || lp(algorithm) || lp(key_id) || lp(version) || lp(SHA-256(binding)))`, where `L` is `"cryptography-suite/v4 hpke wrap" || 0x00`, `lp(x)` is `u32(len(x)) || x`, and `binding` is 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-:`; only the canonical spelling is accepted. Private keys are standard PKCS #8 PEM, optionally encrypted, so `openssl genpkey -algorithm X25519` and 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](RFC-0017-post-quantum-hybrid-recipients.md) 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.