Add ML-KEM-1024 KEM support in HPKE#14694
Merged
reaperhulk merged 2 commits intomainfrom Apr 19, 2026
Merged
Conversation
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
approved these changes
Apr 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: registerMLKEM1024_PUBLIC_KEY/MLKEM1024_PRIVATE_KEYLazyPyImports.src/rust/src/backend/hpke.rs: addMLKEM1024to theKEMenum andkem_paramsconstants; extend every dispatch match (id,secret_length,enc_length,check_public_key,check_private_key,encap,decap) and share the DHKEM-onlyunreachable!arms withMLKEM768. Broaden the panic messages to "ML-KEM" since both variants share those arms now, and add a secret-length test for the distinctMLKEM1024arm.src/cryptography/hazmat/bindings/_rust/openssl/hpke.pyi: addMLKEM1024toKEMand includemlkem.MLKEM1024PublicKey/MLKEM1024PrivateKeyin the Suite and_*_with_aadtype unions.tests/hazmat/primitives/test_hpke.py: addKEM.MLKEM1024toSUPPORTED_SUITES,MLKEM1024_ENC_LENGTH = 1568, dedicated ciphertext/wrong-key/EC-mismatch tests, and KEM-ID0x0042inkem_mapfor vector decryption (the PQ vector file already covers ML-KEM-1024). ML-KEM single-KEM tests usepytest.mark.supported(only_if=backend.mlkem_supported).docs/hazmat/primitives/hpke.rst: document theMLKEM1024attribute.Test plan
OPENSSL_DIR=/path/to/aws-lc nox -e local— ruff/cargo fmt/clippy/mypy clean; pytest 215 passed; cargo tests 33 passedkem_id: 66(0x0042) entries fromvectors/cryptography_vectors/HPKE/hpke-pq-test-vectors.jsonhttps://claude.ai/code/session_015MMmS5HbMtUe5QweZU9Lpj