Skip to content

Add ML-KEM-1024 KEM support in HPKE#14694

Merged
reaperhulk merged 2 commits intomainfrom
claude/add-ml-kem-1024-support-iqZfz
Apr 19, 2026
Merged

Add ML-KEM-1024 KEM support in HPKE#14694
reaperhulk merged 2 commits intomainfrom
claude/add-ml-kem-1024-support-iqZfz

Conversation

@alex
Copy link
Copy Markdown
Member

@alex alex commented Apr 19, 2026

Summary

Extends the existing HPKE ML-KEM-768 support to also handle ML-KEM-1024 (KEM ID 0x0042, NENC=1568, NSECRET=32) per draft-connolly-cfrg-hpke-mlkem.

  • src/rust/src/types.rs: register MLKEM1024_PUBLIC_KEY/MLKEM1024_PRIVATE_KEY LazyPyImports.
  • src/rust/src/backend/hpke.rs: add MLKEM1024 to the KEM enum and kem_params constants; extend every dispatch match (id, secret_length, enc_length, check_public_key, check_private_key, encap, decap) and share the DHKEM-only unreachable! arms with MLKEM768. Broaden the panic messages to "ML-KEM" since both variants share those arms now, and add a secret-length test for the distinct MLKEM1024 arm.
  • src/cryptography/hazmat/bindings/_rust/openssl/hpke.pyi: add MLKEM1024 to KEM and include mlkem.MLKEM1024PublicKey/MLKEM1024PrivateKey in the Suite and _*_with_aad type unions.
  • tests/hazmat/primitives/test_hpke.py: add KEM.MLKEM1024 to SUPPORTED_SUITES, MLKEM1024_ENC_LENGTH = 1568, dedicated ciphertext/wrong-key/EC-mismatch tests, and KEM-ID 0x0042 in kem_map for vector decryption (the PQ vector file already covers ML-KEM-1024). ML-KEM single-KEM tests use pytest.mark.supported(only_if=backend.mlkem_supported).
  • docs/hazmat/primitives/hpke.rst: document the MLKEM1024 attribute.

Test plan

  • OPENSSL_DIR=/path/to/aws-lc nox -e local — ruff/cargo fmt/clippy/mypy clean; pytest 215 passed; cargo tests 33 passed
  • Vector decryption picks up existing kem_id: 66 (0x0042) entries from vectors/cryptography_vectors/HPKE/hpke-pq-test-vectors.json

https://claude.ai/code/session_015MMmS5HbMtUe5QweZU9Lpj

claude added 2 commits April 19, 2026 14:17
Extends the existing HPKE ML-KEM-768 support to also handle ML-KEM-1024
(KEM ID 0x0042) per draft-connolly-cfrg-hpke-mlkem.
…est.mark.supported

- Remove MLKEM1024 unreachable panic tests whose match arms are shared
  with MLKEM768 (generate_key, serialize/deserialize_public_key, exchange,
  kem_hash_algorithm). Keep the MLKEM1024 secret_length test since it
  exercises a distinct match arm.
- Change homogeneous `(KEM.MLKEM768, KEM.MLKEM1024)` tuples to lists.
- Convert ML-KEM single-KEM tests to pytest.mark.supported(only_if=...)
  instead of in-body backend.mlkem_supported() skip checks.
@reaperhulk reaperhulk merged commit 798801d into main Apr 19, 2026
68 checks passed
@reaperhulk reaperhulk deleted the claude/add-ml-kem-1024-support-iqZfz branch April 19, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants