pq_crypto 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -0
  3. data/README.md +5 -0
  4. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  5. data/ext/pqcrypto/vendor/.vendored +4 -4
  6. data/ext/pqcrypto/vendor/mlkem-native/README.md +2 -4
  7. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +98 -0
  8. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +8 -7
  9. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +21 -1
  10. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +45 -44
  11. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +36 -0
  12. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +13 -30
  13. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +25 -5
  14. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +14 -0
  15. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/context.h +42 -0
  16. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +20 -12
  17. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -3
  18. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +5 -2
  19. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +5 -2
  20. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +10 -7
  21. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +10 -7
  22. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +2 -1
  23. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +2 -1
  24. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +5 -0
  25. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +2 -1
  26. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +5 -19
  27. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +8 -5
  28. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_extract_bytes_x4_mve.S → keccak_f1600_x4_state_extract_bytes_mve.S} +14 -14
  29. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_xor_bytes_x4_mve.S → keccak_f1600_x4_state_xor_bytes_mve.S} +12 -12
  30. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +36 -2
  31. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +22 -0
  32. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +6 -0
  33. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +11 -0
  34. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +25 -1
  35. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +44 -2
  36. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +2 -0
  37. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +11 -10
  38. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{intt_aarch64_asm.S → mlkem_intt_aarch64_asm.S} +16 -9
  39. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{ntt_aarch64_asm.S → mlkem_ntt_aarch64_asm.S} +10 -7
  40. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_mulcache_compute_aarch64_asm.S → mlkem_poly_mulcache_compute_aarch64_asm.S} +6 -3
  41. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_reduce_aarch64_asm.S → mlkem_poly_reduce_aarch64_asm.S} +6 -3
  42. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tobytes_aarch64_asm.S → mlkem_poly_tobytes_aarch64_asm.S} +12 -5
  43. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tomont_aarch64_asm.S → mlkem_poly_tomont_aarch64_asm.S} +11 -5
  44. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S} +6 -3
  45. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S} +6 -3
  46. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S} +6 -3
  47. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{rej_uniform_aarch64_asm.S → mlkem_rej_uniform_aarch64_asm.S} +17 -17
  48. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +21 -8
  49. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +1 -1
  50. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +4 -0
  51. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{intt_ppc_asm.S → mlkem_intt_ppc_asm.S} +29 -5
  52. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{ntt_ppc_asm.S → mlkem_ntt_ppc_asm.S} +22 -1
  53. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{poly_tomont_ppc_asm.S → mlkem_poly_tomont_ppc_asm.S} +25 -3
  54. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{reduce_ppc_asm.S → mlkem_reduce_ppc_asm.S} +22 -1
  55. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +4 -0
  56. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +4 -0
  57. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +6 -2
  58. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +25 -5
  59. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +20 -20
  60. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +14 -3
  61. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +8 -0
  62. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{intt_avx2_asm.S → mlkem_intt_avx2_asm.S} +27 -3
  63. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntt_avx2_asm.S → mlkem_ntt_avx2_asm.S} +23 -1
  64. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttfrombytes_avx2_asm.S → mlkem_nttfrombytes_avx2_asm.S} +27 -3
  65. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntttobytes_avx2_asm.S → mlkem_ntttobytes_avx2_asm.S} +27 -3
  66. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttunpack_avx2_asm.S → mlkem_nttunpack_avx2_asm.S} +17 -1
  67. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d10_avx2_asm.S → mlkem_poly_compress_d10_avx2_asm.S} +34 -3
  68. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d11_avx2_asm.S → mlkem_poly_compress_d11_avx2_asm.S} +33 -2
  69. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d4_avx2_asm.S → mlkem_poly_compress_d4_avx2_asm.S} +34 -3
  70. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d5_avx2_asm.S → mlkem_poly_compress_d5_avx2_asm.S} +33 -2
  71. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d10_avx2_asm.S → mlkem_poly_decompress_d10_avx2_asm.S} +32 -3
  72. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d11_avx2_asm.S → mlkem_poly_decompress_d11_avx2_asm.S} +32 -2
  73. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d4_avx2_asm.S → mlkem_poly_decompress_d4_avx2_asm.S} +32 -3
  74. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d5_avx2_asm.S → mlkem_poly_decompress_d5_avx2_asm.S} +32 -2
  75. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_mulcache_compute_avx2_asm.S → mlkem_poly_mulcache_compute_avx2_asm.S} +29 -1
  76. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S} +35 -1
  77. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S} +35 -1
  78. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S} +35 -1
  79. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{reduce_avx2_asm.S → mlkem_reduce_avx2_asm.S} +17 -1
  80. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{rej_uniform_avx2_asm.S → mlkem_rej_uniform_avx2_asm.S} +40 -7
  81. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{tomont_avx2_asm.S → mlkem_tomont_avx2_asm.S} +20 -3
  82. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +7 -2
  83. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +6 -0
  84. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +25 -4
  85. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +33 -4
  86. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +4 -0
  87. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +4 -0
  88. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +19 -1
  89. data/lib/pq_crypto/version.rb +1 -1
  90. data/script/vendor_libs.rb +3 -3
  91. metadata +40 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7887d01882b53d518ecac6559fe2444572c50d5cd7074ee6770d8ea7bcfa32b
4
- data.tar.gz: 9b518ef75cacc9d192b40c831e79e31c6883fddd2ce4cf56d2e08f5054da48a3
3
+ metadata.gz: 68e8c2cd661300cb364be85b4939787590eb88217a2f3cb3463e262b66c4c662
4
+ data.tar.gz: fef5359500d367c68b50b2a72b54cfc8980b3c6dfd6b0e132998212e34cbd47a
5
5
  SHA512:
6
- metadata.gz: 90f571ac5fd32557f539303cfc9d7f148aac81532325cd31baf69d879528f91107184ae2c8b785737808bce762f635436506ef265e623dc14f9d51cc61e826b8
7
- data.tar.gz: 1783ad30164c271257ee6813ba83c24bc50c99cec0ef274217d4a5d65cffef73447f0b4e66c77952ca3260f2abdfad5740d208729517b34d2a60a84304793e71
6
+ metadata.gz: 12bfac65233efde5fa34a30df51494bc6da59985287ae2b3954b377dc9afa949f16b509e98db25d7af2a61a7f3b6a4e572b21f33ff85e797a153ee0e0dde10a0
7
+ data.tar.gz: 25ccfe8a57150355da41a115c401d7ccee2b10a0a6a42957f8335cd3c97024d14261188ee676bc6a122557f52a4ea5894d67062dace53f983b51b4244d9d1a6a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.5] - 2026-08-04
4
+
5
+ ### Changed
6
+
7
+ - update native mlkem `v1.2.0` -> `v1.3.0`
8
+
9
+ Upstream is a feature/integration release with no security fixes and no
10
+ changes to the ML-KEM algorithm implementation. Everything relevant to this
11
+ gem is unchanged: the exported symbol set, all key/ciphertext/shared-secret
12
+ sizes, and the derived key material for ML-KEM-512/768/1024 (verified
13
+ byte-for-byte against `v1.2.0` for both the portable and the AVX2 build,
14
+ including the implicit-rejection path and the SHAKE256/SHA3-256 helpers used
15
+ by the X-Wing combiner).
16
+
17
+ What upstream changed that is visible in the vendored tree:
18
+ - new opt-in `MLK_CONFIG_NO_{KEYPAIR,ENCAPS,DECAPS}_API` build options; the
19
+ gem needs all three operations and does not set them
20
+ - the AArch64 arithmetic and FIPS-202 backends are now gated on compile-time
21
+ NEON availability (`MLK_SYS_AARCH64_NEON`) and on the new `MLK_SYS_CAP_NEON`
22
+ runtime capability, which defaults to "available"
23
+ - new opt-in `MLK_SYS_AARCH64_FAST_SHA3` for CPUs with high SHA3 throughput
24
+ - backend assembly files renamed with an `mlkem_` prefix and assembly-local
25
+ labels namespaced with `mlk_`; both are internal to the vendored aggregator
26
+ `mlkem_native_asm.S` and transparent to this build
27
+ - context-parameter machinery moved into the new `mlkem/src/context.h`
28
+
29
+ Note that `mlkem-native` v1.3.0 is the last release before a breaking v2;
30
+ `release/v1.3` is the upstream support branch.
31
+
32
+ - `mldsa-native` remains pinned at `v1.0.0-beta2`, which is still the latest
33
+ upstream tag.
34
+
35
+ ### Testing
36
+
37
+ - Added `test/native_api_conformance`, a compile-only check that validates the
38
+ hand-written declarations in `ext/pqcrypto/pqcrypto_native_api.h` against the
39
+ vendored upstream headers. The extension deliberately never includes
40
+ `mlkem_native.h` / `mldsa_native.h`, so nothing else in the build could catch
41
+ size or prototype drift after a vendor bump.
42
+
43
+ ### CI
44
+
45
+ - Run the native API conformance check right after `vendor:verify`.
46
+ - Verify that the AArch64 assembly backends are actually compiled in on
47
+ macOS ARM runners, and smoke-test ML-KEM and ML-DSA against that build.
48
+
3
49
  ## [0.6.4] - 2026-07-18
4
50
 
5
51
  ### Compatibility
data/README.md CHANGED
@@ -87,6 +87,11 @@ bundle exec rake vendor
87
87
  bundle exec rake compile
88
88
  ```
89
89
 
90
+ Upstream pins are recorded in `ext/pqcrypto/vendor/.vendored` and enforced by
91
+ `bundle exec rake vendor:verify`. `mlkem-native` is pinned at `v1.3.0`, which
92
+ upstream describes as the last release before a breaking `v2`; `release/v1.3` is
93
+ the upstream support branch. `mldsa-native` is pinned at `v1.0.0-beta2`.
94
+
90
95
  The default build uses the portable native source path. Upstream native assembly
91
96
  can be tested explicitly with:
92
97
 
@@ -2,6 +2,6 @@
2
2
  #ifndef PQCRYPTO_VERSION_H
3
3
  #define PQCRYPTO_VERSION_H
4
4
 
5
- #define PQCRYPTO_VERSION "0.6.4"
5
+ #define PQCRYPTO_VERSION "0.6.5"
6
6
 
7
7
  #endif
@@ -2,11 +2,11 @@
2
2
  backend=PQ Code Package native only
3
3
  pqclean=removed
4
4
  mlkem_native_repo=https://github.com/pq-code-package/mlkem-native.git
5
- mlkem_native_ref=v1.2.0
6
- mlkem_native_commit=0ba906cb14b1c241476134d7403a811b382ca498
7
- mlkem_native_tree_sha256=cc78ed199b8c65abe68635b23a13b294d5a8deb20c8bc7b4d76590c00976bb2d
5
+ mlkem_native_ref=v1.3.0
6
+ mlkem_native_commit=398050c877ff4353c96305c6434b63528accfc37
7
+ mlkem_native_tree_sha256=3cd7af93cde256f73ce5ffde3ac3accd31e4361616e275f1bf1c39d462c2149e
8
8
  mldsa_native_repo=https://github.com/pq-code-package/mldsa-native.git
9
9
  mldsa_native_ref=v1.0.0-beta2
10
10
  mldsa_native_commit=9b0ee84f4cf399043eca59eca4e5f8531ca1d61b
11
11
  mldsa_native_tree_sha256=2887f59926c18a877e8c5a5e30727e84497c357032093d00d7135aedf53f011e
12
- manifest_sha256=011e9d7d1160c7d612869695d950e17f9e330dac6bf782883639593f96fee951
12
+ manifest_sha256=6fc387662d86d42905f6cbed29c92bc83abf18e8678a21500eb27fce14a89c7d
@@ -2,9 +2,7 @@
2
2
 
3
3
  # mlkem-native
4
4
 
5
- ![Base tests](https://github.com/pq-code-package/mlkem-native/actions/workflows/base.yml/badge.svg)
6
- ![Extended tests](https://github.com/pq-code-package/mlkem-native/actions/workflows/ci.yml/badge.svg)
7
- ![Proof: CBMC](https://github.com/pq-code-package/mlkem-native/actions/workflows/cbmc.yml/badge.svg)
5
+ ![CI](https://github.com/pq-code-package/mlkem-native/actions/workflows/all.yml/badge.svg)
8
6
  ![Proof: HOL-Light](https://github.com/pq-code-package/mlkem-native/actions/workflows/hol_light.yml/badge.svg)
9
7
  ![Benchmarks](https://github.com/pq-code-package/mlkem-native/actions/workflows/bench.yml/badge.svg)
10
8
  ![C90](https://img.shields.io/badge/language-C90-blue.svg)
@@ -102,7 +100,7 @@ mlkem-native currently offers the following backends:
102
100
  If you'd like contribute new backends, please reach out or just open a PR.
103
101
 
104
102
  Our AArch64 assembly is developed using the [SLOTHY](https://github.com/slothy-optimizer/slothy) superoptimizer, following the approach described in the SLOTHY paper[^SLOTHY_Paper]:
105
- We write 'clean' assembly by hand and automate micro-optimizations (e.g. see the [clean](dev/aarch64_clean/src/ntt_aarch64_asm.S) vs [optimized](dev/aarch64_opt/src/ntt_aarch64_asm.S) AArch64 NTT).
103
+ We write 'clean' assembly by hand and automate micro-optimizations (e.g. see the [clean](dev/aarch64_clean/src/mlkem_ntt_aarch64_asm.S) vs [optimized](dev/aarch64_opt/src/mlkem_ntt_aarch64_asm.S) AArch64 NTT).
106
104
  See [dev/README.md](dev/README.md) for more details.
107
105
 
108
106
  ## Test Vectors
@@ -1,5 +1,103 @@
1
1
  [//]: # (SPDX-License-Identifier: CC-BY-4.0)
2
2
 
3
+ mlkem-native v1.3.0
4
+ ===================
5
+
6
+ Release notes
7
+ -------------
8
+
9
+ mlkem-native v1.3.0 adds configuration options to control which KEM operations
10
+ are included in a build. It also improves AArch64 feature detection and runtime
11
+ dispatch, and introduces ABI compliance checks for assembly backends. Embedded
12
+ testing now uses Zephyr across a broader range of Arm targets, while assembly
13
+ namespacing and source naming improve integration with projects such as AWS-LC.
14
+
15
+ See the full change log here:
16
+ https://github.com/pq-code-package/mlkem-native/compare/v1.2.0...v1.3.0
17
+
18
+ What's next? mlkem-native v2
19
+ ----------------------------
20
+
21
+ This is expected to be the last release prior to mlkem-native v2. Between
22
+ v1.3.0 and v2, breaking changes to the `main` branch will be made.
23
+
24
+ Long-Term Support
25
+ -----------------
26
+
27
+ `release/v1.3` will act as a support branch until 6 months after
28
+ mlkem-native v2 is established. It will receive bugfixes, but no new features.
29
+ We do currently not plan to offer long-term support for mlkem-native v1.x
30
+ beyond that timeframe.
31
+
32
+ If you are deploying mlkem-native v1.3 and expect to be unable to upgrade to
33
+ mlkem-native v2 within 6 months of its release, please contact us to discuss
34
+ a potential extension of the support schedule.
35
+
36
+ What's New
37
+ ----------
38
+
39
+ ### Configuration / API
40
+
41
+ - Add `MLK_CONFIG_NO_KEYPAIR_API`, `MLK_CONFIG_NO_ENCAPS_API`, and
42
+ `MLK_CONFIG_NO_DECAPS_API`, allowing unused KEM operations and their internal
43
+ dependencies to be excluded. All non-empty API combinations are covered in
44
+ CI. ([#1787](https://github.com/pq-code-package/mlkem-native/pull/1787))
45
+ - Gate the AArch64 arithmetic and FIPS-202 backends on compile-time NEON
46
+ availability and the new `MLK_SYS_CAP_NEON` runtime capability. Integrators
47
+ can now fall back to portable C on AArch64 systems without usable NEON.
48
+ ([#1805](https://github.com/pq-code-package/mlkem-native/pull/1805),
49
+ [#1809](https://github.com/pq-code-package/mlkem-native/pull/1809))
50
+ - Add `MLK_SYS_AARCH64_FAST_SHA3` to select the pure-Neon Armv8.4-A SHA3
51
+ implementation on CPUs with sufficient SHA3 execution capacity, including
52
+ Graviton5. ([#1784](https://github.com/pq-code-package/mlkem-native/pull/1784))
53
+
54
+ ### Assurance / Testing
55
+
56
+ - Fix deterministic-only builds using `MLK_CONFIG_NO_RANDOMIZED_API`, including
57
+ test, example, and stack-measurement coverage.
58
+ ([#1816](https://github.com/pq-code-package/mlkem-native/pull/1816))
59
+ - Upgrade CBMC to v6.10.0, the newest release of CBMC including the fix
60
+ [cbmc/#9011](https://github.com/diffblue/cbmc/pull/9011) to the Z3 soundness
61
+ issue [z3/#9550](https://github.com/Z3Prover/z3/issues/9550). mlkem-native v1.2
62
+ had pinned CBMC to an unstable version between v6.9 and v6.10 which already
63
+ included that fix.
64
+ ([#1762](https://github.com/pq-code-package/mlkem-native/pull/1762))
65
+ - Add assembly ABI checkers for AArch64, x86_64 SysV, ppc64le ELFv2, and
66
+ Armv8.1-M MVE. The checkers verify preservation of callee-saved registers and
67
+ run as part of the standard test suite.
68
+ ([#1135](https://github.com/pq-code-package/mlkem-native/pull/1135))
69
+ - Add Zephyr-based testing for QEMU Cortex-M3, M4, M7, M33, and M55 targets,
70
+ replacing the previous custom MPS baremetal platforms. Add test and benchmark
71
+ support for the NUCLEO-N657X0-Q board.
72
+ ([#1750](https://github.com/pq-code-package/mlkem-native/pull/1750),
73
+ [#1547](https://github.com/pq-code-package/mlkem-native/pull/1547))
74
+ - Strengthen HOL Light tooling with cross-architecture proof execution and
75
+ checks that every expected theorem is present
76
+ ([#1634](https://github.com/pq-code-package/mlkem-native/pull/1634))
77
+ - Strengthen Wycheproof validation by checking newly specified fields, rejecting
78
+ unknown schema fields, and tracking upstream vector changes.
79
+ ([#1801](https://github.com/pq-code-package/mlkem-native/pull/1801))
80
+ - Extend Windows MSVC coverage to allocation-failure, RNG-failure, and
81
+ Wycheproof tests ([#1738](https://github.com/pq-code-package/mlkem-native/pull/1738))
82
+ - Add emulated testing on x86_64 without AVX2.
83
+ ([#1753](https://github.com/pq-code-package/mlkem-native/pull/1753))
84
+ - Correct decapsulation stack measurements, which previously returned before
85
+ the full operation and understated peak stack use by around 10%.
86
+ ([#1823](https://github.com/pq-code-package/mlkem-native/pull/1823))
87
+
88
+ ### Integration / Upgrade Notes
89
+
90
+ - Namespace assembly-local labels with an `mlk_` prefix, preventing collisions
91
+ when mlkem-native and other projects are combined into one assembly unit.
92
+ ([#1813](https://github.com/pq-code-package/mlkem-native/pull/1813))
93
+ - Rename backend assembly files to be self-identifying. Arithmetic assembly
94
+ filenames now use an `mlkem_` prefix. Downstream build systems with explicit
95
+ source lists must update those paths.
96
+ ([#1821](https://github.com/pq-code-package/mlkem-native/pull/1821))
97
+ - Move context-parameter support into the new `mlkem/src/context.h`; downstream
98
+ source manifests must include this file.
99
+ ([#1768](https://github.com/pq-code-package/mlkem-native/pull/1768))
100
+
3
101
  mlkem-native v1.2.0
4
102
  ===================
5
103
 
@@ -202,11 +202,6 @@
202
202
  #undef MLK_COMMON_H
203
203
  #undef MLK_CONCAT
204
204
  #undef MLK_CONCAT_
205
- #undef MLK_CONTEXT_PARAMETERS_0
206
- #undef MLK_CONTEXT_PARAMETERS_1
207
- #undef MLK_CONTEXT_PARAMETERS_2
208
- #undef MLK_CONTEXT_PARAMETERS_3
209
- #undef MLK_CONTEXT_PARAMETERS_4
210
205
  #undef MLK_EMPTY_CU
211
206
  #undef MLK_ERR_FAIL
212
207
  #undef MLK_ERR_OUT_OF_MEMORY
@@ -311,6 +306,13 @@
311
306
  #undef mlk_poly_frommsg
312
307
  #undef mlk_poly_tobytes
313
308
  #undef mlk_poly_tomsg
309
+ /* mlkem/src/context.h */
310
+ #undef MLK_CONTEXT_H
311
+ #undef MLK_CONTEXT_PARAMETERS_0
312
+ #undef MLK_CONTEXT_PARAMETERS_1
313
+ #undef MLK_CONTEXT_PARAMETERS_2
314
+ #undef MLK_CONTEXT_PARAMETERS_3
315
+ #undef MLK_CONTEXT_PARAMETERS_4
314
316
  /* mlkem/src/debug.h */
315
317
  #undef MLK_DEBUG_H
316
318
  #undef mlk_assert
@@ -377,6 +379,7 @@
377
379
  #undef MLK_SYSV_ABI_SUPPORTED
378
380
  #undef MLK_SYS_AARCH64
379
381
  #undef MLK_SYS_AARCH64_EB
382
+ #undef MLK_SYS_AARCH64_NEON
380
383
  #undef MLK_SYS_APPLE
381
384
  #undef MLK_SYS_ARMV81M_MVE
382
385
  #undef MLK_SYS_BIG_ENDIAN
@@ -508,8 +511,6 @@
508
511
  #undef MLK_USE_FIPS202_X4_NATIVE
509
512
  #undef MLK_USE_FIPS202_X4_XOR_BYTES_NATIVE
510
513
  #undef mlk_keccak_f1600_x4_native_impl
511
- #undef mlk_keccak_f1600_x4_state_extract_bytes
512
- #undef mlk_keccak_f1600_x4_state_xor_bytes
513
514
  /* mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h */
514
515
  #undef MLK_FIPS202_NATIVE_ARMV81M_SRC_FIPS202_NATIVE_ARMV81M_H
515
516
  #undef mlk_keccak_f1600_x4_mve_asm
@@ -191,6 +191,7 @@ extern "C"
191
191
  {
192
192
  #endif
193
193
 
194
+ #if !defined(MLK_CONFIG_NO_KEYPAIR_API)
194
195
  /**
195
196
  * Generate a public/private keypair for the ML-KEM key encapsulation mechanism.
196
197
  *
@@ -255,7 +256,9 @@ int MLK_API_NAMESPACE(keypair)(
255
256
  #endif
256
257
  );
257
258
  #endif /* !MLK_CONFIG_NO_RANDOMIZED_API */
259
+ #endif /* !MLK_CONFIG_NO_KEYPAIR_API */
258
260
 
261
+ #if !defined(MLK_CONFIG_NO_ENCAPS_API)
259
262
  /**
260
263
  * Generate ciphertext and shared secret for a given public key.
261
264
  *
@@ -324,7 +327,9 @@ int MLK_API_NAMESPACE(enc)(
324
327
  #endif
325
328
  );
326
329
  #endif /* !MLK_CONFIG_NO_RANDOMIZED_API */
330
+ #endif /* !MLK_CONFIG_NO_ENCAPS_API */
327
331
 
332
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
328
333
  /**
329
334
  * Generate shared secret for a given ciphertext and private key.
330
335
  *
@@ -356,6 +361,7 @@ int MLK_API_NAMESPACE(dec)(
356
361
  MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
357
362
  #endif
358
363
  );
364
+ #endif /* !MLK_CONFIG_NO_DECAPS_API */
359
365
 
360
366
 
361
367
  /**
@@ -375,6 +381,7 @@ int MLK_API_NAMESPACE(dec)(
375
381
  * @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
376
382
  * MLK_CUSTOM_ALLOC returned NULL.
377
383
  */
384
+ #if !defined(MLK_CONFIG_NO_ENCAPS_API)
378
385
  MLK_API_QUALIFIER
379
386
  MLK_API_MUST_CHECK_RETURN_VALUE
380
387
  int MLK_API_NAMESPACE(check_pk)(
@@ -384,6 +391,7 @@ int MLK_API_NAMESPACE(check_pk)(
384
391
  MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
385
392
  #endif
386
393
  );
394
+ #endif /* !MLK_CONFIG_NO_ENCAPS_API */
387
395
 
388
396
  /**
389
397
  * Implements public key hash check mandated by FIPS 203, i.e., ensures that
@@ -402,6 +410,7 @@ int MLK_API_NAMESPACE(check_pk)(
402
410
  * @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
403
411
  * MLK_CUSTOM_ALLOC returned NULL.
404
412
  */
413
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
405
414
  MLK_API_QUALIFIER
406
415
  MLK_API_MUST_CHECK_RETURN_VALUE
407
416
  int MLK_API_NAMESPACE(check_sk)(
@@ -411,6 +420,7 @@ int MLK_API_NAMESPACE(check_sk)(
411
420
  MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
412
421
  #endif
413
422
  );
423
+ #endif /* !MLK_CONFIG_NO_DECAPS_API */
414
424
 
415
425
  #ifdef __cplusplus
416
426
  }
@@ -427,13 +437,23 @@ int MLK_API_NAMESPACE(check_sk)(
427
437
  #define CRYPTO_SYMBYTES MLKEM_SYMBYTES
428
438
  #define CRYPTO_BYTES MLKEM_BYTES
429
439
 
440
+ #if !defined(MLK_CONFIG_NO_KEYPAIR_API)
430
441
  #define crypto_kem_keypair_derand MLK_API_NAMESPACE(keypair_derand)
442
+ #if !defined(MLK_CONFIG_NO_RANDOMIZED_API)
431
443
  #define crypto_kem_keypair MLK_API_NAMESPACE(keypair)
444
+ #endif
445
+ #endif /* !MLK_CONFIG_NO_KEYPAIR_API */
446
+ #if !defined(MLK_CONFIG_NO_ENCAPS_API)
432
447
  #define crypto_kem_enc_derand MLK_API_NAMESPACE(enc_derand)
448
+ #if !defined(MLK_CONFIG_NO_RANDOMIZED_API)
433
449
  #define crypto_kem_enc MLK_API_NAMESPACE(enc)
434
- #define crypto_kem_dec MLK_API_NAMESPACE(dec)
450
+ #endif
435
451
  #define crypto_kem_check_pk MLK_API_NAMESPACE(check_pk)
452
+ #endif /* !MLK_CONFIG_NO_ENCAPS_API */
453
+ #if !defined(MLK_CONFIG_NO_DECAPS_API)
454
+ #define crypto_kem_dec MLK_API_NAMESPACE(dec)
436
455
  #define crypto_kem_check_sk MLK_API_NAMESPACE(check_sk)
456
+ #endif
437
457
 
438
458
  #else /* !MLK_CONFIG_API_NO_SUPERCOP */
439
459
 
@@ -22,7 +22,7 @@
22
22
  * levels, you should include this file once with
23
23
  * MLK_CONFIG_MULTILEVEL_WITH_SHARED set.
24
24
  *
25
- * (You could also follow the same pattern as for mlkem_native_monobuild.c
25
+ * (You could also follow the same pattern as for mlkem_native.c
26
26
  * and include it for every level, setting MLK_CONFIG_MULTILEVEL_NO_SHARED
27
27
  * for all but one. For builds with MLK_CONFIG_MULTILEVEL_NO_SHARED, this
28
28
  * file will then be ignored.)
@@ -60,46 +60,46 @@
60
60
 
61
61
  #if defined(MLK_CONFIG_USE_NATIVE_BACKEND_ARITH)
62
62
  #if defined(MLK_SYS_AARCH64)
63
- #include "src/native/aarch64/src/intt_aarch64_asm.S"
64
- #include "src/native/aarch64/src/ntt_aarch64_asm.S"
65
- #include "src/native/aarch64/src/poly_mulcache_compute_aarch64_asm.S"
66
- #include "src/native/aarch64/src/poly_reduce_aarch64_asm.S"
67
- #include "src/native/aarch64/src/poly_tobytes_aarch64_asm.S"
68
- #include "src/native/aarch64/src/poly_tomont_aarch64_asm.S"
69
- #include "src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S"
70
- #include "src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S"
71
- #include "src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S"
72
- #include "src/native/aarch64/src/rej_uniform_aarch64_asm.S"
63
+ #include "src/native/aarch64/src/mlkem_intt_aarch64_asm.S"
64
+ #include "src/native/aarch64/src/mlkem_ntt_aarch64_asm.S"
65
+ #include "src/native/aarch64/src/mlkem_poly_mulcache_compute_aarch64_asm.S"
66
+ #include "src/native/aarch64/src/mlkem_poly_reduce_aarch64_asm.S"
67
+ #include "src/native/aarch64/src/mlkem_poly_tobytes_aarch64_asm.S"
68
+ #include "src/native/aarch64/src/mlkem_poly_tomont_aarch64_asm.S"
69
+ #include "src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S"
70
+ #include "src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S"
71
+ #include "src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S"
72
+ #include "src/native/aarch64/src/mlkem_rej_uniform_aarch64_asm.S"
73
73
  #endif /* MLK_SYS_AARCH64 */
74
74
  #if defined(MLK_SYS_X86_64)
75
- #include "src/native/x86_64/src/intt_avx2_asm.S"
76
- #include "src/native/x86_64/src/ntt_avx2_asm.S"
77
- #include "src/native/x86_64/src/nttfrombytes_avx2_asm.S"
78
- #include "src/native/x86_64/src/ntttobytes_avx2_asm.S"
79
- #include "src/native/x86_64/src/nttunpack_avx2_asm.S"
80
- #include "src/native/x86_64/src/poly_compress_d10_avx2_asm.S"
81
- #include "src/native/x86_64/src/poly_compress_d11_avx2_asm.S"
82
- #include "src/native/x86_64/src/poly_compress_d4_avx2_asm.S"
83
- #include "src/native/x86_64/src/poly_compress_d5_avx2_asm.S"
84
- #include "src/native/x86_64/src/poly_decompress_d10_avx2_asm.S"
85
- #include "src/native/x86_64/src/poly_decompress_d11_avx2_asm.S"
86
- #include "src/native/x86_64/src/poly_decompress_d4_avx2_asm.S"
87
- #include "src/native/x86_64/src/poly_decompress_d5_avx2_asm.S"
88
- #include "src/native/x86_64/src/poly_mulcache_compute_avx2_asm.S"
89
- #include "src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S"
90
- #include "src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S"
91
- #include "src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S"
92
- #include "src/native/x86_64/src/reduce_avx2_asm.S"
93
- #include "src/native/x86_64/src/rej_uniform_avx2_asm.S"
94
- #include "src/native/x86_64/src/tomont_avx2_asm.S"
75
+ #include "src/native/x86_64/src/mlkem_intt_avx2_asm.S"
76
+ #include "src/native/x86_64/src/mlkem_ntt_avx2_asm.S"
77
+ #include "src/native/x86_64/src/mlkem_nttfrombytes_avx2_asm.S"
78
+ #include "src/native/x86_64/src/mlkem_ntttobytes_avx2_asm.S"
79
+ #include "src/native/x86_64/src/mlkem_nttunpack_avx2_asm.S"
80
+ #include "src/native/x86_64/src/mlkem_poly_compress_d10_avx2_asm.S"
81
+ #include "src/native/x86_64/src/mlkem_poly_compress_d11_avx2_asm.S"
82
+ #include "src/native/x86_64/src/mlkem_poly_compress_d4_avx2_asm.S"
83
+ #include "src/native/x86_64/src/mlkem_poly_compress_d5_avx2_asm.S"
84
+ #include "src/native/x86_64/src/mlkem_poly_decompress_d10_avx2_asm.S"
85
+ #include "src/native/x86_64/src/mlkem_poly_decompress_d11_avx2_asm.S"
86
+ #include "src/native/x86_64/src/mlkem_poly_decompress_d4_avx2_asm.S"
87
+ #include "src/native/x86_64/src/mlkem_poly_decompress_d5_avx2_asm.S"
88
+ #include "src/native/x86_64/src/mlkem_poly_mulcache_compute_avx2_asm.S"
89
+ #include "src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S"
90
+ #include "src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S"
91
+ #include "src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S"
92
+ #include "src/native/x86_64/src/mlkem_reduce_avx2_asm.S"
93
+ #include "src/native/x86_64/src/mlkem_rej_uniform_avx2_asm.S"
94
+ #include "src/native/x86_64/src/mlkem_tomont_avx2_asm.S"
95
95
  #endif /* MLK_SYS_X86_64 */
96
96
  #if defined(MLK_SYS_RISCV64)
97
97
  #endif
98
98
  #if defined(MLK_SYS_PPC64LE)
99
- #include "src/native/ppc64le/src/intt_ppc_asm.S"
100
- #include "src/native/ppc64le/src/ntt_ppc_asm.S"
101
- #include "src/native/ppc64le/src/poly_tomont_ppc_asm.S"
102
- #include "src/native/ppc64le/src/reduce_ppc_asm.S"
99
+ #include "src/native/ppc64le/src/mlkem_intt_ppc_asm.S"
100
+ #include "src/native/ppc64le/src/mlkem_ntt_ppc_asm.S"
101
+ #include "src/native/ppc64le/src/mlkem_poly_tomont_ppc_asm.S"
102
+ #include "src/native/ppc64le/src/mlkem_reduce_ppc_asm.S"
103
103
  #endif /* MLK_SYS_PPC64LE */
104
104
  #endif /* MLK_CONFIG_USE_NATIVE_BACKEND_ARITH */
105
105
 
@@ -116,8 +116,8 @@
116
116
  #endif
117
117
  #if defined(MLK_SYS_ARMV81M_MVE)
118
118
  #include "src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S"
119
- #include "src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S"
120
- #include "src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S"
119
+ #include "src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S"
120
+ #include "src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S"
121
121
  #endif
122
122
  #endif /* MLK_CONFIG_USE_NATIVE_BACKEND_FIPS202 */
123
123
 
@@ -226,11 +226,6 @@
226
226
  #undef MLK_COMMON_H
227
227
  #undef MLK_CONCAT
228
228
  #undef MLK_CONCAT_
229
- #undef MLK_CONTEXT_PARAMETERS_0
230
- #undef MLK_CONTEXT_PARAMETERS_1
231
- #undef MLK_CONTEXT_PARAMETERS_2
232
- #undef MLK_CONTEXT_PARAMETERS_3
233
- #undef MLK_CONTEXT_PARAMETERS_4
234
229
  #undef MLK_EMPTY_CU
235
230
  #undef MLK_ERR_FAIL
236
231
  #undef MLK_ERR_OUT_OF_MEMORY
@@ -335,6 +330,13 @@
335
330
  #undef mlk_poly_frommsg
336
331
  #undef mlk_poly_tobytes
337
332
  #undef mlk_poly_tomsg
333
+ /* mlkem/src/context.h */
334
+ #undef MLK_CONTEXT_H
335
+ #undef MLK_CONTEXT_PARAMETERS_0
336
+ #undef MLK_CONTEXT_PARAMETERS_1
337
+ #undef MLK_CONTEXT_PARAMETERS_2
338
+ #undef MLK_CONTEXT_PARAMETERS_3
339
+ #undef MLK_CONTEXT_PARAMETERS_4
338
340
  /* mlkem/src/debug.h */
339
341
  #undef MLK_DEBUG_H
340
342
  #undef mlk_assert
@@ -401,6 +403,7 @@
401
403
  #undef MLK_SYSV_ABI_SUPPORTED
402
404
  #undef MLK_SYS_AARCH64
403
405
  #undef MLK_SYS_AARCH64_EB
406
+ #undef MLK_SYS_AARCH64_NEON
404
407
  #undef MLK_SYS_APPLE
405
408
  #undef MLK_SYS_ARMV81M_MVE
406
409
  #undef MLK_SYS_BIG_ENDIAN
@@ -532,8 +535,6 @@
532
535
  #undef MLK_USE_FIPS202_X4_NATIVE
533
536
  #undef MLK_USE_FIPS202_X4_XOR_BYTES_NATIVE
534
537
  #undef mlk_keccak_f1600_x4_native_impl
535
- #undef mlk_keccak_f1600_x4_state_extract_bytes
536
- #undef mlk_keccak_f1600_x4_state_xor_bytes
537
538
  /* mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h */
538
539
  #undef MLK_FIPS202_NATIVE_ARMV81M_SRC_FIPS202_NATIVE_ARMV81M_H
539
540
  #undef mlk_keccak_f1600_x4_mve_asm
@@ -99,6 +99,42 @@
99
99
  */
100
100
  /* #define MLK_CONFIG_EXTERNAL_API_QUALIFIER */
101
101
 
102
+ /**
103
+ * MLK_CONFIG_NO_KEYPAIR_API
104
+ *
105
+ * By default, mlkem-native includes support for generating key pairs.
106
+ * If you don't need this, set MLK_CONFIG_NO_KEYPAIR_API to exclude
107
+ * crypto_kem_keypair and crypto_kem_keypair_derand, and all internal
108
+ * APIs only needed by those functions.
109
+ */
110
+ /* #define MLK_CONFIG_NO_KEYPAIR_API */
111
+
112
+ /**
113
+ * MLK_CONFIG_NO_ENCAPS_API
114
+ *
115
+ * By default, mlkem-native includes support for encapsulation. If you
116
+ * don't need this, set MLK_CONFIG_NO_ENCAPS_API to exclude
117
+ * crypto_kem_enc, crypto_kem_enc_derand, crypto_kem_check_pk, and
118
+ * all internal APIs only needed by those functions.
119
+ *
120
+ * @note Setting this option is incompatible with MLK_CONFIG_KEYGEN_PCT
121
+ * as the current PCT implementation requires crypto_kem_enc().
122
+ */
123
+ /* #define MLK_CONFIG_NO_ENCAPS_API */
124
+
125
+ /**
126
+ * MLK_CONFIG_NO_DECAPS_API
127
+ *
128
+ * By default, mlkem-native includes support for decapsulation. If you
129
+ * don't need this, set MLK_CONFIG_NO_DECAPS_API to exclude
130
+ * crypto_kem_dec, crypto_kem_check_sk, and all internal APIs only
131
+ * needed by those functions.
132
+ *
133
+ * @note Setting this option is incompatible with MLK_CONFIG_KEYGEN_PCT
134
+ * as the current PCT implementation requires crypto_kem_dec().
135
+ */
136
+ /* #define MLK_CONFIG_NO_DECAPS_API */
137
+
102
138
  /**
103
139
  * MLK_CONFIG_NO_RANDOMIZED_API
104
140
  *
@@ -125,6 +125,14 @@
125
125
  #error Bad configuration: MLK_CONFIG_NO_RANDOMIZED_API is incompatible with MLK_CONFIG_KEYGEN_PCT as the current PCT implementation requires crypto_kem_enc()
126
126
  #endif
127
127
 
128
+ #if defined(MLK_CONFIG_NO_ENCAPS_API) && defined(MLK_CONFIG_KEYGEN_PCT)
129
+ #error Bad configuration: MLK_CONFIG_NO_ENCAPS_API is incompatible with MLK_CONFIG_KEYGEN_PCT as the current PCT implementation requires crypto_kem_enc()
130
+ #endif
131
+
132
+ #if defined(MLK_CONFIG_NO_DECAPS_API) && defined(MLK_CONFIG_KEYGEN_PCT)
133
+ #error Bad configuration: MLK_CONFIG_NO_DECAPS_API is incompatible with MLK_CONFIG_KEYGEN_PCT as the current PCT implementation requires crypto_kem_dec()
134
+ #endif
135
+
128
136
  #if defined(MLK_CONFIG_USE_NATIVE_BACKEND_ARITH)
129
137
  #include MLK_CONFIG_ARITH_BACKEND_FILE
130
138
  /* Include to enforce consistency of API and implementation,
@@ -188,36 +196,11 @@
188
196
  #error Bad configuration: MLK_CONFIG_CUSTOM_ALLOC_FREE must be set together with MLK_CUSTOM_ALLOC and MLK_CUSTOM_FREE
189
197
  #endif
190
198
 
191
- /*
192
- * If the integration wants to provide a context parameter for use in
193
- * platform-specific hooks, then it should define this parameter.
194
- *
195
- * The MLK_CONTEXT_PARAMETERS_n macros are intended to be used with macros
196
- * defining the function names and expand to either pass or discard the context
197
- * argument as required by the current build. If there is no context parameter
198
- * requested then these are removed from the prototypes and from all calls.
199
- */
200
- #ifdef MLK_CONFIG_CONTEXT_PARAMETER
201
- #define MLK_CONTEXT_PARAMETERS_0(context) (context)
202
- #define MLK_CONTEXT_PARAMETERS_1(arg0, context) (arg0, context)
203
- #define MLK_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1, context)
204
- #define MLK_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) \
205
- (arg0, arg1, arg2, context)
206
- #define MLK_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
207
- (arg0, arg1, arg2, arg3, context)
208
- #else /* MLK_CONFIG_CONTEXT_PARAMETER */
209
- #define MLK_CONTEXT_PARAMETERS_0(context) ()
210
- #define MLK_CONTEXT_PARAMETERS_1(arg0, context) (arg0)
211
- #define MLK_CONTEXT_PARAMETERS_2(arg0, arg1, context) (arg0, arg1)
212
- #define MLK_CONTEXT_PARAMETERS_3(arg0, arg1, arg2, context) (arg0, arg1, arg2)
213
- #define MLK_CONTEXT_PARAMETERS_4(arg0, arg1, arg2, arg3, context) \
214
- (arg0, arg1, arg2, arg3)
215
- #endif /* !MLK_CONFIG_CONTEXT_PARAMETER */
216
-
217
- #if defined(MLK_CONFIG_CONTEXT_PARAMETER_TYPE) != \
218
- defined(MLK_CONFIG_CONTEXT_PARAMETER)
219
- #error MLK_CONFIG_CONTEXT_PARAMETER_TYPE must be defined if and only if MLK_CONFIG_CONTEXT_PARAMETER is defined
220
- #endif
199
+ /* Context-parameter machinery (MLK_CONTEXT_PARAMETERS_n and related config
200
+ * checks). Kept in a separate, level-generic header for readability; included
201
+ * here so it is available to the allocation macros below and to all consumers
202
+ * of common.h. */
203
+ #include "context.h"
221
204
 
222
205
  #if !defined(MLK_CONFIG_CUSTOM_ALLOC_FREE)
223
206
  /* Default: stack allocation */