Skip to content

[CHERRYPICK FIPS 5.x] Add AArch64 NEON runtime fallback for ML-KEM and ML-DSA#3358

Open
samuel40791765 wants to merge 1 commit into
aws:fips-2026-06-26-snapshotfrom
samuel40791765:fips-2026-need
Open

[CHERRYPICK FIPS 5.x] Add AArch64 NEON runtime fallback for ML-KEM and ML-DSA#3358
samuel40791765 wants to merge 1 commit into
aws:fips-2026-06-26-snapshotfrom
samuel40791765:fips-2026-need

Conversation

@samuel40791765

Copy link
Copy Markdown
Contributor

On aarch64, the ML-KEM/ML-DSA native primitives called the NEON assembly unconditionally, with no runtime path to the C reference implementation. This was fine since NEON assembly is a mandatory part of the base aarch64 architecture.

However, FIPS requires us to include a way to test the C fallback implementation on relevant architectures. This adds a runtime NEON capability gate on every native entry point so that when NEON is unavailable (reachable via OPENSSL_armcap=0) execution falls back to the C reference path, mirroring the existing x86-64/AVX2 gate.

This was implemented with the shadow-header pattern already used for x86-64 ML-DSA (mldsa_x86_64_meta.h). Since upstream mlkem-native does not have this, I've created two similar files mlkem_aarch64_meta.h / mldsa_aarch64_meta.h which mirror the vendored aarch64 meta.h. This allows no edits to the vendored mlkem/ or mldsa/ trees.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

(cherry picked from commit aba09cb)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

On aarch64, the ML-KEM/ML-DSA native primitives called the NEON assembly
unconditionally, with no runtime path to the C reference implementation.
This was fine since NEON assembly is a mandatory part of the base
aarch64 architecture.

However, FIPS requires us to include a way to test the C fallback
implementation on relevant architectures. This adds a runtime NEON
capability gate on every native entry point so that when NEON is
unavailable (reachable via `OPENSSL_armcap=0`) execution falls back to
the C reference path, mirroring the existing x86-64/AVX2 gate.

This was implemented with the shadow-header pattern already used for
x86-64 ML-DSA (`mldsa_x86_64_meta.h`). Since upstream mlkem-native does
not have this, I've created two similar files `mlkem_aarch64_meta.h` /
`mldsa_aarch64_meta.h` which mirror the vendored aarch64 meta.h. This
allows no edits to the vendored mlkem/ or mldsa/ trees.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.

(cherry picked from commit aba09cb)
@samuel40791765
samuel40791765 requested a review from a team as a code owner July 18, 2026 02:22
@samuel40791765 samuel40791765 changed the title Add AArch64 NEON runtime fallback for ML-KEM and ML-DSA (#3353) [CHERRYPICK FIPS 5.x] Add AArch64 NEON runtime fallback for ML-KEM and ML-DSA Jul 18, 2026
@samuel40791765
samuel40791765 deployed to auto-approve July 18, 2026 02:23 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

🔒 Security ReviewView Report

Please review before merging.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.17%. Comparing base (6283365) to head (91224c8).

Additional details and impacted files
@@                     Coverage Diff                      @@
##           fips-2026-06-26-snapshot    #3358      +/-   ##
============================================================
- Coverage                     78.21%   78.17%   -0.05%     
============================================================
  Files                           693      693              
  Lines                        123900   123900              
  Branches                      17208    17216       +8     
============================================================
- Hits                          96910    96855      -55     
- Misses                        26072    26126      +54     
- Partials                        918      919       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants