pq_crypto 0.6.5 → 0.6.7

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 (157) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +233 -0
  3. data/README.md +16 -3
  4. data/SECURITY.md +46 -0
  5. data/ext/pqcrypto/extconf.rb +8 -1
  6. data/ext/pqcrypto/pq_externalmu.c +35 -0
  7. data/ext/pqcrypto/pqcrypto_native_api.h +91 -75
  8. data/ext/pqcrypto/pqcrypto_ruby_secure.c +97 -9
  9. data/ext/pqcrypto/pqcrypto_secure.c +95 -33
  10. data/ext/pqcrypto/pqcrypto_secure.h +66 -48
  11. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  12. data/ext/pqcrypto/vendor/.vendored +7 -7
  13. data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +5 -2
  14. data/ext/pqcrypto/vendor/mldsa-native/LICENSE +21 -2
  15. data/ext/pqcrypto/vendor/mldsa-native/README.md +20 -7
  16. data/ext/pqcrypto/vendor/mldsa-native/RELEASE.md +160 -0
  17. data/ext/pqcrypto/vendor/mldsa-native/SECURITY.md +1 -1
  18. data/ext/pqcrypto/vendor/mldsa-native/mldsa/README.md +2 -2
  19. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +85 -59
  20. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +292 -348
  21. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +122 -76
  22. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +184 -86
  23. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +49 -4
  24. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +49 -81
  25. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/context.h +152 -0
  26. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +25 -12
  27. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +2 -0
  28. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +2 -0
  29. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +2 -2
  30. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +9 -11
  31. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +19 -11
  32. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +6 -4
  33. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +7 -4
  34. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +7 -4
  35. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +12 -9
  36. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +12 -9
  37. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +1 -1
  38. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +3 -2
  39. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +3 -2
  40. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +6 -1
  41. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +3 -2
  42. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +11 -11
  43. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +9 -22
  44. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +8 -5
  45. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +1 -0
  46. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/{state_extract_bytes_x4_mve.S → keccak_f1600_x4_state_extract_bytes_mve.S} +14 -14
  47. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/{state_xor_bytes_x4_mve.S → keccak_f1600_x4_state_xor_bytes_mve.S} +12 -12
  48. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +5 -4
  49. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +2 -2
  50. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +1 -0
  51. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +36 -2
  52. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +62 -4
  53. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +87 -54
  54. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{intt_aarch64_asm.S → mldsa_intt_aarch64_asm.S} +39 -6
  55. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{ntt_aarch64_asm.S → mldsa_ntt_aarch64_asm.S} +39 -6
  56. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{pointwise_montgomery_aarch64_asm.S → mldsa_pointwise_montgomery_aarch64_asm.S} +25 -3
  57. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_caddq_aarch64_asm.S → mldsa_poly_caddq_aarch64_asm.S} +19 -3
  58. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_chknorm_aarch64_asm.S → mldsa_poly_chknorm_aarch64_asm.S} +24 -3
  59. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_decompose_32_aarch64_asm.S → mldsa_poly_decompose_32_aarch64_asm.S} +25 -3
  60. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_decompose_88_aarch64_asm.S → mldsa_poly_decompose_88_aarch64_asm.S} +25 -3
  61. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_use_hint_32_aarch64_asm.S → mldsa_poly_use_hint_32_aarch64_asm.S} +25 -3
  62. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_use_hint_88_aarch64_asm.S → mldsa_poly_use_hint_88_aarch64_asm.S} +25 -3
  63. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S} +31 -3
  64. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S} +31 -3
  65. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S} +31 -3
  66. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{polyz_unpack_17_aarch64_asm.S → mldsa_polyz_unpack_17_aarch64_asm.S} +31 -3
  67. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{polyz_unpack_19_aarch64_asm.S → mldsa_polyz_unpack_19_aarch64_asm.S} +31 -3
  68. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_aarch64_asm.S → mldsa_rej_uniform_aarch64_asm.S} +48 -15
  69. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_eta2_aarch64_asm.S → mldsa_rej_uniform_eta2_aarch64_asm.S} +42 -9
  70. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_eta4_aarch64_asm.S → mldsa_rej_uniform_eta4_aarch64_asm.S} +42 -9
  71. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +11 -3
  72. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +3 -2
  73. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +28 -28
  74. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +171 -49
  75. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{intt_avx2_asm.S → mldsa_intt_avx2_asm.S} +23 -1
  76. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{ntt_avx2_asm.S → mldsa_ntt_avx2_asm.S} +23 -1
  77. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{nttunpack_avx2_asm.S → mldsa_nttunpack_avx2_asm.S} +17 -1
  78. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l4_avx2_asm.S → mldsa_pointwise_acc_l4_avx2_asm.S} +37 -3
  79. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l5_avx2_asm.S → mldsa_pointwise_acc_l5_avx2_asm.S} +37 -3
  80. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l7_avx2_asm.S → mldsa_pointwise_acc_l7_avx2_asm.S} +37 -3
  81. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_avx2_asm.S → mldsa_pointwise_avx2_asm.S} +31 -3
  82. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{poly_caddq_avx2_asm.S → mldsa_poly_caddq_avx2_asm.S} +18 -9
  83. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +176 -0
  84. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +490 -0
  85. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +489 -0
  86. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +123 -0
  87. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +125 -0
  88. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +355 -0
  89. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +355 -0
  90. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +132 -0
  91. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +205 -0
  92. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +176 -0
  93. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +27 -36
  94. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +42 -8
  95. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +93 -17
  96. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +74 -15
  97. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +97 -11
  98. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +7 -38
  99. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +49 -7
  100. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +16 -17
  101. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +26 -9
  102. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +3 -0
  103. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +18 -19
  104. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +15 -3
  105. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +28 -6
  106. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +311 -246
  107. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +245 -240
  108. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +64 -5
  109. data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +5 -2
  110. data/ext/pqcrypto/vendor/mlkem-native/LICENSE +21 -3
  111. data/ext/pqcrypto/vendor/mlkem-native/README.md +2 -2
  112. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +113 -0
  113. data/ext/pqcrypto/vendor/mlkem-native/mlkem/README.md +2 -2
  114. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +17 -27
  115. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +68 -151
  116. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +17 -27
  117. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +46 -44
  118. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +25 -0
  119. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +37 -6
  120. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/context.h +9 -0
  121. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +2 -2
  122. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +8 -8
  123. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +1 -1
  124. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +3 -3
  125. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +3 -3
  126. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +2 -2
  127. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +3 -3
  128. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/api.h +11 -11
  129. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +3 -3
  130. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +2 -2
  131. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +14 -11
  132. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +28 -11
  133. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +39 -14
  134. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +10 -10
  135. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +20 -20
  136. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +5 -5
  137. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +11 -10
  138. data/lib/pq_crypto/internal.rb +10 -0
  139. data/lib/pq_crypto/kem.rb +47 -5
  140. data/lib/pq_crypto/key.rb +14 -8
  141. data/lib/pq_crypto/pkcs8.rb +13 -5
  142. data/lib/pq_crypto/signature.rb +34 -9
  143. data/lib/pq_crypto/spki.rb +4 -2
  144. data/lib/pq_crypto/version.rb +1 -1
  145. data/lib/pq_crypto.rb +9 -0
  146. data/script/vendor_libs.rb +6 -6
  147. metadata +40 -38
  148. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_chknorm_avx2.c +0 -52
  149. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +0 -157
  150. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +0 -157
  151. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +0 -103
  152. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +0 -105
  153. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +0 -94
  154. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +0 -96
  155. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_avx2.c +0 -126
  156. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +0 -157
  157. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +0 -141
