pq_crypto 0.6.1 → 0.6.2

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 (141) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/SECURITY.md +7 -0
  4. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  5. data/ext/pqcrypto/vendor/.vendored +4 -4
  6. data/ext/pqcrypto/vendor/mldsa-native/README.md +23 -10
  7. data/ext/pqcrypto/vendor/mldsa-native/mldsa/README.md +23 -0
  8. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +114 -58
  9. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +498 -461
  10. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +145 -85
  11. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +456 -422
  12. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +47 -25
  13. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +26 -14
  14. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +56 -81
  15. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +17 -24
  16. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.c +33 -40
  17. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +67 -87
  18. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +19 -14
  19. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +13 -5
  20. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +84 -10
  21. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +10 -5
  22. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +6 -0
  23. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +22 -15
  24. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +376 -0
  25. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +204 -0
  26. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +259 -0
  27. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +1077 -0
  28. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +987 -0
  29. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +16 -10
  30. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +2 -1
  31. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +1 -1
  32. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +4 -2
  33. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +2 -2
  34. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +1 -1
  35. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +60 -0
  36. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +48 -0
  37. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +18 -1
  38. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +658 -582
  39. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +5 -100
  40. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +26 -25
  41. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +334 -0
  42. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +355 -0
  43. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +8 -3
  44. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/{xkcp.h → keccak_f1600_x4_avx2.h} +11 -8
  45. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +44 -0
  46. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +454 -0
  47. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +52 -0
  48. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +37 -28
  49. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +213 -196
  50. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +248 -64
  51. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt_aarch64_asm.S +753 -0
  52. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +129 -0
  53. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +145 -0
  54. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +177 -0
  55. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt_aarch64_asm.S +653 -0
  56. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery_aarch64_asm.S +84 -0
  57. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_aarch64_asm.S +53 -0
  58. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_aarch64_asm.S +55 -0
  59. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_aarch64_asm.S +86 -0
  60. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_aarch64_asm.S +86 -0
  61. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_aarch64_asm.S +103 -0
  62. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_aarch64_asm.S +111 -0
  63. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_aarch64_asm.S +75 -0
  64. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_aarch64_asm.S +72 -0
  65. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +23 -11
  66. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_aarch64_asm.S +189 -0
  67. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_aarch64_asm.S +137 -0
  68. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_aarch64_asm.S +130 -0
  69. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +520 -516
  70. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +34 -33
  71. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +202 -242
  72. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +25 -17
  73. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +112 -28
  74. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +1 -1
  75. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +1 -1
  76. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt_avx2_asm.S +2311 -0
  77. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt_avx2_asm.S +2383 -0
  78. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack_avx2_asm.S +238 -0
  79. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4_avx2_asm.S +139 -0
  80. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5_avx2_asm.S +155 -0
  81. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7_avx2_asm.S +187 -0
  82. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_avx2_asm.S +130 -0
  83. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2_asm.S +190 -0
  84. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +6 -4
  85. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +6 -4
  86. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +9 -8
  87. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +10 -9
  88. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +8 -5
  89. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +8 -5
  90. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +6 -4
  91. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +6 -4
  92. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +130 -129
  93. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +109 -180
  94. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +169 -150
  95. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +56 -40
  96. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +149 -164
  97. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +52 -57
  98. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +132 -167
  99. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +57 -424
  100. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +167 -474
  101. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +308 -0
  102. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +653 -0
  103. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +22 -29
  104. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +37 -43
  105. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +511 -367
  106. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +456 -417
  107. data/lib/pq_crypto/version.rb +1 -1
  108. data/script/vendor_libs.rb +3 -3
  109. metadata +41 -35
  110. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +0 -376
  111. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +0 -204
  112. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +0 -259
  113. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +0 -1077
  114. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +0 -987
  115. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.c +0 -488
  116. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.h +0 -16
  117. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt.S +0 -753
  118. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4.S +0 -129
  119. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5.S +0 -145
  120. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7.S +0 -177
  121. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt.S +0 -653
  122. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery.S +0 -79
  123. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_asm.S +0 -53
  124. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_asm.S +0 -55
  125. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_asm.S +0 -85
  126. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_asm.S +0 -85
  127. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_asm.S +0 -102
  128. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_asm.S +0 -110
  129. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_asm.S +0 -72
  130. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_asm.S +0 -69
  131. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_asm.S +0 -189
  132. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_asm.S +0 -135
  133. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_asm.S +0 -128
  134. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt.S +0 -2311
  135. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt.S +0 -2383
  136. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack.S +0 -239
  137. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise.S +0 -131
  138. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4.S +0 -139
  139. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5.S +0 -155
  140. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7.S +0 -187
  141. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2.c +0 -61
@@ -21,140 +21,178 @@
21
21
  #ifndef MLD_CONFIG_H
22
22
  #define MLD_CONFIG_H
23
23
 
24
- /******************************************************************************
25
- * Name: MLD_CONFIG_PARAMETER_SET
26
- *
27
- * Description: Specifies the parameter set for ML-DSA
28
- * - MLD_CONFIG_PARAMETER_SET=44 corresponds to ML-DSA-44
29
- * - MLD_CONFIG_PARAMETER_SET=65 corresponds to ML-DSA-65
30
- * - MLD_CONFIG_PARAMETER_SET=87 corresponds to ML-DSA-87
24
+ /**
25
+ * MLD_CONFIG_PARAMETER_SET
31
26
  *
32
- * If you want to support multiple parameter sets, build the
33
- * library multiple times and set MLD_CONFIG_MULTILEVEL_BUILD.
34
- * See MLD_CONFIG_MULTILEVEL_BUILD for how to do this while
35
- * minimizing code duplication.
27
+ * Specifies the parameter set for ML-DSA
28
+ * - MLD_CONFIG_PARAMETER_SET=44 corresponds to ML-DSA-44
29
+ * - MLD_CONFIG_PARAMETER_SET=65 corresponds to ML-DSA-65
30
+ * - MLD_CONFIG_PARAMETER_SET=87 corresponds to ML-DSA-87
36
31
  *
37
- * This can also be set using CFLAGS.
32
+ * If you want to support multiple parameter sets, build the
33
+ * library multiple times and set MLD_CONFIG_MULTILEVEL_BUILD.
34
+ * See MLD_CONFIG_MULTILEVEL_BUILD for how to do this while
35
+ * minimizing code duplication.
38
36
  *
39
- *****************************************************************************/
37
+ * This can also be set using CFLAGS.
38
+ */
40
39
  #ifndef MLD_CONFIG_PARAMETER_SET
41
40
  #define MLD_CONFIG_PARAMETER_SET \
42
41
  44 /* Change this for different security strengths */
43
42
  #endif
44
43
 
45
- /******************************************************************************
46
- * Name: MLD_CONFIG_FILE
44
+ /**
45
+ * MLD_CONFIG_FILE
47
46
  *
48
- * Description: If defined, this is a header that will be included instead
49
- * of the default configuration file mldsa/mldsa_native_config.h.
47
+ * If defined, this is a header that will be included instead
48
+ * of the default configuration file mldsa/mldsa_native_config.h.
50
49
  *
51
- * When you need to build mldsa-native in multiple configurations,
52
- * using varying MLD_CONFIG_FILE can be more convenient
53
- * then configuring everything through CFLAGS.
50
+ * When you need to build mldsa-native in multiple configurations,
51
+ * using varying MLD_CONFIG_FILE can be more convenient
52
+ * then configuring everything through CFLAGS.
54
53
  *
55
- * To use, MLD_CONFIG_FILE _must_ be defined prior
56
- * to the inclusion of any mldsa-native headers. For example,
57
- * it can be set by passing `-DMLD_CONFIG_FILE="..."`
58
- * on the command line.
59
- *
60
- *****************************************************************************/
54
+ * To use, MLD_CONFIG_FILE _must_ be defined prior
55
+ * to the inclusion of any mldsa-native headers. For example,
56
+ * it can be set by passing `-DMLD_CONFIG_FILE="..."`
57
+ * on the command line.
58
+ */
61
59
  /* #define MLD_CONFIG_FILE "mldsa_native_config.h" */
62
60
 
63
- /******************************************************************************
64
- * Name: MLD_CONFIG_NAMESPACE_PREFIX
61
+ /**
62
+ * MLD_CONFIG_NAMESPACE_PREFIX
65
63
  *
66
- * Description: The prefix to use to namespace global symbols from mldsa/.
64
+ * The prefix to use to namespace global symbols from mldsa/.
67
65
  *
68
- * In a multi-level build, level-dependent symbols will
69
- * additionally be prefixed with the parameter set (44/65/87).
66
+ * In a multi-level build, level-dependent symbols will
67
+ * additionally be prefixed with the parameter set (44/65/87).
70
68
  *
71
- * This can also be set using CFLAGS.
72
- *
73
- *****************************************************************************/
69
+ * This can also be set using CFLAGS.
70
+ */
74
71
  #if !defined(MLD_CONFIG_NAMESPACE_PREFIX)
75
72
  #define MLD_CONFIG_NAMESPACE_PREFIX MLD_DEFAULT_NAMESPACE_PREFIX
76
73
  #endif
77
74
 
78
- /******************************************************************************
79
- * Name: MLD_CONFIG_MULTILEVEL_BUILD
80
- *
81
- * Description: Set this if the build is part of a multi-level build supporting
82
- * multiple parameter sets.
75
+ /**
76
+ * MLD_CONFIG_MULTILEVEL_BUILD
83
77
  *
84
- * If you need only a single parameter set, keep this unset.
78
+ * Set this if the build is part of a multi-level build supporting
79
+ * multiple parameter sets.
85
80
  *
86
- * To build mldsa-native with support for all parameter sets,
87
- * build it three times -- once per parameter set -- and set the
88
- * option MLD_CONFIG_MULTILEVEL_WITH_SHARED for exactly one of
89
- * them, and MLD_CONFIG_MULTILEVEL_NO_SHARED for the others.
90
- * MLD_CONFIG_MULTILEVEL_BUILD should be set for all of them.
81
+ * If you need only a single parameter set, keep this unset.
91
82
  *
92
- * See examples/multilevel_build for an example.
83
+ * To build mldsa-native with support for all parameter sets,
84
+ * build it three times -- once per parameter set -- and set the
85
+ * option MLD_CONFIG_MULTILEVEL_WITH_SHARED for exactly one of
86
+ * them, and MLD_CONFIG_MULTILEVEL_NO_SHARED for the others.
87
+ * MLD_CONFIG_MULTILEVEL_BUILD should be set for all of them.
93
88
  *
94
- * This can also be set using CFLAGS.
89
+ * See examples/multilevel_build for an example.
95
90
  *
96
- *****************************************************************************/
91
+ * This can also be set using CFLAGS.
92
+ */
97
93
  /* #define MLD_CONFIG_MULTILEVEL_BUILD */
98
94
 
99
- /******************************************************************************
100
- * Name: MLD_CONFIG_EXTERNAL_API_QUALIFIER
101
- *
102
- * Description: If set, this option provides an additional function
103
- * qualifier to be added to declarations of mldsa-native's
104
- * public API.
95
+ /**
96
+ * MLD_CONFIG_EXTERNAL_API_QUALIFIER
105
97
  *
106
- * The primary use case for this option are single-CU builds
107
- * where the public API exposed by mldsa-native is wrapped by
108
- * another API in the consuming application. In this case,
109
- * even mldsa-native's public API can be marked `static`.
98
+ * If set, this option provides an additional function
99
+ * qualifier to be added to declarations of mldsa-native's
100
+ * public API.
110
101
  *
111
- *****************************************************************************/
102
+ * The primary use case for this option are single-CU builds
103
+ * where the public API exposed by mldsa-native is wrapped by
104
+ * another API in the consuming application. In this case,
105
+ * even mldsa-native's public API can be marked `static`.
106
+ */
112
107
  /* #define MLD_CONFIG_EXTERNAL_API_QUALIFIER */
113
108
 
114
- /******************************************************************************
115
- * Name: MLD_CONFIG_NO_RANDOMIZED_API
109
+ /**
110
+ * MLD_CONFIG_NO_KEYPAIR_API
116
111
  *
117
- * Description: If this option is set, mldsa-native will be built without the
118
- * randomized API functions (crypto_sign_keypair,
119
- * crypto_sign, crypto_sign_signature, and
120
- * crypto_sign_signature_extmu).
121
- * This allows users to build mldsa-native without providing a
122
- * randombytes() implementation if they only need the
123
- * internal deterministic API
124
- * (crypto_sign_keypair_internal, crypto_sign_signature_internal).
125
- *
126
- * NOTE: This option is incompatible with MLD_CONFIG_KEYGEN_PCT
127
- * as the current PCT implementation requires
128
- * crypto_sign_signature().
112
+ * By default, mldsa-native includes support for generating key
113
+ * pairs. If you don't need this, set MLD_CONFIG_NO_KEYPAIR_API
114
+ * to exclude crypto_sign_keypair, crypto_sign_keypair_internal,
115
+ * crypto_sign_pk_from_sk, and all internal APIs only needed by
116
+ * those functions.
117
+ */
118
+ /* #define MLD_CONFIG_NO_KEYPAIR_API */
119
+
120
+ /**
121
+ * MLD_CONFIG_NO_SIGN_API
122
+ *
123
+ * By default, mldsa-native includes support for creating
124
+ * signatures. If you don't need this, set MLD_CONFIG_NO_SIGN_API
125
+ * to exclude crypto_sign, crypto_sign_signature,
126
+ * crypto_sign_signature_extmu, crypto_sign_signature_internal,
127
+ * crypto_sign_signature_pre_hash_internal,
128
+ * crypto_sign_signature_pre_hash_shake256, and all internal APIs
129
+ * only needed by those functions.
130
+ */
131
+ /* #define MLD_CONFIG_NO_SIGN_API */
132
+
133
+ /**
134
+ * MLD_CONFIG_NO_VERIFY_API
135
+ *
136
+ * By default, mldsa-native includes support for verifying
137
+ * signatures. If you don't need this, set
138
+ * MLD_CONFIG_NO_VERIFY_API to exclude crypto_sign_open,
139
+ * crypto_sign_verify, crypto_sign_verify_extmu,
140
+ * crypto_sign_verify_internal,
141
+ * crypto_sign_verify_pre_hash_internal,
142
+ * crypto_sign_verify_pre_hash_shake256, and all internal APIs
143
+ * only needed by those functions.
144
+ */
145
+ /* #define MLD_CONFIG_NO_VERIFY_API */
146
+
147
+ /**
148
+ * MLD_CONFIG_CORE_API_ONLY
129
149
  *
130
- *****************************************************************************/
150
+ * Set this to remove all public APIs except
151
+ * crypto_sign_keypair_internal, crypto_sign_signature_internal,
152
+ * and crypto_sign_verify_internal.
153
+ */
154
+ /* #define MLD_CONFIG_CORE_API_ONLY */
155
+
156
+ /**
157
+ * MLD_CONFIG_NO_RANDOMIZED_API
158
+ *
159
+ * If this option is set, mldsa-native will be built without the
160
+ * randomized API functions (crypto_sign_keypair,
161
+ * crypto_sign, crypto_sign_signature, and
162
+ * crypto_sign_signature_extmu).
163
+ * This allows users to build mldsa-native without providing a
164
+ * randombytes() implementation if they only need the
165
+ * internal deterministic API
166
+ * (crypto_sign_keypair_internal, crypto_sign_signature_internal).
167
+ *
168
+ * @note This option is incompatible with MLD_CONFIG_KEYGEN_PCT
169
+ * as the current PCT implementation requires
170
+ * crypto_sign_signature().
171
+ */
131
172
  /* #define MLD_CONFIG_NO_RANDOMIZED_API */
