pq_crypto 0.4.2 → 0.5.0

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 (408) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/GET_STARTED.md +21 -16
  4. data/README.md +26 -0
  5. data/SECURITY.md +22 -16
  6. data/ext/pqcrypto/extconf.rb +148 -99
  7. data/ext/pqcrypto/mldsa_api.h +1 -118
  8. data/ext/pqcrypto/mlkem_api.h +1 -42
  9. data/ext/pqcrypto/pq_externalmu.c +88 -216
  10. data/ext/pqcrypto/pqcrypto_native_api.h +129 -0
  11. data/ext/pqcrypto/pqcrypto_ruby_secure.c +0 -3
  12. data/ext/pqcrypto/pqcrypto_secure.c +135 -117
  13. data/ext/pqcrypto/pqcrypto_secure.h +1 -42
  14. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  15. data/ext/pqcrypto/randombytes.h +9 -0
  16. data/ext/pqcrypto/vendor/.vendored +10 -5
  17. data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +105 -0
  18. data/ext/pqcrypto/vendor/mldsa-native/LICENSE +286 -0
  19. data/ext/pqcrypto/vendor/mldsa-native/META.yml +24 -0
  20. data/ext/pqcrypto/vendor/mldsa-native/README.md +221 -0
  21. data/ext/pqcrypto/vendor/mldsa-native/SECURITY.md +8 -0
  22. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +721 -0
  23. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +975 -0
  24. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +724 -0
  25. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +723 -0
  26. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +166 -0
  27. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +321 -0
  28. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.c +21 -0
  29. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +385 -0
  30. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +73 -0
  31. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +130 -0
  32. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.c +277 -0
  33. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +244 -0
  34. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +182 -0
  35. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +117 -0
  36. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +438 -0
  37. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +105 -0
  38. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +71 -0
  39. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +62 -0
  40. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +376 -0
  41. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +204 -0
  42. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +259 -0
  43. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1077 -0
  44. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +987 -0
  45. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +41 -0
  46. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +26 -0
  47. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +35 -0
  48. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +37 -0
  49. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +27 -0
  50. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +36 -0
  51. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +69 -0
  52. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/README.md +10 -0
  53. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +32 -0
  54. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +20 -0
  55. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +638 -0
  56. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +136 -0
  57. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +52 -0
  58. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +29 -0
  59. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.c +488 -0
  60. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.h +16 -0
  61. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/xkcp.h +31 -0
  62. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +247 -0
  63. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +231 -0
  64. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +150 -0
  65. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt.S +753 -0
  66. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4.S +129 -0
  67. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5.S +145 -0
  68. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7.S +177 -0
  69. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt.S +653 -0
  70. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery.S +79 -0
  71. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_asm.S +53 -0
  72. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_asm.S +55 -0
  73. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_asm.S +85 -0
  74. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_asm.S +85 -0
  75. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_asm.S +102 -0
  76. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_asm.S +110 -0
  77. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_asm.S +72 -0
  78. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_asm.S +69 -0
  79. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +40 -0
  80. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_asm.S +189 -0
  81. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_asm.S +135 -0
  82. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_asm.S +128 -0
  83. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +543 -0
  84. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +62 -0
  85. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +649 -0
  86. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +23 -0
  87. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +315 -0
  88. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +124 -0
  89. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +157 -0
  90. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +27 -0
  91. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt.S +2311 -0
  92. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt.S +2383 -0
  93. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack.S +239 -0
  94. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise.S +131 -0
  95. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4.S +139 -0
  96. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5.S +155 -0
  97. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7.S +187 -0
  98. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2.c +61 -0
  99. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_chknorm_avx2.c +52 -0
  100. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +155 -0
  101. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +155 -0
  102. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +102 -0
  103. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +104 -0
  104. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +91 -0
  105. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +93 -0
  106. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_avx2.c +126 -0
  107. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +155 -0
  108. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +139 -0
  109. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +160 -0
  110. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +293 -0
  111. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +224 -0
  112. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +77 -0
  113. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +991 -0
  114. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +393 -0
  115. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +946 -0
  116. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +360 -0
  117. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +877 -0
  118. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +725 -0
  119. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/randombytes.h +26 -0
  120. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +139 -0
  121. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +249 -0
  122. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +1511 -0
  123. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +806 -0
  124. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/symmetric.h +68 -0
  125. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +268 -0
  126. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/zetas.inc +55 -0
  127. data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +104 -0
  128. data/ext/pqcrypto/vendor/mlkem-native/LICENSE +294 -0
  129. data/ext/pqcrypto/vendor/mlkem-native/META.yml +30 -0
  130. data/ext/pqcrypto/vendor/mlkem-native/README.md +223 -0
  131. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +86 -0
  132. data/ext/pqcrypto/vendor/mlkem-native/SECURITY.md +8 -0
  133. data/ext/pqcrypto/vendor/mlkem-native/mlkem/README.md +23 -0
  134. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +660 -0
  135. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +538 -0
  136. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +681 -0
  137. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +709 -0
  138. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +174 -0
  139. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +274 -0
  140. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +717 -0
  141. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +688 -0
  142. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.c +64 -0
  143. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.h +128 -0
  144. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +251 -0
  145. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +158 -0
  146. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +208 -0
  147. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +80 -0
  148. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +463 -0
  149. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.h +98 -0
  150. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +70 -0
  151. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/fips202_native_aarch64.h +69 -0
  152. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +375 -0
  153. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +203 -0
  154. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +258 -0
  155. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1076 -0
  156. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +986 -0
  157. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +46 -0
  158. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +25 -0
  159. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +34 -0
  160. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +35 -0
  161. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +26 -0
  162. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +35 -0
  163. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/api.h +117 -0
  164. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/README.md +10 -0
  165. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +79 -0
  166. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h +35 -0
  167. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +667 -0
  168. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +40 -0
  169. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +51 -0
  170. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +290 -0
  171. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +314 -0
  172. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +28 -0
  173. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +33 -0
  174. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +41 -0
  175. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2.S +451 -0
  176. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +51 -0
  177. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +622 -0
  178. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +156 -0
  179. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +446 -0
  180. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +326 -0
  181. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/README.md +16 -0
  182. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +122 -0
  183. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +174 -0
  184. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +177 -0
  185. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/intt.S +628 -0
  186. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/ntt.S +562 -0
  187. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_mulcache_compute_asm.S +127 -0
  188. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_reduce_asm.S +150 -0
  189. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tobytes_asm.S +117 -0
  190. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tomont_asm.S +98 -0
  191. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +261 -0
  192. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +314 -0
  193. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +368 -0
  194. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_asm.S +226 -0
  195. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_table.c +542 -0
  196. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +637 -0
  197. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +25 -0
  198. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/README.md +11 -0
  199. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +128 -0
  200. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +45 -0
  201. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +81 -0
  202. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +145 -0
  203. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_izetas.inc +27 -0
  204. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +805 -0
  205. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas.inc +27 -0
  206. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas_basemul.inc +39 -0
  207. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/README.md +4 -0
  208. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +304 -0
  209. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +309 -0
  210. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +94 -0
  211. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +45 -0
  212. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.c +102 -0
  213. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.h +25 -0
  214. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/intt.S +719 -0
  215. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mulcache_compute.S +90 -0
  216. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntt.S +639 -0
  217. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttfrombytes.S +193 -0
  218. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntttobytes.S +181 -0
  219. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttunpack.S +174 -0
  220. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d10.S +382 -0
  221. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d11.S +448 -0
  222. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d4.S +163 -0
  223. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d5.S +220 -0
  224. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d10.S +228 -0
  225. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d11.S +277 -0
  226. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d4.S +180 -0
  227. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d5.S +192 -0
  228. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +502 -0
  229. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +750 -0
  230. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +998 -0
  231. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/reduce.S +218 -0
  232. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_asm.S +103 -0
  233. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_table.c +544 -0
  234. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/tomont.S +155 -0
  235. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/params.h +76 -0
  236. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +572 -0
  237. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +317 -0
  238. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +502 -0
  239. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +668 -0
  240. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/randombytes.h +60 -0
  241. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +362 -0
  242. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +118 -0
  243. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/symmetric.h +70 -0
  244. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +260 -0
  245. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.c +20 -0
  246. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +464 -0
  247. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/zetas.inc +30 -0
  248. data/lib/pq_crypto/version.rb +1 -1
  249. data/lib/pq_crypto.rb +1 -1
  250. data/script/vendor_libs.rb +88 -159
  251. metadata +236 -160
  252. data/ext/pqcrypto/vendor/pqclean/common/aes.c +0 -639
  253. data/ext/pqcrypto/vendor/pqclean/common/aes.h +0 -64
  254. data/ext/pqcrypto/vendor/pqclean/common/compat.h +0 -73
  255. data/ext/pqcrypto/vendor/pqclean/common/crypto_declassify.h +0 -7
  256. data/ext/pqcrypto/vendor/pqclean/common/fips202.c +0 -928
  257. data/ext/pqcrypto/vendor/pqclean/common/fips202.h +0 -166
  258. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/feat.S +0 -168
  259. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.c +0 -684
  260. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.h +0 -60
  261. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SIMD256.c +0 -1028
  262. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SnP.h +0 -50
  263. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-unrolling.macros +0 -198
  264. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile +0 -8
  265. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile.Microsoft_nmake +0 -8
  266. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/SIMD256-config.h +0 -3
  267. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/align.h +0 -34
  268. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/brg_endian.h +0 -142
  269. data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.c +0 -101
  270. data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.h +0 -39
  271. data/ext/pqcrypto/vendor/pqclean/common/randombytes.c +0 -355
  272. data/ext/pqcrypto/vendor/pqclean/common/randombytes.h +0 -27
  273. data/ext/pqcrypto/vendor/pqclean/common/sha2.c +0 -769
  274. data/ext/pqcrypto/vendor/pqclean/common/sha2.h +0 -173
  275. data/ext/pqcrypto/vendor/pqclean/common/sp800-185.c +0 -156
  276. data/ext/pqcrypto/vendor/pqclean/common/sp800-185.h +0 -27
  277. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/LICENSE +0 -5
  278. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/Makefile +0 -19
  279. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/Makefile.Microsoft_nmake +0 -23
  280. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/api.h +0 -18
  281. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/cbd.c +0 -83
  282. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/cbd.h +0 -11
  283. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/indcpa.c +0 -327
  284. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/indcpa.h +0 -22
  285. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/kem.c +0 -164
  286. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/kem.h +0 -23
  287. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/ntt.c +0 -146
  288. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/ntt.h +0 -14
  289. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/params.h +0 -36
  290. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/poly.c +0 -311
  291. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/poly.h +0 -37
  292. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/polyvec.c +0 -198
  293. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/polyvec.h +0 -26
  294. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/reduce.c +0 -41
  295. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/reduce.h +0 -13
  296. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/symmetric-shake.c +0 -71
  297. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/symmetric.h +0 -30
  298. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/verify.c +0 -67
  299. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-1024/clean/verify.h +0 -13
  300. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/LICENSE +0 -5
  301. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/Makefile +0 -19
  302. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/Makefile.Microsoft_nmake +0 -23
  303. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/api.h +0 -18
  304. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/cbd.c +0 -108
  305. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/cbd.h +0 -11
  306. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/indcpa.c +0 -327
  307. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/indcpa.h +0 -22
  308. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/kem.c +0 -164
  309. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/kem.h +0 -23
  310. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/ntt.c +0 -146
  311. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/ntt.h +0 -14
  312. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/params.h +0 -36
  313. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/poly.c +0 -299
  314. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/poly.h +0 -37
  315. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/polyvec.c +0 -188
  316. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/polyvec.h +0 -26
  317. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/reduce.c +0 -41
  318. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/reduce.h +0 -13
  319. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/symmetric-shake.c +0 -71
  320. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/symmetric.h +0 -30
  321. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/verify.c +0 -67
  322. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-512/clean/verify.h +0 -13
  323. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/LICENSE +0 -5
  324. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile +0 -19
  325. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile.Microsoft_nmake +0 -23
  326. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/api.h +0 -18
  327. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.c +0 -83
  328. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.h +0 -11
  329. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.c +0 -327
  330. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.h +0 -22
  331. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.c +0 -164
  332. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.h +0 -23
  333. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.c +0 -146
  334. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.h +0 -14
  335. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/params.h +0 -36
  336. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.c +0 -299
  337. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.h +0 -37
  338. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.c +0 -188
  339. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.h +0 -26
  340. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.c +0 -41
  341. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.h +0 -13
  342. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric-shake.c +0 -71
  343. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric.h +0 -30
  344. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.c +0 -67
  345. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.h +0 -13
  346. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/LICENSE +0 -5
  347. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/Makefile +0 -19
  348. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/Makefile.Microsoft_nmake +0 -23
  349. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/api.h +0 -50
  350. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/ntt.c +0 -98
  351. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/ntt.h +0 -10
  352. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/packing.c +0 -261
  353. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/packing.h +0 -31
  354. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/params.h +0 -44
  355. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/poly.c +0 -848
  356. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/poly.h +0 -52
  357. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/polyvec.c +0 -415
  358. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/polyvec.h +0 -65
  359. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/reduce.c +0 -69
  360. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/reduce.h +0 -17
  361. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/rounding.c +0 -98
  362. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/rounding.h +0 -14
  363. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/sign.c +0 -407
  364. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/sign.h +0 -47
  365. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/symmetric-shake.c +0 -26
  366. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-44/clean/symmetric.h +0 -34
  367. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/LICENSE +0 -5
  368. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile +0 -19
  369. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile.Microsoft_nmake +0 -23
  370. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/api.h +0 -50
  371. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.c +0 -98
  372. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.h +0 -10
  373. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.c +0 -261
  374. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.h +0 -31
  375. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/params.h +0 -44
  376. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.c +0 -799
  377. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.h +0 -52
  378. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.c +0 -415
  379. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.h +0 -65
  380. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.c +0 -69
  381. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.h +0 -17
  382. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.c +0 -92
  383. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.h +0 -14
  384. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.c +0 -407
  385. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.h +0 -47
  386. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric-shake.c +0 -26
  387. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric.h +0 -34
  388. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/LICENSE +0 -5
  389. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/Makefile +0 -19
  390. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/Makefile.Microsoft_nmake +0 -23
  391. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/api.h +0 -50
  392. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/ntt.c +0 -98
  393. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/ntt.h +0 -10
  394. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/packing.c +0 -261
  395. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/packing.h +0 -31
  396. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/params.h +0 -44
  397. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/poly.c +0 -823
  398. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/poly.h +0 -52
  399. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/polyvec.c +0 -415
  400. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/polyvec.h +0 -65
  401. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/reduce.c +0 -69
  402. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/reduce.h +0 -17
  403. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/rounding.c +0 -92
  404. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/rounding.h +0 -14
  405. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/sign.c +0 -407
  406. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/sign.h +0 -47
  407. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/symmetric-shake.c +0 -26
  408. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-87/clean/symmetric.h +0 -34
@@ -0,0 +1,277 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+
6
+ /* References
7
+ * ==========
8
+ *
9
+ * - [FIPS204]
10
+ * FIPS 204 Module-Lattice-Based Digital Signature Standard
11
+ * National Institute of Standards and Technology
12
+ * https://csrc.nist.gov/pubs/fips/204/final
13
+ *
14
+ * - [mupq]
15
+ * Common files for pqm4, pqm3, pqriscv
16
+ * Kannwischer, Petri, Rijneveld, Schwabe, Stoffelen
17
+ * https://github.com/mupq/mupq
18
+ *
19
+ * - [supercop]
20
+ * SUPERCOP benchmarking framework
21
+ * Daniel J. Bernstein
22
+ * http://bench.cr.yp.to/supercop.html
23
+ *
24
+ * - [tweetfips]
25
+ * 'tweetfips202' FIPS202 implementation
26
+ * Van Assche, Bernstein, Schwabe
27
+ * https://keccak.team/2015/tweetfips202.html
28
+ */
29
+
30
+ /* Based on the CC0 implementation from @[mupq] and the public domain
31
+ * implementation @[supercop, crypto_hash/keccakc512/simple/]
32
+ * by Ronny Van Keer, and the public domain @[tweetfips] implementation. */
33
+
34
+ #include <stddef.h>
35
+
36
+ #include "../common.h"
37
+ #include "../ct.h"
38
+ #include "fips202.h"
39
+ #include "keccakf1600.h"
40
+ #if !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
41
+
42
+ /*************************************************
43
+ * Name: keccak_init
44
+ *
45
+ * Description: Initializes the Keccak state.
46
+ *
47
+ * Arguments: - uint64_t *s: pointer to Keccak state
48
+ **************************************************/
49
+ static void keccak_init(uint64_t s[MLD_KECCAK_LANES])
50
+ __contract__(
51
+ requires(memory_no_alias(s, sizeof(uint64_t) * MLD_KECCAK_LANES))
52
+ assigns(memory_slice(s, sizeof(uint64_t) * MLD_KECCAK_LANES))
53
+ )
54
+ {
55
+ mld_memset(s, 0, sizeof(uint64_t) * MLD_KECCAK_LANES);
56
+ }
57
+
58
+ /*************************************************
59
+ * Name: keccak_absorb
60
+ *
61
+ * Description: Absorb step of Keccak; incremental.
62
+ *
63
+ * Arguments: - uint64_t *s: pointer to Keccak state
64
+ * - unsigned int pos: position in current block to be absorbed
65
+ * - unsigned int r: rate in bytes (e.g., 168 for SHAKE128)
66
+ * - const uint8_t *in: pointer to input to be absorbed into s
67
+ * - size_t inlen: length of input in bytes
68
+ *
69
+ * Returns new position pos in current block
70
+ **************************************************/
71
+ static unsigned int keccak_absorb(uint64_t s[MLD_KECCAK_LANES],
72
+ unsigned int pos, unsigned int r,
73
+ const uint8_t *in, size_t inlen)
74
+ __contract__(
75
+ requires(inlen <= MLD_MAX_BUFFER_SIZE)
76
+ requires(r > 0)
77
+ requires(r < sizeof(uint64_t) * MLD_KECCAK_LANES)
78
+ requires(pos <= r)
79
+ requires(memory_no_alias(s, sizeof(uint64_t) * MLD_KECCAK_LANES))
80
+ requires(memory_no_alias(in, inlen))
81
+ assigns(memory_slice(s, sizeof(uint64_t) * MLD_KECCAK_LANES))
82
+ ensures(return_value < r))
83
+ {
84
+ while (inlen >= r - pos)
85
+ __loop__(
86
+ assigns(pos, in, inlen,
87
+ memory_slice(s, sizeof(uint64_t) * MLD_KECCAK_LANES))
88
+ invariant(inlen <= loop_entry(inlen))
89
+ invariant(pos <= r)
90
+ invariant(in == loop_entry(in) + (loop_entry(inlen) - inlen))
91
+ decreases(inlen + pos))
92
+ {
93
+ mld_keccakf1600_xor_bytes(s, in, pos, r - pos);
94
+ inlen -= r - pos;
95
+ in += r - pos;
96
+ mld_keccakf1600_permute(s);
97
+ pos = 0;
98
+ }
99
+ /* Safety: At this point, inlen < r, so the truncation to unsigned is safe. */
100
+ mld_keccakf1600_xor_bytes(s, in, pos, (unsigned)inlen);
101
+
102
+ /* Safety: At this point, inlen < r and pos <= r so the truncation to unsigned
103
+ * is safe. */
104
+ return (unsigned)(pos + inlen);
105
+ }
106
+
107
+ /*************************************************
108
+ * Name: keccak_finalize
109
+ *
110
+ * Description: Finalize absorb step.
111
+ *
112
+ * Arguments: - uint64_t *s: pointer to Keccak state
113
+ * - unsigned int pos: position in current block to be absorbed
114
+ * - unsigned int r: rate in bytes (e.g., 168 for SHAKE128)
115
+ * - uint8_t p: domain separation byte
116
+ **************************************************/
117
+ static void keccak_finalize(uint64_t s[MLD_KECCAK_LANES], unsigned int pos,
118
+ unsigned int r, uint8_t p)
119
+ __contract__(
120
+ requires(pos <= r && r < sizeof(uint64_t) * MLD_KECCAK_LANES)
121
+ requires((r / 8) >= 1)
122
+ requires(memory_no_alias(s, sizeof(uint64_t) * MLD_KECCAK_LANES))
123
+ assigns(memory_slice(s, sizeof(uint64_t) * MLD_KECCAK_LANES))
124
+ )
125
+ {
126
+ uint8_t b = 0x80;
127
+ mld_keccakf1600_xor_bytes(s, &p, pos, 1);
128
+ mld_keccakf1600_xor_bytes(s, &b, r - 1, 1);
129
+ }
130
+
131
+ /*************************************************
132
+ * Name: keccak_squeeze
133
+ *
134
+ * Description: Squeeze step of Keccak. Squeezes arbitratrily many bytes.
135
+ * Modifies the state. Can be called multiple times to keep
136
+ * squeezing, i.e., is incremental.
137
+ *
138
+ * Arguments: - uint8_t *out: pointer to output data
139
+ * - size_t outlen: number of bytes to be squeezed (written to out)
140
+ * - uint64_t *s: pointer to input/output Keccak state
141
+ * - unsigned int pos: number of bytes in current block already
142
+ *squeezed
143
+ * - unsigned int r: rate in bytes (e.g., 168 for SHAKE128)
144
+ *
145
+ * Returns new position pos in current block
146
+ **************************************************/
147
+ static unsigned int keccak_squeeze(uint8_t *out, size_t outlen,
148
+ uint64_t s[MLD_KECCAK_LANES],
149
+ unsigned int pos, unsigned int r)
150
+ __contract__(
151
+ requires((r == SHAKE128_RATE && pos <= SHAKE128_RATE) ||
152
+ (r == SHAKE256_RATE && pos <= SHAKE256_RATE) ||
153
+ (r == SHA3_512_RATE && pos <= SHA3_512_RATE))
154
+ requires(outlen <= 8 * r /* somewhat arbitrary bound */)
155
+ requires(memory_no_alias(s, sizeof(uint64_t) * MLD_KECCAK_LANES))
156
+ requires(memory_no_alias(out, outlen))
157
+ assigns(memory_slice(s, sizeof(uint64_t) * MLD_KECCAK_LANES))
158
+ assigns(memory_slice(out, outlen))
159
+ ensures(return_value <= r))
160
+ {
161
+ unsigned int i;
162
+ size_t out_offset = 0;
163
+
164
+ /* Reference: This code is re-factored from the reference implementation
165
+ * to facilitate proof with CBMC and to improve readability.
166
+ *
167
+ * Take a mutable copy of outlen to count down the number of bytes
168
+ * still to squeeze. The initial value of outlen is needed for the CBMC
169
+ * assigns() clauses. */
170
+ size_t bytes_to_go = outlen;
171
+
172
+ while (bytes_to_go > 0)
173
+ __loop__(
174
+ assigns(i, bytes_to_go, pos, out_offset, memory_slice(s, sizeof(uint64_t) * MLD_KECCAK_LANES), memory_slice(out, outlen))
175
+ invariant(bytes_to_go <= outlen)
176
+ invariant(out_offset == outlen - bytes_to_go)
177
+ invariant(pos <= r)
178
+ decreases(bytes_to_go)
179
+ )
180
+ {
181
+ if (pos == r)
182
+ {
183
+ mld_keccakf1600_permute(s);
184
+ pos = 0;
185
+ }
186
+ /* Safety: If bytes_to_go < r - pos, truncation to unsigned is safe. */
187
+ i = bytes_to_go < r - pos ? (unsigned)bytes_to_go : r - pos;
188
+ mld_keccakf1600_extract_bytes(s, out + out_offset, pos, i);
189
+ bytes_to_go -= i;
190
+ pos += i;
191
+ out_offset += i;
192
+ }
193
+
194
+ return pos;
195
+ }
196
+
197
+ MLD_INTERNAL_API
198
+ void mld_shake128_init(mld_shake128ctx *state)
199
+ {
200
+ keccak_init(state->s);
201
+ state->pos = 0;
202
+ }
203
+
204
+ MLD_INTERNAL_API
205
+ void mld_shake128_absorb(mld_shake128ctx *state, const uint8_t *in,
206
+ size_t inlen)
207
+ {
208
+ state->pos = keccak_absorb(state->s, state->pos, SHAKE128_RATE, in, inlen);
209
+ }
210
+
211
+ MLD_INTERNAL_API
212
+ void mld_shake128_finalize(mld_shake128ctx *state)
213
+ {
214
+ keccak_finalize(state->s, state->pos, SHAKE128_RATE, 0x1F);
215
+ state->pos = SHAKE128_RATE;
216
+ }
217
+
218
+ MLD_INTERNAL_API
219
+ void mld_shake128_squeeze(uint8_t *out, size_t outlen, mld_shake128ctx *state)
220
+ {
221
+ state->pos = keccak_squeeze(out, outlen, state->s, state->pos, SHAKE128_RATE);
222
+ }
223
+
224
+ MLD_INTERNAL_API
225
+ void mld_shake128_release(mld_shake128ctx *state)
226
+ {
227
+ /* @[FIPS204, Section 3.6.3] Destruction of intermediate values. */
228
+ mld_zeroize(state, sizeof(mld_shake128ctx));
229
+ }
230
+
231
+ MLD_INTERNAL_API
232
+ void mld_shake256_init(mld_shake256ctx *state)
233
+ {
234
+ keccak_init(state->s);
235
+ state->pos = 0;
236
+ }
237
+
238
+ MLD_INTERNAL_API
239
+ void mld_shake256_absorb(mld_shake256ctx *state, const uint8_t *in,
240
+ size_t inlen)
241
+ {
242
+ state->pos = keccak_absorb(state->s, state->pos, SHAKE256_RATE, in, inlen);
243
+ }
244
+
245
+ MLD_INTERNAL_API
246
+ void mld_shake256_finalize(mld_shake256ctx *state)
247
+ {
248
+ keccak_finalize(state->s, state->pos, SHAKE256_RATE, 0x1F);
249
+ state->pos = SHAKE256_RATE;
250
+ }
251
+
252
+ MLD_INTERNAL_API
253
+ void mld_shake256_squeeze(uint8_t *out, size_t outlen, mld_shake256ctx *state)
254
+ {
255
+ state->pos = keccak_squeeze(out, outlen, state->s, state->pos, SHAKE256_RATE);
256
+ }
257
+
258
+ MLD_INTERNAL_API
259
+ void mld_shake256_release(mld_shake256ctx *state)
260
+ {
261
+ /* @[FIPS204, Section 3.6.3] Destruction of intermediate values. */
262
+ mld_zeroize(state, sizeof(mld_shake256ctx));
263
+ }
264
+
265
+ MLD_INTERNAL_API
266
+ void mld_shake256(uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen)
267
+ {
268
+ mld_shake256ctx state;
269
+
270
+ mld_shake256_init(&state);
271
+ mld_shake256_absorb(&state, in, inlen);
272
+ mld_shake256_finalize(&state);
273
+ mld_shake256_squeeze(out, outlen, &state);
274
+ mld_shake256_release(&state);
275
+ }
276
+
277
+ #endif /* !MLD_CONFIG_MULTILEVEL_NO_SHARED */
@@ -0,0 +1,244 @@
1
+ /*
2
+ * Copyright (c) The mldsa-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+ #ifndef MLD_FIPS202_FIPS202_H
6
+ #define MLD_FIPS202_FIPS202_H
7
+
8
+ #include <stddef.h>
9
+ #include "../cbmc.h"
10
+ #include "../common.h"
11
+
12
+ #define SHAKE128_RATE 168
13
+ #define SHAKE256_RATE 136
14
+ #define SHA3_256_RATE 136
15
+ #define SHA3_512_RATE 72
16
+ #define MLD_KECCAK_LANES 25
17
+ #define SHA3_256_HASHBYTES 32
18
+ #define SHA3_512_HASHBYTES 64
19
+
20
+
21
+ typedef struct
22
+ {
23
+ uint64_t s[MLD_KECCAK_LANES];
24
+ unsigned int pos;
25
+ } mld_shake128ctx;
26
+
27
+ typedef struct
28
+ {
29
+ uint64_t s[MLD_KECCAK_LANES];
30
+ unsigned int pos;
31
+ } mld_shake256ctx;
32
+
33
+ #define mld_shake128_init MLD_NAMESPACE(shake128_init)
34
+ /*************************************************
35
+ * Name: mld_shake128_init
36
+ *
37
+ * Description: Initializes state for use as SHAKE128 XOF
38
+ *
39
+ * Arguments: - mld_shake128ctx *state: pointer to (uninitialized) state
40
+ **************************************************/
41
+ MLD_INTERNAL_API
42
+ void mld_shake128_init(mld_shake128ctx *state)
43
+ __contract__(
44
+ requires(memory_no_alias(state, sizeof(mld_shake128ctx)))
45
+ assigns(memory_slice(state, sizeof(mld_shake128ctx)))
46
+ ensures(state->pos == 0)
47
+ );
48
+
49
+ #define mld_shake128_absorb MLD_NAMESPACE(shake128_absorb)
50
+ /*************************************************
51
+ * Name: mld_shake128_absorb
52
+ *
53
+ * Description: Absorb step of the SHAKE128 XOF. Absorbs arbitrarily many bytes.
54
+ * Can be called multiple times to absorb multiple chunks of data.
55
+ *
56
+ * Arguments: - mld_shake128ctx *state: pointer to (initialized) output state
57
+ * - const uint8_t *in: pointer to input to be absorbed into s
58
+ * - size_t inlen: length of input in bytes
59
+ **************************************************/
60
+ MLD_INTERNAL_API
61
+ void mld_shake128_absorb(mld_shake128ctx *state, const uint8_t *in,
62
+ size_t inlen)
63
+ __contract__(
64
+ requires(inlen <= MLD_MAX_BUFFER_SIZE)
65
+ requires(memory_no_alias(state, sizeof(mld_shake128ctx)))
66
+ requires(memory_no_alias(in, inlen))
67
+ requires(state->pos <= SHAKE128_RATE)
68
+ assigns(memory_slice(state, sizeof(mld_shake128ctx)))
69
+ ensures(state->pos <= SHAKE128_RATE)
70
+ );
71
+
72
+ #define mld_shake128_finalize MLD_NAMESPACE(shake128_finalize)
73
+ /*************************************************
74
+ * Name: mld_shake128_finalize
75
+ *
76
+ * Description: Concludes the absorb phase of the SHAKE128 XOF.
77
+ *
78
+ * Arguments: - mld_shake128ctx *state: pointer to state
79
+ **************************************************/
80
+ MLD_INTERNAL_API
81
+ void mld_shake128_finalize(mld_shake128ctx *state)
82
+ __contract__(
83
+ requires(memory_no_alias(state, sizeof(mld_shake128ctx)))
84
+ requires(state->pos <= SHAKE128_RATE)
85
+ assigns(memory_slice(state, sizeof(mld_shake128ctx)))
86
+ ensures(state->pos <= SHAKE128_RATE)
87
+ );
88
+
89
+ #define mld_shake128_squeeze MLD_NAMESPACE(shake128_squeeze)
90
+ /*************************************************
91
+ * Name: mld_shake128_squeeze
92
+ *
93
+ * Description: Squeeze step of SHAKE128 XOF. Squeezes arbitrarily many
94
+ * bytes. Can be called multiple times to keep squeezing.
95
+ *
96
+ * Arguments: - uint8_t *out: pointer to output blocks
97
+ * - size_t outlen : number of bytes to be squeezed (written to
98
+ *output)
99
+ * - mld_shake128ctx *s: pointer to input/output state
100
+ **************************************************/
101
+ MLD_INTERNAL_API
102
+ void mld_shake128_squeeze(uint8_t *out, size_t outlen, mld_shake128ctx *state)
103
+ __contract__(
104
+ requires(outlen <= 8 * SHAKE128_RATE /* somewhat arbitrary bound */)
105
+ requires(memory_no_alias(state, sizeof(mld_shake128ctx)))
106
+ requires(memory_no_alias(out, outlen))
107
+ requires(state->pos <= SHAKE128_RATE)
108
+ assigns(memory_slice(state, sizeof(mld_shake128ctx)))
109
+ assigns(memory_slice(out, outlen))
110
+ ensures(state->pos <= SHAKE128_RATE)
111
+ );
112
+
113
+ #define mld_shake128_release MLD_NAMESPACE(shake128_release)
114
+ /*************************************************
115
+ * Name: mld_shake128_release
116
+ *
117
+ * Description: Release and securely zero the SHAKE128 state.
118
+ *
119
+ * Arguments: - mld_shake128ctx *state: pointer to state
120
+ **************************************************/
121
+ MLD_INTERNAL_API
122
+ void mld_shake128_release(mld_shake128ctx *state)
123
+ __contract__(
124
+ requires(memory_no_alias(state, sizeof(mld_shake128ctx)))
125
+ assigns(memory_slice(state, sizeof(mld_shake128ctx)))
126
+ );
127
+
128
+ #define mld_shake256_init MLD_NAMESPACE(shake256_init)
129
+ /*************************************************
130
+ * Name: mld_shake256_init
131
+ *
132
+ * Description: Initializes state for use as SHAKE256 XOF
133
+ *
134
+ * Arguments: - mld_shake256ctx *state: pointer to (uninitialized) state
135
+ **************************************************/
136
+ MLD_INTERNAL_API
137
+ void mld_shake256_init(mld_shake256ctx *state)
138
+ __contract__(
139
+ requires(memory_no_alias(state, sizeof(mld_shake256ctx)))
140
+ assigns(memory_slice(state, sizeof(mld_shake256ctx)))
141
+ ensures(state->pos == 0)
142
+ );
143
+
144
+ #define mld_shake256_absorb MLD_NAMESPACE(shake256_absorb)
145
+ /*************************************************
146
+ * Name: mld_shake256_absorb
147
+ *
148
+ * Description: Absorb step of the SHAKE256 XOF. Absorbs arbitrarily many bytes.
149
+ * Can be called multiple times to absorb multiple chunks of data.
150
+ *
151
+ * Arguments: - mld_shake256ctx *state: pointer to (initialized) output state
152
+ * - const uint8_t *in: pointer to input to be absorbed into s
153
+ * - size_t inlen: length of input in bytes
154
+ **************************************************/
155
+ MLD_INTERNAL_API
156
+ void mld_shake256_absorb(mld_shake256ctx *state, const uint8_t *in,
157
+ size_t inlen)
158
+ __contract__(
159
+ requires(inlen <= MLD_MAX_BUFFER_SIZE)
160
+ requires(memory_no_alias(state, sizeof(mld_shake256ctx)))
161
+ requires(memory_no_alias(in, inlen))
162
+ requires(state->pos <= SHAKE256_RATE)
163
+ assigns(memory_slice(state, sizeof(mld_shake256ctx)))
164
+ ensures(state->pos <= SHAKE256_RATE)
165
+ );
166
+
167
+ #define mld_shake256_finalize MLD_NAMESPACE(shake256_finalize)
168
+ /*************************************************
169
+ * Name: mld_shake256_finalize
170
+ *
171
+ * Description: Concludes the absorb phase of the SHAKE256 XOF.
172
+ *
173
+ * Arguments: - mld_shake256ctx *state: pointer to state
174
+ **************************************************/
175
+ MLD_INTERNAL_API
176
+ void mld_shake256_finalize(mld_shake256ctx *state)
177
+ __contract__(
178
+ requires(memory_no_alias(state, sizeof(mld_shake256ctx)))
179
+ requires(state->pos <= SHAKE256_RATE)
180
+ assigns(memory_slice(state, sizeof(mld_shake256ctx)))
181
+ ensures(state->pos <= SHAKE256_RATE)
182
+ );
183
+
184
+ #define mld_shake256_squeeze MLD_NAMESPACE(shake256_squeeze)
185
+ /*************************************************
186
+ * Name: mld_shake256_squeeze
187
+ *
188
+ * Description: Squeeze step of SHAKE256 XOF. Squeezes arbitrarily many
189
+ * bytes. Can be called multiple times to keep squeezing.
190
+ *
191
+ * Arguments: - uint8_t *out: pointer to output blocks
192
+ * - size_t outlen : number of bytes to be squeezed (written to
193
+ *output)
194
+ * - mld_shake256ctx *s: pointer to input/output state
195
+ **************************************************/
196
+ MLD_INTERNAL_API
197
+ void mld_shake256_squeeze(uint8_t *out, size_t outlen, mld_shake256ctx *state)
198
+ __contract__(
199
+ requires(outlen <= 8 * SHAKE256_RATE /* somewhat arbitrary bound */)
200
+ requires(memory_no_alias(state, sizeof(mld_shake256ctx)))
201
+ requires(memory_no_alias(out, outlen))
202
+ requires(state->pos <= SHAKE256_RATE)
203
+ assigns(memory_slice(state, sizeof(mld_shake256ctx)))
204
+ assigns(memory_slice(out, outlen))
205
+ ensures(state->pos <= SHAKE256_RATE)
206
+ );
207
+
208
+ #define mld_shake256_release MLD_NAMESPACE(shake256_release)
209
+ /*************************************************
210
+ * Name: mld_shake256_release
211
+ *
212
+ * Description: Release and securely zero the SHAKE256 state.
213
+ *
214
+ * Arguments: - mld_shake256ctx *state: pointer to state
215
+ **************************************************/
216
+ MLD_INTERNAL_API
217
+ void mld_shake256_release(mld_shake256ctx *state)
218
+ __contract__(
219
+ requires(memory_no_alias(state, sizeof(mld_shake256ctx)))
220
+ assigns(memory_slice(state, sizeof(mld_shake256ctx)))
221
+ );
222
+
223
+ #define mld_shake256 MLD_NAMESPACE(shake256)
224
+ /*************************************************
225
+ * Name: mld_shake256
226
+ *
227
+ * Description: SHAKE256 XOF with non-incremental API
228
+ *
229
+ * Arguments: - uint8_t *out: pointer to output
230
+ * - size_t outlen: requested output length in bytes
231
+ * - const uint8_t *in: pointer to input
232
+ * - size_t inlen: length of input in bytes
233
+ **************************************************/
234
+ MLD_INTERNAL_API
235
+ void mld_shake256(uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen)
236
+ __contract__(
237
+ requires(inlen <= MLD_MAX_BUFFER_SIZE)
238
+ requires(outlen <= 8 * SHAKE256_RATE /* somewhat arbitrary bound */)
239
+ requires(memory_no_alias(in, inlen))
240
+ requires(memory_no_alias(out, outlen))
241
+ assigns(memory_slice(out, outlen))
242
+ );
243
+
244
+ #endif /* !MLD_FIPS202_FIPS202_H */
@@ -0,0 +1,182 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * Copyright (c) The mldsa-native project authors
4
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
+ */
6
+
7
+ /* References
8
+ * ==========
9
+ *
10
+ * - [FIPS204]
11
+ * FIPS 204 Module-Lattice-Based Digital Signature Standard
12
+ * National Institute of Standards and Technology
13
+ * https://csrc.nist.gov/pubs/fips/204/final
14
+ */
15
+
16
+ #include "../common.h"
17
+ #if !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED) && \
18
+ !defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
19
+
20
+ #include "../ct.h"
21
+ #include "fips202.h"
22
+ #include "fips202x4.h"
23
+ #include "keccakf1600.h"
24
+
25
+ static void mld_keccak_absorb_once_x4(uint64_t *s, uint32_t r,
26
+ const uint8_t *in0, const uint8_t *in1,
27
+ const uint8_t *in2, const uint8_t *in3,
28
+ size_t inlen, uint8_t p)
29
+ __contract__(
30
+ requires(inlen <= MLD_MAX_BUFFER_SIZE)
31
+ requires(memory_no_alias(s, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
32
+ requires(r > 0)
33
+ requires(r <= sizeof(uint64_t) * MLD_KECCAK_LANES)
34
+ requires(memory_no_alias(in0, inlen))
35
+ requires(memory_no_alias(in1, inlen))
36
+ requires(memory_no_alias(in2, inlen))
37
+ requires(memory_no_alias(in3, inlen))
38
+ assigns(memory_slice(s, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY)))
39
+ {
40
+ while (inlen >= r)
41
+ __loop__(
42
+ assigns(inlen, in0, in1, in2, in3, memory_slice(s, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
43
+ invariant(inlen <= loop_entry(inlen))
44
+ invariant(in0 == loop_entry(in0) + (loop_entry(inlen) - inlen))
45
+ invariant(in1 == loop_entry(in1) + (loop_entry(inlen) - inlen))
46
+ invariant(in2 == loop_entry(in2) + (loop_entry(inlen) - inlen))
47
+ invariant(in3 == loop_entry(in3) + (loop_entry(inlen) - inlen))
48
+ decreases(inlen))
49
+ {
50
+ mld_keccakf1600x4_xor_bytes(s, in0, in1, in2, in3, 0, r);
51
+ mld_keccakf1600x4_permute(s);
52
+
53
+ in0 += r;
54
+ in1 += r;
55
+ in2 += r;
56
+ in3 += r;
57
+ inlen -= r;
58
+ }
59
+
60
+ /* Safety: At this point, inlen < r, so the truncations to unsigned are safe
61
+ * below. */
62
+ if (inlen > 0)
63
+ {
64
+ mld_keccakf1600x4_xor_bytes(s, in0, in1, in2, in3, 0, (unsigned)inlen);
65
+ }
66
+
67
+ if (inlen == r - 1)
68
+ {
69
+ p |= 128;
70
+ mld_keccakf1600x4_xor_bytes(s, &p, &p, &p, &p, (unsigned)inlen, 1);
71
+ }
72
+ else
73
+ {
74
+ mld_keccakf1600x4_xor_bytes(s, &p, &p, &p, &p, (unsigned)inlen, 1);
75
+ p = 128;
76
+ mld_keccakf1600x4_xor_bytes(s, &p, &p, &p, &p, r - 1, 1);
77
+ }
78
+ }
79
+
80
+ static void mld_keccak_squeezeblocks_x4(uint8_t *out0, uint8_t *out1,
81
+ uint8_t *out2, uint8_t *out3,
82
+ size_t nblocks, uint64_t *s, uint32_t r)
83
+ __contract__(
84
+ requires(r <= sizeof(uint64_t) * MLD_KECCAK_LANES)
85
+ requires(nblocks <= 8 /* somewhat arbitrary bound */)
86
+ requires(memory_no_alias(s, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
87
+ requires(memory_no_alias(out0, nblocks * r))
88
+ requires(memory_no_alias(out1, nblocks * r))
89
+ requires(memory_no_alias(out2, nblocks * r))
90
+ requires(memory_no_alias(out3, nblocks * r))
91
+ assigns(memory_slice(s, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
92
+ assigns(memory_slice(out0, nblocks * r))
93
+ assigns(memory_slice(out1, nblocks * r))
94
+ assigns(memory_slice(out2, nblocks * r))
95
+ assigns(memory_slice(out3, nblocks * r)))
96
+ {
97
+ while (nblocks > 0)
98
+ __loop__(
99
+ assigns(out0, out1, out2, out3, nblocks,
100
+ memory_slice(s, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY),
101
+ memory_slice(out0, nblocks * r),
102
+ memory_slice(out1, nblocks * r),
103
+ memory_slice(out2, nblocks * r),
104
+ memory_slice(out3, nblocks * r))
105
+ invariant(nblocks <= loop_entry(nblocks) &&
106
+ out0 == loop_entry(out0) + r * (loop_entry(nblocks) - nblocks) &&
107
+ out1 == loop_entry(out1) + r * (loop_entry(nblocks) - nblocks) &&
108
+ out2 == loop_entry(out2) + r * (loop_entry(nblocks) - nblocks) &&
109
+ out3 == loop_entry(out3) + r * (loop_entry(nblocks) - nblocks))
110
+ decreases(nblocks))
111
+ {
112
+ mld_keccakf1600x4_permute(s);
113
+ mld_keccakf1600x4_extract_bytes(s, out0, out1, out2, out3, 0, r);
114
+
115
+ out0 += r;
116
+ out1 += r;
117
+ out2 += r;
118
+ out3 += r;
119
+ nblocks--;
120
+ }
121
+ }
122
+
123
+ #if !defined(MLD_CONFIG_REDUCE_RAM)
124
+ MLD_INTERNAL_API
125
+ void mld_shake128x4_absorb_once(mld_shake128x4ctx *state, const uint8_t *in0,
126
+ const uint8_t *in1, const uint8_t *in2,
127
+ const uint8_t *in3, size_t inlen)
128
+ {
129
+ mld_memset(state, 0, sizeof(mld_shake128x4ctx));
130
+ mld_keccak_absorb_once_x4(state->ctx, SHAKE128_RATE, in0, in1, in2, in3,
131
+ inlen, 0x1F);
132
+ }
133
+
134
+ MLD_INTERNAL_API
135
+ void mld_shake128x4_squeezeblocks(uint8_t *out0, uint8_t *out1, uint8_t *out2,
136
+ uint8_t *out3, size_t nblocks,
137
+ mld_shake128x4ctx *state)
138
+ {
139
+ mld_keccak_squeezeblocks_x4(out0, out1, out2, out3, nblocks, state->ctx,
140
+ SHAKE128_RATE);
141
+ }
142
+
143
+ MLD_INTERNAL_API
144
+ void mld_shake128x4_init(mld_shake128x4ctx *state) { (void)state; }
145
+ MLD_INTERNAL_API
146
+ void mld_shake128x4_release(mld_shake128x4ctx *state)
147
+ {
148
+ /* @[FIPS204, Section 3.6.3] Destruction of intermediate values. */
149
+ mld_zeroize(state, sizeof(mld_shake128x4ctx));
150
+ }
151
+ #endif /* !MLD_CONFIG_REDUCE_RAM */
152
+
153
+ MLD_INTERNAL_API
154
+ void mld_shake256x4_absorb_once(mld_shake256x4ctx *state, const uint8_t *in0,
155
+ const uint8_t *in1, const uint8_t *in2,
156
+ const uint8_t *in3, size_t inlen)
157
+ {
158
+ mld_memset(state, 0, sizeof(mld_shake256x4ctx));
159
+ mld_keccak_absorb_once_x4(state->ctx, SHAKE256_RATE, in0, in1, in2, in3,
160
+ inlen, 0x1F);
161
+ }
162
+
163
+ MLD_INTERNAL_API
164
+ void mld_shake256x4_squeezeblocks(uint8_t *out0, uint8_t *out1, uint8_t *out2,
165
+ uint8_t *out3, size_t nblocks,
166
+ mld_shake256x4ctx *state)
167
+ {
168
+ mld_keccak_squeezeblocks_x4(out0, out1, out2, out3, nblocks, state->ctx,
169
+ SHAKE256_RATE);
170
+ }
171
+
172
+ MLD_INTERNAL_API
173
+ void mld_shake256x4_init(mld_shake256x4ctx *state) { (void)state; }
174
+ MLD_INTERNAL_API
175
+ void mld_shake256x4_release(mld_shake256x4ctx *state)
176
+ {
177
+ /* @[FIPS204, Section 3.6.3] Destruction of intermediate values. */
178
+ mld_zeroize(state, sizeof(mld_shake256x4ctx));
179
+ }
180
+
181
+ #endif /* !MLD_CONFIG_MULTILEVEL_NO_SHARED && !MLD_CONFIG_SERIAL_FIPS202_ONLY \
182
+ */