@@ -6,6 +6,12 @@
6
6
  /* References
7
7
  * ==========
8
8
  *
9
+ * - [FIPS140_3_IG]
10
+ * Implementation Guidance for FIPS 140-3 and the Cryptographic Module
11
+ * Validation Program
12
+ * National Institute of Standards and Technology
13
+ * https://csrc.nist.gov/projects/cryptographic-module-validation-program/fips-140-3-ig-announcements
14
+ *
9
15
  * - [FIPS203]
10
16
  * FIPS 203 Module-Lattice-Based Key-Encapsulation Mechanism Standard
11
17
  * National Institute of Standards and Technology
@@ -23,6 +29,11 @@
23
29
  * Make sure the configuration file is in the include path
24
30
  * (this is "mlkem_native_config.h" by default, or MLK_CONFIG_FILE if defined).
25
31
  *
32
+ * # API conventions
33
+ *
34
+ * Conventions shared by all functions below (return values, pointer validity,
35
+ * output buffers on error) are documented in API-CONVENTIONS.md.
36
+ *
26
37
  * # Multi-level builds
27
38
  *
28
39
  * This header specifies a build of mlkem-native for a fixed security level.
@@ -31,51 +42,15 @@
31
42
  * MLK_CONFIG_PARAMETER_SET accordingly for each, and #undef'ing the MLK_H
32
43
  * guard to allow multiple inclusions.
33
44
  *
34
- * # Legacy configuration (deprecated)
35
- *
36
- * Instead of providing the config file used for the build, you can
37
- * alternatively set the following configuration options prior to
38
- * including this header.
39
- *
40
- * This method of configuration is deprecated.
41
- * It will be removed in mlkem-native-v2.
42
- *
43
- * - MLK_CONFIG_API_PARAMETER_SET [required]
44
- *
45
- * The parameter set used for the build; 512, 768, or 1024.
46
- *
47
- * - MLK_CONFIG_API_NAMESPACE_PREFIX [required]
48
- *
49
- * The namespace prefix used for the build.
50
- *
51
- * NOTE:
52
- * For a multi-level build, you must include the 512/768/1024 suffixes
53
- * in MLK_CONFIG_API_NAMESPACE_PREFIX.
54
- *
55
- * - MLK_CONFIG_API_NO_SUPERCOP [optional]
56
- *
57
- * By default, this header will also expose the mlkem-native API in the
58
- * SUPERCOP naming convention crypto_kem_xxx. If you don't want/need this,
59
- * set MLK_CONFIG_API_NO_SUPERCOP. You must set this for a multi-level build.
60
- *
61
- * - MLK_CONFIG_API_CONSTANTS_ONLY [optional]
62
- *
63
- * If you don't want this header to expose any function declarations,
64
- * but only constants for the sizes of key material, set
65
- * MLK_CONFIG_API_CONSTANTS_ONLY. In this case, you don't need to set
66
- * MLK_CONFIG_API_PARAMETER_SET or MLK_CONFIG_API_NAMESPACE_PREFIX,
67
- * nor include a configuration.
68
- *
69
- * - MLK_CONFIG_API_QUALIFIER [optional]
70
- *
71
- * Qualifier to apply to external API.
72
- *
73
- ******************************************************************************/
45
+ * In this case, the configuration file must also set
46
+ * MLK_CONFIG_MULTILEVEL_BUILD. Without it, the parameter set is not appended
47
+ * to the namespace prefix and all inclusions declare the same symbol names.
48
+ */
74
49
 
75
50
  /******************************* Key sizes ************************************/
76
51
 
77
52
  /* Sizes of cryptographic material, per parameter set */
78
- /* See mlkem/common.h for the arithmetic expressions giving rise to these */
53
+ /* See mlkem/src/params.h for the arithmetic expressions giving rise to these */
79
54
  /* check-magic: off */
80
55
  #define MLKEM512_SECRETKEYBYTES 1632
81
56
  #define MLKEM512_PUBLICKEYBYTES 800
@@ -111,28 +86,35 @@
111
86
 
112
87
  /****************************** Error codes ***********************************/
113
88
 
114
- /* Generic failure condition */
89
+ /* Generic failure condition. Currently not returned by any function;
90
+ * reserved for failures that no more specific code covers. */
115
91
  #define MLK_ERR_FAIL (-1)
116
92
  /* An allocation failed. This can only happen if MLK_CONFIG_CUSTOM_ALLOC_FREE
117
93
  * is defined and the provided MLK_CUSTOM_ALLOC can fail. */
118
94
  #define MLK_ERR_OUT_OF_MEMORY (-2)
119
- /* An rng failure occured. Might be due to insufficient entropy or
95
+ /* An RNG failure occurred. Might be due to insufficient entropy or
120
96
  * system misconfiguration. */
121
97
  #define MLK_ERR_RNG_FAIL (-3)
122
-
123
- /****************************** Function API **********************************/
98
+ /* Public key validation failed: the @[FIPS203, Section 7.2, 'modulus check']
99
+ * found a coefficient outside [0,q-1]. Returned by check_pk and by the
100
+ * encapsulation API. */
101
+ #define MLK_ERR_INVALID_PK (-4)
102
+ /* Secret key validation failed: the @[FIPS203, Section 7.3, 'hash check']
103
+ * found the embedded public key hash inconsistent. Returned by check_sk and
104
+ * by the decapsulation API. */
105
+ #define MLK_ERR_INVALID_SK (-5)
106
+ /* The 'Pairwise Consistency Test' @[FIPS140_3_IG, p.87] and
107
+ * @[FIPS203, Section 7.1, Pairwise Consistency] failed. Only possible when
108
+ * MLK_CONFIG_KEYGEN_PCT is enabled; signals that the freshly generated key
109
+ * pair failed its encaps/decaps self-test. */
110
+ #define MLK_ERR_PCT_FAIL (-6)
111
+
112
+ /********************* Namespacing and Qualifiers *****************************/
124
113
 
125
114
  #define MLK_API_CONCAT_(x, y) x##y
126
115
  #define MLK_API_CONCAT(x, y) MLK_API_CONCAT_(x, y)
127
116
  #define MLK_API_CONCAT_UNDERSCORE(x, y) MLK_API_CONCAT(MLK_API_CONCAT(x, _), y)
128
117
 
129
- #if !defined(MLK_CONFIG_API_PARAMETER_SET)
130
- /* Recommended configuration via same config file as used for the build. */
131
-
132
- /* For now, we derive the legacy API configuration MLK_CONFIG_API_XXX from
133
- * the config file. In mlkem-native-v2, this will be removed and we will
134
- * exclusively work with MLK_CONFIG_XXX. */
135
-
136
118
  /* You need to make sure the config file is in the include path. */
137
119
  #if defined(MLK_CONFIG_FILE)
138
120
  #include MLK_CONFIG_FILE
@@ -140,35 +122,17 @@
140
122
  #include "mlkem_native_config.h"
141
123
  #endif
142
124
 
143
- #define MLK_CONFIG_API_PARAMETER_SET MLK_CONFIG_PARAMETER_SET
144
-
125
+ /* Namespace prefix for the public API symbols. For multi-level builds, the
126
+ * parameter set is appended to disambiguate the security levels. */
145
127
  #if defined(MLK_CONFIG_MULTILEVEL_BUILD)
146
- #define MLK_CONFIG_API_NAMESPACE_PREFIX \
128
+ #define MLK_API_NAMESPACE_PREFIX \
147
129
  MLK_API_CONCAT(MLK_CONFIG_NAMESPACE_PREFIX, MLK_CONFIG_PARAMETER_SET)
148
130
  #else
149
- #define MLK_CONFIG_API_NAMESPACE_PREFIX MLK_CONFIG_NAMESPACE_PREFIX
131
+ #define MLK_API_NAMESPACE_PREFIX MLK_CONFIG_NAMESPACE_PREFIX
150
132
  #endif
151
133
 
152
- #if defined(MLK_CONFIG_NO_SUPERCOP)
153
- #define MLK_CONFIG_API_NO_SUPERCOP
154
- #endif
155
-
156
- #if defined(MLK_CONFIG_CONSTANTS_ONLY)
157
- #define MLK_CONFIG_API_CONSTANTS_ONLY
158
- #endif
159
-
160
- #if defined(MLK_CONFIG_EXTERNAL_API_QUALIFIER)
161
- #define MLK_CONFIG_API_QUALIFIER MLK_CONFIG_EXTERNAL_API_QUALIFIER
162
- #endif
163
-
164
- #else /* !MLK_CONFIG_API_PARAMETER_SET */
165
-
166
- #define MLK_API_LEGACY_CONFIG
167
-
168
- #endif /* MLK_CONFIG_API_PARAMETER_SET */
169
-
170
134
  #define MLK_API_NAMESPACE(sym) \
171
- MLK_API_CONCAT_UNDERSCORE(MLK_CONFIG_API_NAMESPACE_PREFIX, sym)
135
+ MLK_API_CONCAT_UNDERSCORE(MLK_API_NAMESPACE_PREFIX, sym)
172
136
 
173
137
  #if defined(__GNUC__) || defined(__clang__)
174
138
  #define MLK_API_MUST_CHECK_RETURN_VALUE __attribute__((warn_unused_result))
@@ -176,13 +140,15 @@
176
140
  #define MLK_API_MUST_CHECK_RETURN_VALUE
177
141
  #endif
178
142
 
179
- #if defined(MLK_CONFIG_API_QUALIFIER)
180
- #define MLK_API_QUALIFIER MLK_CONFIG_API_QUALIFIER
143
+ #if defined(MLK_CONFIG_EXTERNAL_API_QUALIFIER)
144
+ #define MLK_API_QUALIFIER MLK_CONFIG_EXTERNAL_API_QUALIFIER
181
145
  #else
182
146
  #define MLK_API_QUALIFIER
183
147
  #endif
184
148
 
185
- #if !defined(MLK_CONFIG_API_CONSTANTS_ONLY)
149
+ /****************************** Function API **********************************/
150
+
151
+ #if !defined(MLK_CONFIG_CONSTANTS_ONLY)
186
152
 
187
153
  #include <stdint.h>
188
154
 
@@ -208,15 +174,17 @@ extern "C"
208
174
  * MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
209
175
  *
210
176
  * @retval 0 Success.
211
- * @retval MLK_ERR_FAIL MLK_CONFIG_KEYGEN_PCT enabled and PCT failed.
177
+ * @retval MLK_ERR_PCT_FAIL MLK_CONFIG_KEYGEN_PCT enabled and PCT failed.
212
178
  * @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
213
179
  * MLK_CUSTOM_ALLOC returned NULL.
180
+ * @retval MLK_ERR_RNG_FAIL MLK_CONFIG_KEYGEN_PCT enabled and random
181
+ * number generation failed within the PCT.
214
182
  */
215
183
  MLK_API_QUALIFIER
216
184
  MLK_API_MUST_CHECK_RETURN_VALUE
217
185
  int MLK_API_NAMESPACE(keypair_derand)(
218
- uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)],
219
- uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)],
186
+ uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_PARAMETER_SET)],
187
+ uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_PARAMETER_SET)],
220
188
  const uint8_t coins[2 * MLKEM_SYMBYTES]
221
189
  #ifdef MLK_CONFIG_CONTEXT_PARAMETER
222
190
  ,
@@ -240,7 +208,7 @@ int MLK_API_NAMESPACE(keypair_derand)(
240
208
  * MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
241
209
  *
242
210
  * @retval 0 Success.
243
- * @retval MLK_ERR_FAIL MLK_CONFIG_KEYGEN_PCT enabled and PCT failed.
211
+ * @retval MLK_ERR_PCT_FAIL MLK_CONFIG_KEYGEN_PCT enabled and PCT failed.
244
212
  * @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
245
213
  * MLK_CUSTOM_ALLOC returned NULL.
246
214
  * @retval MLK_ERR_RNG_FAIL Random number generation failed.
@@ -248,8 +216,8 @@ int MLK_API_NAMESPACE(keypair_derand)(
248
216
  MLK_API_QUALIFIER
249
217
  MLK_API_MUST_CHECK_RETURN_VALUE
250
218
  int MLK_API_NAMESPACE(keypair)(
251
- uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)],
252
- uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)]
219
+ uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_PARAMETER_SET)],
220
+ uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_PARAMETER_SET)]
253
221
  #ifdef MLK_CONFIG_CONTEXT_PARAMETER
254
222
  ,
255
223
  MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
@@ -275,7 +243,7 @@ int MLK_API_NAMESPACE(keypair)(
275
243
  * MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
276
244
  *
277
245
  * @retval 0 Success.
278
- * @retval MLK_ERR_FAIL The 'modulus check' @[FIPS203, Section 7.2]
246
+ * @retval MLK_ERR_INVALID_PK The 'modulus check' @[FIPS203, Section 7.2]
279
247
  * for the public key failed.
280
248
  * @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
281
249
  * MLK_CUSTOM_ALLOC returned NULL.
@@ -283,9 +251,9 @@ int MLK_API_NAMESPACE(keypair)(
283
251
  MLK_API_QUALIFIER
284
252
  MLK_API_MUST_CHECK_RETURN_VALUE
285
253
  int MLK_API_NAMESPACE(enc_derand)(
286
- uint8_t ct[MLKEM_CIPHERTEXTBYTES(MLK_CONFIG_API_PARAMETER_SET)],
254
+ uint8_t ct[MLKEM_CIPHERTEXTBYTES(MLK_CONFIG_PARAMETER_SET)],
287
255
  uint8_t ss[MLKEM_BYTES],
288
- const uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)],
256
+ const uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_PARAMETER_SET)],
289
257
  const uint8_t coins[MLKEM_SYMBYTES]
290
258
  #ifdef MLK_CONFIG_CONTEXT_PARAMETER
291
259
  ,
@@ -309,7 +277,7 @@ int MLK_API_NAMESPACE(enc_derand)(
309
277
  * MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
310
278
  *
311
279
  * @retval 0 Success.
312
- * @retval MLK_ERR_FAIL The 'modulus check' @[FIPS203, Section 7.2]
280
+ * @retval MLK_ERR_INVALID_PK The 'modulus check' @[FIPS203, Section 7.2]
313
281
  * for the public key failed.
314
282
  * @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
315
283
  * MLK_CUSTOM_ALLOC returned NULL.
@@ -318,9 +286,9 @@ int MLK_API_NAMESPACE(enc_derand)(
318
286
  MLK_API_QUALIFIER
319
287
  MLK_API_MUST_CHECK_RETURN_VALUE
320
288
  int MLK_API_NAMESPACE(enc)(
321
- uint8_t ct[MLKEM_CIPHERTEXTBYTES(MLK_CONFIG_API_PARAMETER_SET)],
289
+ uint8_t ct[MLKEM_CIPHERTEXTBYTES(MLK_CONFIG_PARAMETER_SET)],
322
290
  uint8_t ss[MLKEM_BYTES],
323
- const uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)]
291
+ const uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_PARAMETER_SET)]
324
292
  #ifdef MLK_CONFIG_CONTEXT_PARAMETER
325
293
  ,
326
294
  MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
@@ -345,7 +313,7 @@ int MLK_API_NAMESPACE(enc)(
345
313
  * MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
346
314
  *
347
315
  * @retval 0 Success.
348
- * @retval MLK_ERR_FAIL The 'hash check' @[FIPS203, Section 7.3]
316
+ * @retval MLK_ERR_INVALID_SK The 'hash check' @[FIPS203, Section 7.3]
349
317
  * for the secret key failed.
350
318
  * @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
351
319
  * MLK_CUSTOM_ALLOC returned NULL.
@@ -354,8 +322,8 @@ MLK_API_QUALIFIER
354
322
  MLK_API_MUST_CHECK_RETURN_VALUE
355
323
  int MLK_API_NAMESPACE(dec)(
356
324
  uint8_t ss[MLKEM_BYTES],
357
- const uint8_t ct[MLKEM_CIPHERTEXTBYTES(MLK_CONFIG_API_PARAMETER_SET)],
358
- const uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)]
325
+ const uint8_t ct[MLKEM_CIPHERTEXTBYTES(MLK_CONFIG_PARAMETER_SET)],
326
+ const uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_PARAMETER_SET)]
359
327
  #ifdef MLK_CONFIG_CONTEXT_PARAMETER
360
328
  ,
361
329
  MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
@@ -377,7 +345,7 @@ int MLK_API_NAMESPACE(dec)(
377
345
  * MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
378
346
  *
379
347
  * @retval 0 Success.
380
- * @retval MLK_ERR_FAIL Modulus check failed.
348
+ * @retval MLK_ERR_INVALID_PK Modulus check failed.
381
349
  * @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
382
350
  * MLK_CUSTOM_ALLOC returned NULL.
383
351
  */
@@ -385,7 +353,7 @@ int MLK_API_NAMESPACE(dec)(
385
353
  MLK_API_QUALIFIER
386
354
  MLK_API_MUST_CHECK_RETURN_VALUE
387
355
  int MLK_API_NAMESPACE(check_pk)(
388
- const uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)]
356
+ const uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_PARAMETER_SET)]
389
357
  #ifdef MLK_CONFIG_CONTEXT_PARAMETER
390
358
  ,
391
359
  MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
@@ -406,7 +374,7 @@ int MLK_API_NAMESPACE(check_pk)(
406
374
  * MLK_CONFIG_CONTEXT_PARAMETER_TYPE.
407
375
  *
408
376
  * @retval 0 Success.
409
- * @retval MLK_ERR_FAIL Public key hash check failed.
377
+ * @retval MLK_ERR_INVALID_SK Public key hash check failed.
410
378
  * @retval MLK_ERR_OUT_OF_MEMORY MLK_CONFIG_CUSTOM_ALLOC_FREE was used and
411
379
  * MLK_CUSTOM_ALLOC returned NULL.
412
380
  */
@@ -414,7 +382,7 @@ int MLK_API_NAMESPACE(check_pk)(
414
382
  MLK_API_QUALIFIER
415
383
  MLK_API_MUST_CHECK_RETURN_VALUE
416
384
  int MLK_API_NAMESPACE(check_sk)(
417
- const uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)]
385
+ const uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_PARAMETER_SET)]
418
386
  #ifdef MLK_CONFIG_CONTEXT_PARAMETER
419
387
  ,
420
388
  MLK_CONFIG_CONTEXT_PARAMETER_TYPE context
@@ -426,56 +394,9 @@ int MLK_API_NAMESPACE(check_sk)(
426
394
  }
427
395
  #endif
428
396
 
429
- /****************************** SUPERCOP API *********************************/
430
-
431
- #if !defined(MLK_CONFIG_API_NO_SUPERCOP)
432
- /* Export API in SUPERCOP naming scheme CRYPTO_xxx / crypto_kem_xxx */
433
- #define CRYPTO_SECRETKEYBYTES MLKEM_SECRETKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)
434
- #define CRYPTO_PUBLICKEYBYTES MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)
435
- #define CRYPTO_CIPHERTEXTBYTES \
436
- MLKEM_CIPHERTEXTBYTES(MLK_CONFIG_API_PARAMETER_SET)
437
- #define CRYPTO_SYMBYTES MLKEM_SYMBYTES
438
- #define CRYPTO_BYTES MLKEM_BYTES
439
-
440
- #if !defined(MLK_CONFIG_NO_KEYPAIR_API)
441
- #define crypto_kem_keypair_derand MLK_API_NAMESPACE(keypair_derand)
442
- #if !defined(MLK_CONFIG_NO_RANDOMIZED_API)
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)
447
- #define crypto_kem_enc_derand MLK_API_NAMESPACE(enc_derand)
448
- #if !defined(MLK_CONFIG_NO_RANDOMIZED_API)
449
- #define crypto_kem_enc MLK_API_NAMESPACE(enc)
450
- #endif
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)
455
- #define crypto_kem_check_sk MLK_API_NAMESPACE(check_sk)
456
- #endif
457
-
458
- #else /* !MLK_CONFIG_API_NO_SUPERCOP */
397
+ #undef MLK_API_NAMESPACE_PREFIX
459
398
 
460
- /* If the SUPERCOP API is not needed, we can undefine the various helper macros
461
- * above. Otherwise, they are needed for lazy evaluation of crypto_kem_xxx. */
462
- #if !defined(MLK_API_LEGACY_CONFIG)
463
- #undef MLK_CONFIG_API_PARAMETER_SET
464
- #undef MLK_CONFIG_API_NAMESPACE_PREFIX
465
- #undef MLK_CONFIG_API_NO_SUPERCOP
466
- #undef MLK_CONFIG_API_CONSTANTS_ONLY
467
- #undef MLK_CONFIG_API_QUALIFIER
468
- #endif /* !MLK_API_LEGACY_CONFIG */
469
-
470
- #undef MLK_API_CONCAT
471
- #undef MLK_API_CONCAT_
472
- #undef MLK_API_CONCAT_UNDERSCORE
473
- #undef MLK_API_NAMESPACE
474
- #undef MLK_API_MUST_CHECK_RETURN_VALUE
475
- #undef MLK_API_QUALIFIER
476
-
477
- #endif /* MLK_CONFIG_API_NO_SUPERCOP */
478
- #endif /* !MLK_CONFIG_API_CONSTANTS_ONLY */
399
+ #endif /* !MLK_CONFIG_CONSTANTS_ONLY */
479
400
 
480
401
 
481
402
  /***************************** Memory Usage **********************************/
@@ -512,10 +433,8 @@ int MLK_API_NAMESPACE(check_sk)(
512
433
 
513
434
  /*
514
435
  * MLK_TOTAL_ALLOC_*_KEYPAIR adapts based on MLK_CONFIG_KEYGEN_PCT.
515
- * For legacy config, we don't know which options are used, so assume
516
- * the worst case (PCT enabled).
517
436
  */
518
- #if defined(MLK_API_LEGACY_CONFIG) || defined(MLK_CONFIG_KEYGEN_PCT)
437
+ #if defined(MLK_CONFIG_KEYGEN_PCT)
519
438
  #define MLK_TOTAL_ALLOC_512_KEYPAIR MLK_TOTAL_ALLOC_512_KEYPAIR_PCT
520
439
  #define MLK_TOTAL_ALLOC_768_KEYPAIR MLK_TOTAL_ALLOC_768_KEYPAIR_PCT
521
440
  #define MLK_TOTAL_ALLOC_1024_KEYPAIR MLK_TOTAL_ALLOC_1024_KEYPAIR_PCT
@@ -542,6 +461,4 @@ int MLK_API_NAMESPACE(check_sk)(
542
461
  MLK_MAX3_(MLK_TOTAL_ALLOC_1024_KEYPAIR, MLK_TOTAL_ALLOC_1024_ENCAPS, \
543
462
  MLK_TOTAL_ALLOC_1024_DECAPS)
544
463
 
545
- #undef MLK_API_LEGACY_CONFIG
546
-
547
464
  #endif /* !MLK_H */
@@ -145,11 +145,6 @@
145
145
  * Undefine macros from MLK_CONFIG_PARAMETER_SET-specific files
146
146
  */
147
147
  /* mlkem/mlkem_native.h */
148
- #undef CRYPTO_BYTES
149
- #undef CRYPTO_CIPHERTEXTBYTES
150
- #undef CRYPTO_PUBLICKEYBYTES
151
- #undef CRYPTO_SECRETKEYBYTES
152
- #undef CRYPTO_SYMBYTES
153
148
  #undef MLKEM1024_BYTES
154
149
  #undef MLKEM1024_CIPHERTEXTBYTES
155
150
  #undef MLKEM1024_PUBLICKEYBYTES
@@ -176,17 +171,15 @@
176
171
  #undef MLK_API_CONCAT
177
172
  #undef MLK_API_CONCAT_
178
173
  #undef MLK_API_CONCAT_UNDERSCORE
179
- #undef MLK_API_LEGACY_CONFIG
180
174
  #undef MLK_API_MUST_CHECK_RETURN_VALUE
181
175
  #undef MLK_API_NAMESPACE
176
+ #undef MLK_API_NAMESPACE_PREFIX
182
177
  #undef MLK_API_QUALIFIER
183
- #undef MLK_CONFIG_API_CONSTANTS_ONLY
184
- #undef MLK_CONFIG_API_NAMESPACE_PREFIX
185
- #undef MLK_CONFIG_API_NO_SUPERCOP
186
- #undef MLK_CONFIG_API_PARAMETER_SET
187
- #undef MLK_CONFIG_API_QUALIFIER
188
178
  #undef MLK_ERR_FAIL
179
+ #undef MLK_ERR_INVALID_PK
180
+ #undef MLK_ERR_INVALID_SK
189
181
  #undef MLK_ERR_OUT_OF_MEMORY
182
+ #undef MLK_ERR_PCT_FAIL
190
183
  #undef MLK_ERR_RNG_FAIL
191
184
  #undef MLK_H
192
185
  #undef MLK_MAX3_
@@ -208,13 +201,6 @@
208
201
  #undef MLK_TOTAL_ALLOC_768_KEYPAIR
209
202
  #undef MLK_TOTAL_ALLOC_768_KEYPAIR_NO_PCT
210
203
  #undef MLK_TOTAL_ALLOC_768_KEYPAIR_PCT
211
- #undef crypto_kem_check_pk
212
- #undef crypto_kem_check_sk
213
- #undef crypto_kem_dec
214
- #undef crypto_kem_enc
215
- #undef crypto_kem_enc_derand
216
- #undef crypto_kem_keypair
217
- #undef crypto_kem_keypair_derand
218
204
  /* mlkem/src/common.h */
219
205
  #undef MLK_ADD_PARAM_SET
220
206
  #undef MLK_ALLOC
@@ -228,7 +214,10 @@
228
214
  #undef MLK_CONCAT_
229
215
  #undef MLK_EMPTY_CU
230
216
  #undef MLK_ERR_FAIL
217
+ #undef MLK_ERR_INVALID_PK
218
+ #undef MLK_ERR_INVALID_SK
231
219
  #undef MLK_ERR_OUT_OF_MEMORY
220
+ #undef MLK_ERR_PCT_FAIL
232
221
  #undef MLK_ERR_RNG_FAIL
233
222
  #undef MLK_EXTERNAL_API
234
223
  #undef MLK_FIPS202X4_HEADER_FILE
@@ -337,6 +326,7 @@
337
326
  #undef MLK_CONTEXT_PARAMETERS_2
338
327
  #undef MLK_CONTEXT_PARAMETERS_3
339
328
  #undef MLK_CONTEXT_PARAMETERS_4
329
+ #undef MLK_CONTEXT_UNUSED
340
330
  /* mlkem/src/debug.h */
341
331
  #undef MLK_DEBUG_H
342
332
  #undef mlk_assert
@@ -490,23 +480,23 @@
490
480
  /* mlkem/src/fips202/native/aarch64/x1_scalar.h */
491
481
  #undef MLK_FIPS202_AARCH64_NEED_X1_SCALAR
492
482
  #undef MLK_FIPS202_NATIVE_AARCH64_X1_SCALAR_H
493
- #undef MLK_USE_FIPS202_X1_NATIVE
483
+ #undef MLK_USE_NATIVE_FIPS202_X1
494
484
  /* mlkem/src/fips202/native/aarch64/x1_v84a.h */
495
485
  #undef MLK_FIPS202_AARCH64_NEED_X1_V84A
496
486
  #undef MLK_FIPS202_NATIVE_AARCH64_X1_V84A_H
497
- #undef MLK_USE_FIPS202_X1_NATIVE
487
+ #undef MLK_USE_NATIVE_FIPS202_X1
498
488
  /* mlkem/src/fips202/native/aarch64/x2_v84a.h */
499
489
  #undef MLK_FIPS202_AARCH64_NEED_X2_V84A
500
490
  #undef MLK_FIPS202_NATIVE_AARCH64_X2_V84A_H
501
- #undef MLK_USE_FIPS202_X4_NATIVE
491
+ #undef MLK_USE_NATIVE_FIPS202_X4
502
492
  /* mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h */
503
493
  #undef MLK_FIPS202_AARCH64_NEED_X4_V8A_SCALAR_HYBRID
504
494
  #undef MLK_FIPS202_NATIVE_AARCH64_X4_V8A_SCALAR_H
505
- #undef MLK_USE_FIPS202_X4_NATIVE
495
+ #undef MLK_USE_NATIVE_FIPS202_X4
506
496
  /* mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h */
507
497
  #undef MLK_FIPS202_AARCH64_NEED_X4_V8A_V84A_SCALAR_HYBRID
508
498
  #undef MLK_FIPS202_NATIVE_AARCH64_X4_V8A_V84A_SCALAR_H
509
- #undef MLK_USE_FIPS202_X4_NATIVE
499
+ #undef MLK_USE_NATIVE_FIPS202_X4
510
500
  #endif /* MLK_SYS_AARCH64 */
511
501
  #if defined(MLK_SYS_X86_64)
512
502
  /*
@@ -515,7 +505,7 @@
515
505
  /* mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h */
516
506
  #undef MLK_FIPS202_NATIVE_X86_64_KECCAK_F1600_X4_AVX2_H
517
507
  #undef MLK_FIPS202_X86_64_NEED_X4_AVX2
518
- #undef MLK_USE_FIPS202_X4_NATIVE
508
+ #undef MLK_USE_NATIVE_FIPS202_X4
519
509
  /* mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h */
520
510
  #undef MLK_FIPS202_NATIVE_X86_64_SRC_FIPS202_NATIVE_X86_64_H
521
511
  #undef mlk_keccak_f1600_x4_avx2_asm
@@ -531,9 +521,9 @@
531
521
  #undef MLK_FIPS202_ARMV81M_NEED_X4
532
522
  #undef MLK_FIPS202_NATIVE_ARMV81M
533
523
  #undef MLK_FIPS202_NATIVE_ARMV81M_MVE_H
534
- #undef MLK_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE
535
- #undef MLK_USE_FIPS202_X4_NATIVE
536
- #undef MLK_USE_FIPS202_X4_XOR_BYTES_NATIVE
524
+ #undef MLK_USE_NATIVE_FIPS202_X4
525
+ #undef MLK_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES
526
+ #undef MLK_USE_NATIVE_FIPS202_X4_XOR_BYTES
537
527
  #undef mlk_keccak_f1600_x4_native_impl
538
528
  /* mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h */
539
529
  #undef MLK_FIPS202_NATIVE_ARMV81M_SRC_FIPS202_NATIVE_ARMV81M_H