132
173
 
133
- /******************************************************************************
134
- * Name: MLD_CONFIG_NO_SUPERCOP
174
+ /**
175
+ * MLD_CONFIG_NO_SUPERCOP
135
176
  *
136
- * Description: By default, mldsa_native.h exposes the mldsa-native API in the
137
- * SUPERCOP naming convention (crypto_sign_xxx). If you don't need
138
- * this, set MLD_CONFIG_NO_SUPERCOP.
177
+ * By default, mldsa_native.h exposes the mldsa-native API in the
178
+ * SUPERCOP naming convention (crypto_sign_xxx). If you don't need
179
+ * this, set MLD_CONFIG_NO_SUPERCOP.
139
180
  *
140
- * NOTE: You must set this for a multi-level build as the SUPERCOP
141
- * naming does not disambiguate between the parameter sets.
142
- *
143
- *****************************************************************************/
181
+ * @note You must set this for a multi-level build as the SUPERCOP
182
+ * naming does not disambiguate between the parameter sets.
183
+ */
144
184
  /* #define MLD_CONFIG_NO_SUPERCOP */
145
185
 
146
- /******************************************************************************
147
- * Name: MLD_CONFIG_CONSTANTS_ONLY
186
+ /**
187
+ * MLD_CONFIG_CONSTANTS_ONLY
148
188
  *
149
- * Description: If you only need the size constants (MLDSA_PUBLICKEYBYTES, etc.)
150
- * but no function declarations, set MLD_CONFIG_CONSTANTS_ONLY.
189
+ * If you only need the size constants (MLDSA_PUBLICKEYBYTES, etc.)
190
+ * but no function declarations, set MLD_CONFIG_CONSTANTS_ONLY.
151
191
  *
152
- * This only affects the public header mldsa_native.h, not
153
- * the implementation.
154
- *
155
- *****************************************************************************/
192
+ * This only affects the public header mldsa_native.h, not
193
+ * the implementation.
194
+ */
156
195
  /* #define MLD_CONFIG_CONSTANTS_ONLY */
157
-
158
196
  /******************************************************************************
159
197
  *
160
198
  * Build-only configuration options
@@ -163,214 +201,202 @@
163
201
  * They do not affect the API described in mldsa_native.h.
164
202
  *
165
203
  *****************************************************************************/
166
-
167
204
  #if defined(MLD_BUILD_INTERNAL)
168
- /******************************************************************************
169
- * Name: MLD_CONFIG_MULTILEVEL_WITH_SHARED
170
- *
171
- * Description: This is for multi-level builds of mldsa-native only. If you
172
- * need only a single parameter set, keep this unset.
205
+
206
+ /**
207
+ * MLD_CONFIG_MULTILEVEL_WITH_SHARED
173
208
  *
174
- * If this is set, all MLD_CONFIG_PARAMETER_SET-independent
175
- * code will be included in the build, including code needed only
176
- * for other parameter sets.
209
+ * This is for multi-level builds of mldsa-native only. If you
210
+ * need only a single parameter set, keep this unset.
177
211
  *
178
- * Example: TODO: add example
212
+ * If this is set, all MLD_CONFIG_PARAMETER_SET-independent
213
+ * code will be included in the build, including code needed only
214
+ * for other parameter sets.
179
215
  *
180
- * To build mldsa-native with support for all parameter sets,
181
- * build it three times -- once per parameter set -- and set the
182
- * option MLD_CONFIG_MULTILEVEL_WITH_SHARED for exactly one of
183
- * them, and MLD_CONFIG_MULTILEVEL_NO_SHARED for the others.
216
+ * Example: TODO: add example
184
217
  *
185
- * See examples/multilevel_build_mldsa for an example.
218
+ * To build mldsa-native with support for all parameter sets,
219
+ * build it three times -- once per parameter set -- and set the
220
+ * option MLD_CONFIG_MULTILEVEL_WITH_SHARED for exactly one of
221
+ * them, and MLD_CONFIG_MULTILEVEL_NO_SHARED for the others.
186
222
  *
187
- * This can also be set using CFLAGS.
223
+ * See examples/multilevel_build_mldsa for an example.
188
224
  *
189
- *****************************************************************************/
225
+ * This can also be set using CFLAGS.
226
+ */
190
227
  /* #define MLD_CONFIG_MULTILEVEL_WITH_SHARED */
191
228
 
192
- /******************************************************************************
193
- * Name: MLD_CONFIG_MULTILEVEL_NO_SHARED
229
+ /**
230
+ * MLD_CONFIG_MULTILEVEL_NO_SHARED
194
231
  *
195
- * Description: This is for multi-level builds of mldsa-native only. If you
196
- * need only a single parameter set, keep this unset.
232
+ * This is for multi-level builds of mldsa-native only. If you
233
+ * need only a single parameter set, keep this unset.
197
234
  *
198
- * If this is set, no MLD_CONFIG_PARAMETER_SET-independent code
199
- * will be included in the build.
235
+ * If this is set, no MLD_CONFIG_PARAMETER_SET-independent code
236
+ * will be included in the build.
200
237
  *
201
- * To build mldsa-native with support for all parameter sets,
202
- * build it three times -- once per parameter set -- and set the
203
- * option MLD_CONFIG_MULTILEVEL_WITH_SHARED for exactly one of
204
- * them, and MLD_CONFIG_MULTILEVEL_NO_SHARED for the others.
238
+ * To build mldsa-native with support for all parameter sets,
239
+ * build it three times -- once per parameter set -- and set the
240
+ * option MLD_CONFIG_MULTILEVEL_WITH_SHARED for exactly one of
241
+ * them, and MLD_CONFIG_MULTILEVEL_NO_SHARED for the others.
205
242
  *
206
- * See examples/multilevel_build_mldsa for an example.
243
+ * See examples/multilevel_build_mldsa for an example.
207
244
  *
208
- * This can also be set using CFLAGS.
209
- *
210
- *****************************************************************************/
245
+ * This can also be set using CFLAGS.
246
+ */
211
247
  /* #define MLD_CONFIG_MULTILEVEL_NO_SHARED */
212
248
 
213
- /******************************************************************************
214
- * Name: MLD_CONFIG_MONOBUILD_KEEP_SHARED_HEADERS
215
- *
216
- * Description: This is only relevant for single compilation unit (SCU)
217
- * builds of mldsa-native. In this case, it determines whether
218
- * directives defined in parameter-set-independent headers should
219
- * be #undef'ined or not at the of the SCU file. This is needed
220
- * in multilevel builds.
249
+ /**
250
+ * MLD_CONFIG_MONOBUILD_KEEP_SHARED_HEADERS
221
251
  *
222
- * See examples/multilevel_build_native for an example.
252
+ * This is only relevant for single compilation unit (SCU)
253
+ * builds of mldsa-native. In this case, it determines whether
254
+ * directives defined in parameter-set-independent headers should
255
+ * be #undef'ined or not at the of the SCU file. This is needed
256
+ * in multilevel builds.
223
257
  *
224
- * This can also be set using CFLAGS.
258
+ * See examples/multilevel_build_native for an example.
225
259
  *
226
- *****************************************************************************/
260
+ * This can also be set using CFLAGS.
261
+ */
227
262
  /* #define MLD_CONFIG_MONOBUILD_KEEP_SHARED_HEADERS */
228
263
 
229
- /******************************************************************************
230
- * Name: MLD_CONFIG_USE_NATIVE_BACKEND_ARITH
231
- *
232
- * Description: Determines whether an native arithmetic backend should be used.
264
+ /**
265
+ * MLD_CONFIG_USE_NATIVE_BACKEND_ARITH
233
266
  *
234
- * The arithmetic backend covers performance critical functions
235
- * such as the number-theoretic transform (NTT).
267
+ * Determines whether an native arithmetic backend should be used.
236
268
  *
237
- * If this option is unset, the C backend will be used.
269
+ * The arithmetic backend covers performance-critical functions
270
+ * such as the number-theoretic transform (NTT).
238
271
  *
239
- * If this option is set, the arithmetic backend to be use is
240
- * determined by MLD_CONFIG_ARITH_BACKEND_FILE: If the latter is
241
- * unset, the default backend for your the target architecture
242
- * will be used. If set, it must be the name of a backend metadata
243
- * file.
272
+ * If this option is unset, the C backend will be used.
244
273
  *
245
- * This can also be set using CFLAGS.
274
+ * If this option is set, the arithmetic backend to be use is
275
+ * determined by MLD_CONFIG_ARITH_BACKEND_FILE: If the latter is
276
+ * unset, the default backend for your the target architecture
277
+ * will be used. If set, it must be the name of a backend metadata
278
+ * file.
246
279
  *
247
- *****************************************************************************/
280
+ * This can also be set using CFLAGS.
281
+ */
248
282
  #if !defined(MLD_CONFIG_USE_NATIVE_BACKEND_ARITH)
249
283
  /* #define MLD_CONFIG_USE_NATIVE_BACKEND_ARITH */
250
284
  #endif
251
285
 
252
- /******************************************************************************
253
- * Name: MLD_CONFIG_ARITH_BACKEND_FILE
286
+ /**
287
+ * MLD_CONFIG_ARITH_BACKEND_FILE
254
288
  *
255
- * Description: The arithmetic backend to use.
289
+ * The arithmetic backend to use.
256
290
  *
257
- * If MLD_CONFIG_USE_NATIVE_BACKEND_ARITH is unset, this option
258
- * is ignored.
291
+ * If MLD_CONFIG_USE_NATIVE_BACKEND_ARITH is unset, this option
292
+ * is ignored.
259
293
  *
260
- * If MLD_CONFIG_USE_NATIVE_BACKEND_ARITH is set, this option must
261
- * either be undefined or the filename of an arithmetic backend.
262
- * If unset, the default backend will be used.
294
+ * If MLD_CONFIG_USE_NATIVE_BACKEND_ARITH is set, this option must
295
+ * either be undefined or the filename of an arithmetic backend.
296
+ * If unset, the default backend will be used.
263
297
  *
264
- * This can be set using CFLAGS.
265
- *
266
- *****************************************************************************/
298
+ * This can be set using CFLAGS.
299
+ */
267
300
  #if defined(MLD_CONFIG_USE_NATIVE_BACKEND_ARITH) && \
268
301
  !defined(MLD_CONFIG_ARITH_BACKEND_FILE)
269
302
  #define MLD_CONFIG_ARITH_BACKEND_FILE "native/meta.h"
270
303
  #endif
271
304
 
272
- /******************************************************************************
273
- * Name: MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202
305
+ /**
306
+ * MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202
274
307
  *
275
- * Description: Determines whether an native FIPS202 backend should be used.
308
+ * Determines whether an native FIPS202 backend should be used.
276
309
  *
277
- * The FIPS202 backend covers 1x/2x/4x-fold Keccak-f1600, which is
278
- * the performance bottleneck of SHA3 and SHAKE.
310
+ * The FIPS202 backend covers 1x/2x/4x-fold Keccak-f1600, which is
311
+ * the performance bottleneck of SHA3 and SHAKE.
279
312
  *
280
- * If this option is unset, the C backend will be used.
313
+ * If this option is unset, the C backend will be used.
281
314
  *
282
- * If this option is set, the FIPS202 backend to be use is
283
- * determined by MLD_CONFIG_FIPS202_BACKEND_FILE: If the latter is
284
- * unset, the default backend for your the target architecture
285
- * will be used. If set, it must be the name of a backend metadata
286
- * file.
315
+ * If this option is set, the FIPS202 backend to be use is
316
+ * determined by MLD_CONFIG_FIPS202_BACKEND_FILE: If the latter is
317
+ * unset, the default backend for your the target architecture
318
+ * will be used. If set, it must be the name of a backend metadata
319
+ * file.
287
320
  *
288
- * This can also be set using CFLAGS.
289
- *
290
- *****************************************************************************/
321
+ * This can also be set using CFLAGS.
322
+ */
291
323
  #if !defined(MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202)
292
324
  /* #define MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 */
293
325
  #endif
294
326
 
295
- /******************************************************************************
296
- * Name: MLD_CONFIG_FIPS202_BACKEND_FILE
297
- *
298
- * Description: The FIPS-202 backend to use.
327
+ /**
328
+ * MLD_CONFIG_FIPS202_BACKEND_FILE
299
329
  *
300
- * If MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 is set, this option
301
- * must either be undefined or the filename of a FIPS202 backend.
302
- * If unset, the default backend will be used.
330
+ * The FIPS-202 backend to use.
303
331
  *
304
- * This can be set using CFLAGS.
332
+ * If MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 is set, this option
333
+ * must either be undefined or the filename of a FIPS202 backend.
334
+ * If unset, the default backend will be used.
305
335
  *
306
- *****************************************************************************/
336
+ * This can be set using CFLAGS.
337
+ */
307
338
  #if defined(MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202) && \
308
339
  !defined(MLD_CONFIG_FIPS202_BACKEND_FILE)
309
340
  #define MLD_CONFIG_FIPS202_BACKEND_FILE "fips202/native/auto.h"
310
341
  #endif
311
342
 
312
- /******************************************************************************
313
- * Name: MLD_CONFIG_FIPS202_CUSTOM_HEADER
314
- *
315
- * Description: Custom header to use for FIPS-202
343
+ /**
344
+ * MLD_CONFIG_FIPS202_CUSTOM_HEADER
316
345
  *
317
- * This should only be set if you intend to use a custom
318
- * FIPS-202 implementation, different from the one shipped
319
- * with mldsa-native.
346
+ * Custom header to use for FIPS-202
320
347
  *
321
- * If set, it must be the name of a file serving as the
322
- * replacement for mldsa/src/fips202/fips202.h, and exposing
323
- * the same API (see FIPS202.md).
348
+ * This should only be set if you intend to use a custom
349
+ * FIPS-202 implementation, different from the one shipped
350
+ * with mldsa-native.
324
351
  *
325
- *****************************************************************************/
352
+ * If set, it must be the name of a file serving as the
353
+ * replacement for mldsa/src/fips202/fips202.h, and exposing
354
+ * the same API (see FIPS202.md).
355
+ */
326
356
  /* #define MLD_CONFIG_FIPS202_CUSTOM_HEADER "SOME_FILE.h" */
327
357
 
328
- /******************************************************************************
329
- * Name: MLD_CONFIG_FIPS202X4_CUSTOM_HEADER
330
- *
331
- * Description: Custom header to use for FIPS-202-X4
358
+ /**
359
+ * MLD_CONFIG_FIPS202X4_CUSTOM_HEADER
332
360
  *
333
- * This should only be set if you intend to use a custom
334
- * FIPS-202 implementation, different from the one shipped
335
- * with mldsa-native.
361
+ * Custom header to use for FIPS-202-X4
336
362
  *
337
- * If set, it must be the name of a file serving as the
338
- * replacement for mldsa/src/fips202/fips202x4.h, and exposing
339
- * the same API (see FIPS202.md).
363
+ * This should only be set if you intend to use a custom
364
+ * FIPS-202 implementation, different from the one shipped
365
+ * with mldsa-native.
340
366
  *
341
- *****************************************************************************/
367
+ * If set, it must be the name of a file serving as the
368
+ * replacement for mldsa/src/fips202/fips202x4.h, and exposing
369
+ * the same API (see FIPS202.md).
370
+ */
342
371
  /* #define MLD_CONFIG_FIPS202X4_CUSTOM_HEADER "SOME_FILE.h" */
343
372
 
344
- /******************************************************************************
345
- * Name: MLD_CONFIG_CUSTOM_ZEROIZE
346
- *
347
- * Description: In compliance with @[FIPS204, Section 3.6.3], mldsa-native,
348
- * zeroizes intermediate stack buffers before returning from
349
- * function calls.
350
- *
351
- * Set this option and define `mld_zeroize` if you want to
352
- * use a custom method to zeroize intermediate stack buffers.
353
- * The default implementation uses SecureZeroMemory on Windows
354
- * and a memset + compiler barrier otherwise. If neither of those
355
- * is available on the target platform, compilation will fail,
356
- * and you will need to use MLD_CONFIG_CUSTOM_ZEROIZE to provide
357
- * a custom implementation of `mld_zeroize()`.
358
- *
359
- * WARNING:
360
- * The explicit stack zeroization conducted by mldsa-native
361
- * reduces the likelihood of data leaking on the stack, but
362
- * does not eliminate it! The C standard makes no guarantee about
363
- * where a compiler allocates structures and whether/where it makes
364
- * copies of them. Also, in addition to entire structures, there
365
- * may also be potentially exploitable leakage of individual values
366
- * on the stack.
367
- *
368
- * If you need bullet-proof zeroization of the stack, you need to
369
- * consider additional measures instead of what this feature
370
- * provides. In this case, you can set mld_zeroize to a
371
- * no-op.
372
- *
373
- *****************************************************************************/
373
+ /**
374
+ * MLD_CONFIG_CUSTOM_ZEROIZE
375
+ *
376
+ * In compliance with @[FIPS204, Section 3.6.3], mldsa-native,
377
+ * zeroizes intermediate stack buffers before returning from
378
+ * function calls.
379
+ *
380
+ * Set this option and define `mld_zeroize` if you want to
381
+ * use a custom method to zeroize intermediate stack buffers.
382
+ * The default implementation uses SecureZeroMemory on Windows
383
+ * and a memset + compiler barrier otherwise. If neither of those
384
+ * is available on the target platform, compilation will fail,
385
+ * and you will need to use MLD_CONFIG_CUSTOM_ZEROIZE to provide
386
+ * a custom implementation of `mld_zeroize()`.
387
+ *
388
+ * @warning The explicit stack zeroization conducted by mldsa-native reduces
389
+ * the likelihood of data leaking on the stack, but does not
390
+ * eliminate it. The C standard makes no guarantee about where a
391
+ * compiler allocates structures and whether/where it makes copies
392
+ * of them. Also, in addition to entire structures, there may also
393
+ * be potentially exploitable leakage of individual values on the
394
+ * stack.
395
+ *
396
+ * If you need bullet-proof zeroization of the stack, you need to
397
+ * consider additional measures instead of what this feature
398
+ * provides. In this case, you can set mld_zeroize to a no-op.
399
+ */
374
400
  /* #define MLD_CONFIG_CUSTOM_ZEROIZE
375
401
  #if !defined(__ASSEMBLER__)
376
402
  #include <stdint.h>
@@ -382,21 +408,20 @@
382
408
  #endif
383
409
  */
384
410
 
385
- /******************************************************************************
386
- * Name: MLD_CONFIG_CUSTOM_RANDOMBYTES
411
+ /**
412
+ * MLD_CONFIG_CUSTOM_RANDOMBYTES
387
413
  *
388
- * Description: mldsa-native does not provide a secure randombytes
389
- * implementation. Such an implementation has to provided by the
390
- * consumer.
414
+ * mldsa-native does not provide a secure randombytes
415
+ * implementation. Such an implementation has to provided by the
416
+ * consumer.
391
417
  *
392
- * If this option is not set, mldsa-native expects a function
393
- * int randombytes(uint8_t *out, size_t outlen).
418
+ * If this option is not set, mldsa-native expects a function
419
+ * int randombytes(uint8_t *out, size_t outlen).
394
420
  *
395
- * Set this option and define `mld_randombytes` if you want to
396
- * use a custom method to sample randombytes with a different name
397
- * or signature.
398
- *
399
- *****************************************************************************/
421
+ * Set this option and define `mld_randombytes` if you want to
422
+ * use a custom method to sample randombytes with a different name
423
+ * or signature.
424
+ */
400
425
  /* #define MLD_CONFIG_CUSTOM_RANDOMBYTES
401
426
  #if !defined(__ASSEMBLER__)
402
427
  #include <stdint.h>
@@ -409,31 +434,30 @@
409
434
  #endif
410
435
  */
411
436
 
412
- /******************************************************************************
413
- * Name: MLD_CONFIG_CUSTOM_CAPABILITY_FUNC
414
- *
415
- * Description: mldsa-native backends may rely on specific hardware features.
416
- * Those backends will only be included in an mldsa-native build
417
- * if support for the respective features is enabled at
418
- * compile-time. However, when building for a heteroneous set
419
- * of CPUs to run the resulting binary/library on, feature
420
- * detection at _runtime_ is needed to decided whether a backend
421
- * can be used or not.
437
+ /**
438
+ * MLD_CONFIG_CUSTOM_CAPABILITY_FUNC
422
439
  *
423
- * Set this option and define `mld_sys_check_capability` if you
424
- * want to use a custom method to dispatch between implementations.
440
+ * mldsa-native backends may rely on specific hardware features.
441
+ * Those backends will only be included in an mldsa-native build
442
+ * if support for the respective features is enabled at
443
+ * compile-time. However, when building for a heteroneous set
444
+ * of CPUs to run the resulting binary/library on, feature
445
+ * detection at _runtime_ is needed to decided whether a backend
446
+ * can be used or not.
425
447
  *
426
- * Return value 1 indicates that a capability is supported.
427
- * Return value 0 indicates that a capability is not supported.
448
+ * Set this option and define `mld_sys_check_capability` if you
449
+ * want to use a custom method to dispatch between implementations.
428
450
  *
429
- * If this option is not set, mldsa-native uses compile-time
430
- * feature detection only to decide which backend to use.
451
+ * Return value 1 indicates that a capability is supported.
452
+ * Return value 0 indicates that a capability is not supported.
431
453
  *
432
- * If you compile mldsa-native on a system with different
433
- * capabilities than the system that the resulting binary/library
434
- * will be run on, you must use this option.
454
+ * If this option is not set, mldsa-native uses compile-time
455
+ * feature detection only to decide which backend to use.
435
456
  *
436
- *****************************************************************************/
457
+ * If you compile mldsa-native on a system with different
458
+ * capabilities than the system that the resulting binary/library
459
+ * will be run on, you must use this option.
460
+ */
437
461
  /* #define MLD_CONFIG_CUSTOM_CAPABILITY_FUNC
438
462
  static MLD_INLINE int mld_sys_check_capability(mld_sys_cap cap)
439
463
  {
@@ -441,41 +465,40 @@
441
465
  }
442
466
  */
443
467
 
444
- /******************************************************************************
445
- * Name: MLD_CONFIG_CUSTOM_ALLOC_FREE [EXPERIMENTAL]
446
- *
447
- * Description: Set this option and define `MLD_CUSTOM_ALLOC` and
448
- * `MLD_CUSTOM_FREE` if you want to use custom allocation for
449
- * large local structures or buffers.
468
+ /**
469
+ * MLD_CONFIG_CUSTOM_ALLOC_FREE
450
470
  *
451
- * By default, all buffers/structures are allocated on the stack.
452
- * If this option is set, most of them will be allocated via
453
- * MLD_CUSTOM_ALLOC.
471
+ * Set this option and define `MLD_CUSTOM_ALLOC` and
472
+ * `MLD_CUSTOM_FREE` if you want to use custom allocation for
473
+ * large local structures or buffers.
454
474
  *
455
- * Parameters to MLD_CUSTOM_ALLOC:
456
- * - T* v: Target pointer to declare.
457
- * - T: Type of structure to be allocated
458
- * - N: Number of elements to be allocated.
475
+ * By default, all buffers/structures are allocated on the stack.
476
+ * If this option is set, most of them will be allocated via
477
+ * MLD_CUSTOM_ALLOC.
459
478
  *
460
- * Parameters to MLD_CUSTOM_FREE:
461
- * - T* v: Target pointer to free. May be NULL.
462
- * - T: Type of structure to be freed.
463
- * - N: Number of elements to be freed.
479
+ * Parameters to MLD_CUSTOM_ALLOC:
480
+ * - T* v: Target pointer to declare.
481
+ * - T: Type of structure to be allocated
482
+ * - N: Number of elements to be allocated.
464
483
  *
465
- * WARNING: This option is experimental!
466
- * Its scope, configuration and function/macro signatures may
467
- * change at any time. We expect a stable API for v2.
484
+ * Parameters to MLD_CUSTOM_FREE:
485
+ * - T* v: Target pointer to free. May be NULL.
486
+ * - T: Type of structure to be freed.
487
+ * - N: Number of elements to be freed.
468
488
  *
469
- * NOTE: Even if this option is set, some allocations further down
470
- * the call stack will still be made from the stack. Those will
471
- * likely be added to the scope of this option in the future.
489
+ * @warning This option is experimental. Its scope, configuration and
490
+ * function/macro signatures may change at any time. We expect a
491
+ * stable API for v2.
472
492
  *
473
- * NOTE: MLD_CUSTOM_ALLOC need not guarantee a successful
474
- * allocation nor include error handling. Upon failure, the
475
- * target pointer should simply be set to NULL. The calling
476
- * code will handle this case and invoke MLD_CUSTOM_FREE.
493
+ * @note Even if this option is set, some allocations further down
494
+ * the call stack will still be made from the stack. Those will
495
+ * likely be added to the scope of this option in the future.
477
496
  *
478
- *****************************************************************************/
497
+ * @note MLD_CUSTOM_ALLOC need not guarantee a successful
498
+ * allocation nor include error handling. Upon failure, the
499
+ * target pointer should simply be set to NULL. The calling
500
+ * code will handle this case and invoke MLD_CUSTOM_FREE.
501
+ */
479
502
  /* #define MLD_CONFIG_CUSTOM_ALLOC_FREE
480
503
  #if !defined(__ASSEMBLER__)
481
504
  #include <stdlib.h>
@@ -486,18 +509,17 @@
486
509
  #endif
487
510
  */
488
511
 
489
- /******************************************************************************
490
- * Name: MLD_CONFIG_CUSTOM_MEMCPY
512
+ /**
513
+ * MLD_CONFIG_CUSTOM_MEMCPY
491
514
  *
492
- * Description: Set this option and define `mld_memcpy` if you want to
493
- * use a custom method to copy memory instead of the standard
494
- * library memcpy function.
515
+ * Set this option and define `mld_memcpy` if you want to
516
+ * use a custom method to copy memory instead of the standard
517
+ * library memcpy function.
495
518
  *
496
- * The custom implementation must have the same signature and
497
- * behavior as the standard memcpy function:
498
- * void *mld_memcpy(void *dest, const void *src, size_t n)
499
- *
500
- *****************************************************************************/
519
+ * The custom implementation must have the same signature and
520
+ * behavior as the standard memcpy function:
521
+ * void *mld_memcpy(void *dest, const void *src, size_t n)
522
+ */
501
523
  /* #define MLD_CONFIG_CUSTOM_MEMCPY
502
524
  #if !defined(__ASSEMBLER__)
503
525
  #include <stdint.h>
@@ -509,18 +531,17 @@
509
531
  #endif
510
532
  */
511
533
 
512
- /******************************************************************************
513
- * Name: MLD_CONFIG_CUSTOM_MEMSET
534
+ /**
535
+ * MLD_CONFIG_CUSTOM_MEMSET
514
536
  *
515
- * Description: Set this option and define `mld_memset` if you want to
516
- * use a custom method to set memory instead of the standard
517
- * library memset function.
537
+ * Set this option and define `mld_memset` if you want to
538
+ * use a custom method to set memory instead of the standard
539
+ * library memset function.
518
540
  *
519
- * The custom implementation must have the same signature and
520
- * behavior as the standard memset function:
521
- * void *mld_memset(void *s, int c, size_t n)
522
- *
523
- *****************************************************************************/
541
+ * The custom implementation must have the same signature and
542
+ * behavior as the standard memset function:
543
+ * void *mld_memset(void *s, int c, size_t n)
544
+ */
524
545
  /* #define MLD_CONFIG_CUSTOM_MEMSET
525
546
  #if !defined(__ASSEMBLER__)
526
547
  #include <stdint.h>
@@ -532,95 +553,93 @@
532
553
  #endif
533
554
  */
534
555
 
535
- /******************************************************************************
536
- * Name: MLD_CONFIG_INTERNAL_API_QUALIFIER
537
- *
538
- * Description: If set, this option provides an additional function
539
- * qualifier to be added to declarations of internal API.
556
+ /**
557
+ * MLD_CONFIG_INTERNAL_API_QUALIFIER
540
558
  *
541
- * The primary use case for this option are single-CU builds,
542
- * in which case this option can be set to `static`.
559
+ * If set, this option provides an additional qualifier
560
+ * to be added to declarations of internal API functions and data.
543
561
  *
544
- *****************************************************************************/
562
+ * The primary use case for this option are single-CU builds,
563
+ * in which case this option can be set to `static`.
564
+ */
545
565
  /* #define MLD_CONFIG_INTERNAL_API_QUALIFIER */
546
566
 
547
- /******************************************************************************
548
- * Name: MLD_CONFIG_CT_TESTING_ENABLED
549
- *
550
- * Description: If set, mldsa-native annotates data as secret / public using
551
- * valgrind's annotations VALGRIND_MAKE_MEM_UNDEFINED and
552
- * VALGRIND_MAKE_MEM_DEFINED, enabling various checks for secret-
553
- * dependent control flow of variable time execution (depending
554
- * on the exact version of valgrind installed).
567
+ /**
568
+ * MLD_CONFIG_CT_TESTING_ENABLED
555
569
  *
556
- *****************************************************************************/
570
+ * If set, mldsa-native annotates data as secret / public using
571
+ * valgrind's annotations VALGRIND_MAKE_MEM_UNDEFINED and
572
+ * VALGRIND_MAKE_MEM_DEFINED, enabling various checks for secret-
573
+ * dependent control flow of variable time execution (depending
574
+ * on the exact version of valgrind installed).
575
+ */
557
576
  /* #define MLD_CONFIG_CT_TESTING_ENABLED */
558
577
 
559
- /******************************************************************************
560
- * Name: MLD_CONFIG_NO_ASM
561
- *
562
- * Description: If this option is set, mldsa-native will be built without
563
- * use of native code or inline assembly.
578
+ /**
579
+ * MLD_CONFIG_NO_ASM
564
580
  *
565
- * By default, inline assembly is used to implement value barriers.
566
- * Without inline assembly, mldsa-native will use a global volatile
567
- * 'opt blocker' instead; see ct.h.
581
+ * If this option is set, mldsa-native will be built without
582
+ * use of native code or inline assembly.
568
583
  *
569
- * Inline assembly is also used to implement a secure zeroization
570
- * function on non-Windows platforms. If this option is set and
571
- * the target platform is not Windows, you MUST set
572
- * MLD_CONFIG_CUSTOM_ZEROIZE and provide a custom zeroization
573
- * function.
584
+ * By default, inline assembly is used to implement value barriers.
585
+ * Without inline assembly, mldsa-native will use a global volatile
586
+ * 'opt blocker' instead; see ct.h.
574
587
  *
575
- * If this option is set, MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 and
576
- * and MLD_CONFIG_USE_NATIVE_BACKEND_ARITH will be ignored, and no
577
- * native backends will be used.
588
+ * Inline assembly is also used to implement a secure zeroization
589
+ * function on non-Windows platforms. If this option is set and
590
+ * the target platform is not Windows, you MUST set
591
+ * MLD_CONFIG_CUSTOM_ZEROIZE and provide a custom zeroization
592
+ * function.
578
593
  *
579
- *****************************************************************************/
594
+ * If this option is set, MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202 and
595
+ * and MLD_CONFIG_USE_NATIVE_BACKEND_ARITH will be ignored, and no
596
+ * native backends will be used.
597
+ */
580
598
  /* #define MLD_CONFIG_NO_ASM */
581
599
 
582
- /******************************************************************************
583
- * Name: MLD_CONFIG_NO_ASM_VALUE_BARRIER
600
+ /**
601
+ * MLD_CONFIG_NO_ASM_VALUE_BARRIER
584
602
  *
585
- * Description: If this option is set, mldsa-native will be built without
586
- * use of native code or inline assembly for value barriers.
603
+ * If this option is set, mldsa-native will be built without
604
+ * use of native code or inline assembly for value barriers.
587
605
  *
588
- * By default, inline assembly (if available) is used to implement
589
- * value barriers.
590
- * Without inline assembly, mldsa-native will use a global volatile
591
- * 'opt blocker' instead; see ct.h.
592
- *
593
- *****************************************************************************/
606
+ * By default, inline assembly (if available) is used to implement
607
+ * value barriers.
608
+ * Without inline assembly, mldsa-native will use a global volatile
609
+ * 'opt blocker' instead; see ct.h.
610
+ */
594
611
  /* #define MLD_CONFIG_NO_ASM_VALUE_BARRIER */
595
612
 
596
- /******************************************************************************
597
- * Name: MLD_CONFIG_KEYGEN_PCT
613
+ /**
614
+ * MLD_CONFIG_KEYGEN_PCT
598
615
  *
599
- * Description: Compliance with @[FIPS140_3_IG, p.87] requires a
600
- * Pairwise Consistency Test (PCT) to be carried out on a freshly
601
- * generated keypair before it can be exported.
616
+ * Compliance with @[FIPS140_3_IG, p.87] requires a
617
+ * Pairwise Consistency Test (PCT) to be carried out on a freshly
618
+ * generated keypair before it can be exported.
602
619
  *
603
- * Set this option if such a check should be implemented.
604
- * In this case, crypto_sign_keypair_internal and
605
- * crypto_sign_keypair will return a non-zero error code if the
606
- * PCT failed.
620
+ * Set this option if such a check should be implemented.
621
+ * In this case, crypto_sign_keypair_internal and
622
+ * crypto_sign_keypair will return a non-zero error code if the
623
+ * PCT failed.
607
624
  *
608
- * NOTE: This feature will drastically lower the performance of
609
- * key generation.
625
+ * @note This feature will drastically lower the performance of
626
+ * key generation.
610
627
  *
611
- *****************************************************************************/
628
+ * @note This option is incompatible with MLD_CONFIG_NO_SIGN_API
629
+ * and MLD_CONFIG_NO_VERIFY_API as the current PCT implementation
630
+ * requires crypto_sign_signature() and crypto_sign_verify().
631
+ */
612
632
  /* #define MLD_CONFIG_KEYGEN_PCT */
613
633
 
614
- /******************************************************************************
615
- * Name: MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST
634
+ /**
635
+ * MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST
616
636
  *
617
- * Description: If this option is set, the user must provide a runtime
618
- * function `static inline int mld_break_pct() { ... }` to
619
- * indicate whether the PCT should be made fail.
637
+ * If this option is set, the user must provide a runtime
638
+ * function `static inline int mld_break_pct() { ... }` to
639
+ * indicate whether the PCT should be made fail.
620
640
  *
621
- * This option only has an effect if MLD_CONFIG_KEYGEN_PCT is set.
622
- *
623
- *****************************************************************************/
641
+ * This option only has an effect if MLD_CONFIG_KEYGEN_PCT is set.
642
+ */
624
643
  /* #define MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST
625
644
  #if !defined(__ASSEMBLER__)
626
645
  #include "src/src.h"
@@ -631,69 +650,84 @@
631
650
  #endif
632
651
  */
633
652
 
634
- /******************************************************************************
635
- * Name: MLD_CONFIG_SERIAL_FIPS202_ONLY
653
+ /**
654
+ * MLD_CONFIG_MAX_SIGNING_ATTEMPTS
636
655
  *
637
- * Description: Set this to use a FIPS202 implementation with global state
638
- * that supports only one active Keccak computation at a time
639
- * (e.g. some hardware accelerators).
656
+ * Upper bound on the number of rejection-sampling iterations
657
+ * performed by ML-DSA signing (@[FIPS204, Algorithm 7]).
640
658
  *
641
- * If this option is set, ML-DSA will use FIPS202 operations
642
- * serially, ensuring that only one SHAKE context is active
643
- * at any given time.
659
+ * If a valid signature is not produced within this many
660
+ * attempts, signing returns MLD_ERR_SIGN_ATTEMPTS_EXHAUSTED.
661
+ * This is useful in timing-sensitive environments that
662
+ * require a deterministic worst-case bound on signing time.
644
663
  *
645
- * This allows offloading Keccak computations to a hardware
646
- * accelerator that holds only a single Keccak state locally,
647
- * rather than requiring support for multiple concurrent
648
- * Keccak states.
664
+ * For FIPS 204 compliance, this value MUST be at least 814,
665
+ * cf. @[FIPS204, Appendix C], which is chosen so that the
666
+ * signing failure rate is < 2^{-256}.
649
667
  *
650
- * NOTE: Depending on the target CPU, this may reduce
651
- * performance when using software FIPS202 implementations.
652
- * Only enable this when you have to.
668
+ * Default: Largest possible value before internal counters
669
+ * would overflow. This is larger than the FIPS204 bound.
653
670
  *
654
- *****************************************************************************/
655
- /* #define MLD_CONFIG_SERIAL_FIPS202_ONLY */
671
+ * In particular, in the default configuration, the signing
672
+ * failure rate is < 2^{-256}.
673
+ */
674
+ /* #define MLD_CONFIG_MAX_SIGNING_ATTEMPTS 814 */
656
675
 
657
- /******************************************************************************
658
- * Name: MLD_CONFIG_CONTEXT_PARAMETER
676
+ /**
677
+ * MLD_CONFIG_SERIAL_FIPS202_ONLY
659
678
  *
660
- * Description: Set this to add a context parameter that is provided to public
661
- * API functions and is then available in custom callbacks.
679
+ * Set this to use a FIPS202 implementation with global state
680
+ * that supports only one active Keccak computation at a time
681
+ * (e.g. some hardware accelerators).
662
682
  *
663
- * The type of the context parameter is configured via
664
- * MLD_CONFIG_CONTEXT_PARAMETER_TYPE.
683
+ * If this option is set, ML-DSA will use FIPS202 operations
684
+ * serially, ensuring that only one SHAKE context is active
685
+ * at any given time.
665
686
  *
666
- *****************************************************************************/
667
- /* #define MLD_CONFIG_CONTEXT_PARAMETER */
687
+ * This allows offloading Keccak computations to a hardware
688
+ * accelerator that holds only a single Keccak state locally,
689
+ * rather than requiring support for multiple concurrent
690
+ * Keccak states.
691
+ *
692
+ * @note Depending on the target CPU, this may reduce
693
+ * performance when using software FIPS202 implementations.
694
+ * Only enable this when you have to.
695
+ */
696
+ /* #define MLD_CONFIG_SERIAL_FIPS202_ONLY */
668
697
 
669
- /******************************************************************************
670
- * Name: MLD_CONFIG_CONTEXT_PARAMETER_TYPE
698
+ /**
699
+ * MLD_CONFIG_CONTEXT_PARAMETER
700
+ *
701
+ * Set this to add a context parameter that is provided to public
702
+ * API functions and is then available in custom callbacks.
671
703
  *
672
- * Description: Set this to define the type for the context parameter used by
673
- * MLD_CONFIG_CONTEXT_PARAMETER.
704
+ * The type of the context parameter is configured via
705
+ * MLD_CONFIG_CONTEXT_PARAMETER_TYPE.
706
+ */
707
+ /* #define MLD_CONFIG_CONTEXT_PARAMETER */
708
+
709
+ /**
710
+ * MLD_CONFIG_CONTEXT_PARAMETER_TYPE
674
711
  *
675
- * This is only relevant if MLD_CONFIG_CONTEXT_PARAMETER is set.
712
+ * Set this to define the type for the context parameter used by
713
+ * MLD_CONFIG_CONTEXT_PARAMETER.
676
714
  *
677
- *****************************************************************************/
715
+ * This is only relevant if MLD_CONFIG_CONTEXT_PARAMETER is set.
716
+ */
678
717
  /* #define MLD_CONFIG_CONTEXT_PARAMETER_TYPE void* */
679
718
 
680
- /******************************************************************************
681
- * Name: MLD_CONFIG_REDUCE_RAM [EXPERIMENTAL]
682
- *
683
- * Description: Set this to reduce RAM usage.
684
- * This trades memory for performance.
719
+ /**
720
+ * MLD_CONFIG_REDUCE_RAM
685
721
  *
686
- * For expected memory usage, see the MLD_TOTAL_ALLOC_* constants
687
- * defined in mldsa_native.h.
722
+ * Set this to reduce RAM usage. This trades memory for performance.
688
723
  *
689
- * This option is useful for embedded systems with tight RAM
690
- * constraints but relaxed performance requirements.
724
+ * For expected memory usage, see the MLD_TOTAL_ALLOC_* constants defined in
725
+ * mldsa_native.h.
691
726
  *
692
- * WARNING: This option is experimental!
693
- * CBMC proofs do not currently cover this configuration option.
694
- * Its scope and configuration may change at any time.
727
+ * This option is useful for embedded systems with tight RAM constraints but
728
+ * relaxed performance requirements.
695
729
  *
696
- *****************************************************************************/
730
+ */
697
731
  /* #define MLD_CONFIG_REDUCE_RAM */
698
732
 
699
733
  /************************* Config internals ********************************/