Skip to content

Add HPKE (RFC 9180) hybrid public key encryption - #198

Merged
Xor-el merged 1 commit into
masterfrom
feature/hpke
Sep 5, 2026
Merged

Add HPKE (RFC 9180) hybrid public key encryption#198
Xor-el merged 1 commit into
masterfrom
feature/hpke

Conversation

@Xor-el

@Xor-el Xor-el commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Implement the Hybrid Public Key Encryption facade supporting all four authentication modes (base, psk, auth, auth_psk), each combinable with any of the four AEADs: AES-128-GCM, AES-256-GCM, ChaCha20-Poly1305, and the export-only suite (secret export with no seal/open). Key encapsulation covers the five DHKEM suites (P-256, P-384, P-521, X25519, X448) over the three HKDF variants (SHA-256/384/512).

  • New Crypto/Hpke units: THpke facade, TDhKem, THpkeKdf, THpkeAead, THpkeContext (+ interfaces), reusing the existing raw ECDH/X25519/X448 agreements, GCM/ChaCha20-Poly1305 AEADs and HKDF generator.
  • Expose ExtractPRK on THkdfBytesGenerator so the labeled KDF composes over the existing extract path instead of duplicating it.
  • Zeroize derived key material: the AEAD wipes its key and base nonce, the context wipes the exporter secret, and the key schedule and DHKEM wipe the DH output, PRKs, master secret and derived scalar buffers after use.
  • Seal/open expose whole-buffer and offset/length overloads (the former delegating to the latter); a post-doFinal output-size mismatch fails closed before the sequence number advances.
  • Tests: HpkeVectors loader plus HpkeTests covering all 128 published vectors (every mode x KEM x KDF x AEAD), the intermediate KEM shared secret, pairwise base/auth/export-only round-trips, the offset overloads, and the negative cases (tampered tag, wrong sender key, sequence number not advanced on failure).

Implement the Hybrid Public Key Encryption facade supporting all four
authentication modes (base, psk, auth, auth_psk), each combinable with any of
the four AEADs: AES-128-GCM, AES-256-GCM, ChaCha20-Poly1305, and the
export-only suite (secret export with no seal/open). Key encapsulation covers
the five DHKEM suites (P-256, P-384, P-521, X25519, X448) over the three HKDF
variants (SHA-256/384/512).

- New Crypto/Hpke units: THpke facade, TDhKem, THpkeKdf, THpkeAead,
  THpkeContext (+ interfaces), reusing the existing raw ECDH/X25519/X448
  agreements, GCM/ChaCha20-Poly1305 AEADs and HKDF generator.
- Expose ExtractPRK on THkdfBytesGenerator so the labeled KDF composes over
  the existing extract path instead of duplicating it.
- Zeroize derived key material: the AEAD wipes its key and base nonce, the
  context wipes the exporter secret, and the key schedule and DHKEM wipe the
  DH output, PRKs, master secret and derived scalar buffers after use.
- Seal/open expose whole-buffer and offset/length overloads (the former
  delegating to the latter); a post-doFinal output-size mismatch fails closed
  before the sequence number advances.
- Tests: HpkeVectors loader plus HpkeTests covering all 128 published vectors
  (every mode x KEM x KDF x AEAD), the intermediate KEM shared secret,
  pairwise base/auth/export-only round-trips, the offset overloads, and the
  negative cases (tampered tag, wrong sender key, sequence number not advanced
  on failure).
@Xor-el
Xor-el merged commit 2375af3 into master Sep 5, 2026
42 checks passed
@Xor-el
Xor-el deleted the feature/hpke branch September 5, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant