Skip to content

Add ML-KEM support when using BoringSSL#14673

Merged
reaperhulk merged 4 commits intomainfrom
claude/add-mlkem-boringssl-bqncu
Apr 16, 2026
Merged

Add ML-KEM support when using BoringSSL#14673
reaperhulk merged 4 commits intomainfrom
claude/add-mlkem-boringssl-bqncu

Conversation

@alex
Copy link
Copy Markdown
Member

@alex alex commented Apr 16, 2026

Summary

  • Add ML-KEM-768 and ML-KEM-1024 support for BoringSSL, mirroring the existing ML-DSA BoringSSL pattern
  • BoringSSL uses EVP_pkey_ml_kem_768/1024 + EVP_PKEY_from_private_seed for key creation, and EVP_PKEY_encapsulate/decapsulate with _init calls
  • Added is_mlkem_pkey_type() function (like is_mldsa_pkey_type()) to replace single PKEY_ID matching, since BoringSSL uses per-variant NIDs
  • Key parsing (PKCS#8/SPKI) and Python mlkem_supported() now enabled for BoringSSL

Test plan

  • Built BoringSSL at pinned CI commit (92316dc661f0)
  • OPENSSL_DIR=path-to-boringssl nox -e local passes (3209 passed, 938 skipped)
  • ML-KEM KAT vectors for both 768 and 1024 run and pass on BoringSSL
  • cargo check --all --tests compiles cleanly
  • CI passes on all backends (BoringSSL, AWS-LC, OpenSSL)

https://claude.ai/code/session_01CQzkjEGQfv1xVZ4UXy6Jqj

BoringSSL supports ML-KEM-768 and ML-KEM-1024 via its EVP_PKEY API.
This mirrors the existing ML-DSA BoringSSL support pattern, using
EVP_pkey_ml_kem_768/1024 and EVP_PKEY_from_private_seed for key
creation, and EVP_PKEY_encapsulate/decapsulate with the required
_init calls for encapsulation/decapsulation.

Key changes:
- cryptography-openssl mlkem module: cfg-gated for both BoringSSL
  and AWS-LC with variant-specific code paths via cfg_if
- Added is_mlkem_pkey_type() function (like mldsa) to replace
  single PKEY_ID matching, since BoringSSL uses per-variant NIDs
- Key parsing (pkcs8/spki) enabled for BoringSSL
- Python backend: mlkem_supported() now returns True for BoringSSL

https://claude.ai/code/session_01CQzkjEGQfv1xVZ4UXy6Jqj
cvt(ffi::EVP_PKEY_encapsulate_init(
ctx.as_ptr(),
std::ptr::null(),
))?;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code needs to be reformatted for coverage reasons. something like let res = ffi::EVP_PKEY_encapsulate_init(...); cvt(res)?;` probably

cvt(ffi::EVP_PKEY_decapsulate_init(
ctx.as_ptr(),
std::ptr::null(),
))?;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identical thing here

claude added 3 commits April 16, 2026 02:49
Split the unsafe FFI call from the cvt() error check so that
coverage tools can distinguish the call site from the error path.

https://claude.ai/code/session_01CQzkjEGQfv1xVZ4UXy6Jqj
The undocumented_unsafe_blocks lint requires SAFETY comments
directly above the unsafe block, not separated by #[cfg] attrs.

https://claude.ai/code/session_01CQzkjEGQfv1xVZ4UXy6Jqj
@reaperhulk reaperhulk merged commit 716cbe7 into main Apr 16, 2026
68 checks passed
@reaperhulk reaperhulk deleted the claude/add-mlkem-boringssl-bqncu branch April 16, 2026 20:29
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