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
@@ -1,71 +0,0 @@
1
- #include "fips202.h"
2
- #include "params.h"
3
- #include "symmetric.h"
4
- #include <stddef.h>
5
- #include <stdint.h>
6
- #include <string.h>
7
-
8
- /*************************************************
9
- * Name: PQCLEAN_MLKEM512_CLEAN_kyber_shake128_absorb
10
- *
11
- * Description: Absorb step of the SHAKE128 specialized for the Kyber context.
12
- *
13
- * Arguments: - xof_state *state: pointer to (uninitialized) output Keccak state
14
- * - const uint8_t *seed: pointer to KYBER_SYMBYTES input to be absorbed into state
15
- * - uint8_t i: additional byte of input
16
- * - uint8_t j: additional byte of input
17
- **************************************************/
18
- void PQCLEAN_MLKEM512_CLEAN_kyber_shake128_absorb(xof_state *state,
19
- const uint8_t seed[KYBER_SYMBYTES],
20
- uint8_t x,
21
- uint8_t y) {
22
- uint8_t extseed[KYBER_SYMBYTES + 2];
23
-
24
- memcpy(extseed, seed, KYBER_SYMBYTES);
25
- extseed[KYBER_SYMBYTES + 0] = x;
26
- extseed[KYBER_SYMBYTES + 1] = y;
27
-
28
- shake128_absorb(state, extseed, sizeof(extseed));
29
- }
30
-
31
- /*************************************************
32
- * Name: PQCLEAN_MLKEM512_CLEAN_kyber_shake256_prf
33
- *
34
- * Description: Usage of SHAKE256 as a PRF, concatenates secret and public input
35
- * and then generates outlen bytes of SHAKE256 output
36
- *
37
- * Arguments: - uint8_t *out: pointer to output
38
- * - size_t outlen: number of requested output bytes
39
- * - const uint8_t *key: pointer to the key (of length KYBER_SYMBYTES)
40
- * - uint8_t nonce: single-byte nonce (public PRF input)
41
- **************************************************/
42
- void PQCLEAN_MLKEM512_CLEAN_kyber_shake256_prf(uint8_t *out, size_t outlen, const uint8_t key[KYBER_SYMBYTES], uint8_t nonce) {
43
- uint8_t extkey[KYBER_SYMBYTES + 1];
44
-
45
- memcpy(extkey, key, KYBER_SYMBYTES);
46
- extkey[KYBER_SYMBYTES] = nonce;
47
-
48
- shake256(out, outlen, extkey, sizeof(extkey));
49
- }
50
-
51
- /*************************************************
52
- * Name: PQCLEAN_MLKEM512_CLEAN_kyber_shake256_prf
53
- *
54
- * Description: Usage of SHAKE256 as a PRF, concatenates secret and public input
55
- * and then generates outlen bytes of SHAKE256 output
56
- *
57
- * Arguments: - uint8_t *out: pointer to output
58
- * - size_t outlen: number of requested output bytes
59
- * - const uint8_t *key: pointer to the key (of length KYBER_SYMBYTES)
60
- * - uint8_t nonce: single-byte nonce (public PRF input)
61
- **************************************************/
62
- void PQCLEAN_MLKEM512_CLEAN_kyber_shake256_rkprf(uint8_t out[KYBER_SSBYTES], const uint8_t key[KYBER_SYMBYTES], const uint8_t input[KYBER_CIPHERTEXTBYTES]) {
63
- shake256incctx s;
64
-
65
- shake256_inc_init(&s);
66
- shake256_inc_absorb(&s, key, KYBER_SYMBYTES);
67
- shake256_inc_absorb(&s, input, KYBER_CIPHERTEXTBYTES);
68
- shake256_inc_finalize(&s);
69
- shake256_inc_squeeze(out, KYBER_SSBYTES, &s);
70
- shake256_inc_ctx_release(&s);
71
- }
@@ -1,30 +0,0 @@
1
- #ifndef PQCLEAN_MLKEM512_CLEAN_SYMMETRIC_H
2
- #define PQCLEAN_MLKEM512_CLEAN_SYMMETRIC_H
3
- #include "fips202.h"
4
- #include "params.h"
5
- #include <stddef.h>
6
- #include <stdint.h>
7
-
8
-
9
- typedef shake128ctx xof_state;
10
-
11
- void PQCLEAN_MLKEM512_CLEAN_kyber_shake128_absorb(xof_state *s,
12
- const uint8_t seed[KYBER_SYMBYTES],
13
- uint8_t x,
14
- uint8_t y);
15
-
16
- void PQCLEAN_MLKEM512_CLEAN_kyber_shake256_prf(uint8_t *out, size_t outlen, const uint8_t key[KYBER_SYMBYTES], uint8_t nonce);
17
-
18
- void PQCLEAN_MLKEM512_CLEAN_kyber_shake256_rkprf(uint8_t out[KYBER_SSBYTES], const uint8_t key[KYBER_SYMBYTES], const uint8_t input[KYBER_CIPHERTEXTBYTES]);
19
-
20
- #define XOF_BLOCKBYTES SHAKE128_RATE
21
-
22
- #define hash_h(OUT, IN, INBYTES) sha3_256(OUT, IN, INBYTES)
23
- #define hash_g(OUT, IN, INBYTES) sha3_512(OUT, IN, INBYTES)
24
- #define xof_absorb(STATE, SEED, X, Y) PQCLEAN_MLKEM512_CLEAN_kyber_shake128_absorb(STATE, SEED, X, Y)
25
- #define xof_squeezeblocks(OUT, OUTBLOCKS, STATE) shake128_squeezeblocks(OUT, OUTBLOCKS, STATE)
26
- #define xof_ctx_release(STATE) shake128_ctx_release(STATE)
27
- #define prf(OUT, OUTBYTES, KEY, NONCE) PQCLEAN_MLKEM512_CLEAN_kyber_shake256_prf(OUT, OUTBYTES, KEY, NONCE)
28
- #define rkprf(OUT, KEY, INPUT) PQCLEAN_MLKEM512_CLEAN_kyber_shake256_rkprf(OUT, KEY, INPUT)
29
-
30
- #endif /* SYMMETRIC_H */
@@ -1,67 +0,0 @@
1
- #include "compat.h"
2
- #include "verify.h"
3
- #include <stddef.h>
4
- #include <stdint.h>
5
-
6
- /*************************************************
7
- * Name: PQCLEAN_MLKEM512_CLEAN_verify
8
- *
9
- * Description: Compare two arrays for equality in constant time.
10
- *
11
- * Arguments: const uint8_t *a: pointer to first byte array
12
- * const uint8_t *b: pointer to second byte array
13
- * size_t len: length of the byte arrays
14
- *
15
- * Returns 0 if the byte arrays are equal, 1 otherwise
16
- **************************************************/
17
- int PQCLEAN_MLKEM512_CLEAN_verify(const uint8_t *a, const uint8_t *b, size_t len) {
18
- size_t i;
19
- uint8_t r = 0;
20
-
21
- for (i = 0; i < len; i++) {
22
- r |= a[i] ^ b[i];
23
- }
24
-
25
- return (-(uint64_t)r) >> 63;
26
- }
27
-
28
- /*************************************************
29
- * Name: PQCLEAN_MLKEM512_CLEAN_cmov
30
- *
31
- * Description: Copy len bytes from x to r if b is 1;
32
- * don't modify x if b is 0. Requires b to be in {0,1};
33
- * assumes two's complement representation of negative integers.
34
- * Runs in constant time.
35
- *
36
- * Arguments: uint8_t *r: pointer to output byte array
37
- * const uint8_t *x: pointer to input byte array
38
- * size_t len: Amount of bytes to be copied
39
- * uint8_t b: Condition bit; has to be in {0,1}
40
- **************************************************/
41
- void PQCLEAN_MLKEM512_CLEAN_cmov(uint8_t *r, const uint8_t *x, size_t len, uint8_t b) {
42
- size_t i;
43
-
44
- PQCLEAN_PREVENT_BRANCH_HACK(b);
45
-
46
- b = -b;
47
- for (i = 0; i < len; i++) {
48
- r[i] ^= b & (r[i] ^ x[i]);
49
- }
50
- }
51
-
52
-
53
- /*************************************************
54
- * Name: PQCLEAN_MLKEM512_CLEAN_cmov_int16
55
- *
56
- * Description: Copy input v to *r if b is 1, don't modify *r if b is 0.
57
- * Requires b to be in {0,1};
58
- * Runs in constant time.
59
- *
60
- * Arguments: int16_t *r: pointer to output int16_t
61
- * int16_t v: input int16_t
62
- * uint8_t b: Condition bit; has to be in {0,1}
63
- **************************************************/
64
- void PQCLEAN_MLKEM512_CLEAN_cmov_int16(int16_t *r, int16_t v, uint16_t b) {
65
- b = -b;
66
- *r ^= b & ((*r) ^ v);
67
- }
@@ -1,13 +0,0 @@
1
- #ifndef PQCLEAN_MLKEM512_CLEAN_VERIFY_H
2
- #define PQCLEAN_MLKEM512_CLEAN_VERIFY_H
3
- #include "params.h"
4
- #include <stddef.h>
5
- #include <stdint.h>
6
-
7
- int PQCLEAN_MLKEM512_CLEAN_verify(const uint8_t *a, const uint8_t *b, size_t len);
8
-
9
- void PQCLEAN_MLKEM512_CLEAN_cmov(uint8_t *r, const uint8_t *x, size_t len, uint8_t b);
10
-
11
- void PQCLEAN_MLKEM512_CLEAN_cmov_int16(int16_t *r, int16_t v, uint16_t b);
12
-
13
- #endif
@@ -1,5 +0,0 @@
1
- Public Domain (https://creativecommons.org/share-your-work/public-domain/cc0/)
2
-
3
- For Keccak and AES we are using public-domain
4
- code from sources and by authors listed in
5
- comments on top of the respective files.
@@ -1,19 +0,0 @@
1
- # This Makefile can be used with GNU Make or BSD Make
2
-
3
- LIB=libml-kem-768_clean.a
4
- HEADERS=api.h cbd.h indcpa.h kem.h ntt.h params.h poly.h polyvec.h reduce.h symmetric.h verify.h
5
- OBJECTS=cbd.o indcpa.o kem.o ntt.o poly.o polyvec.o reduce.o symmetric-shake.o verify.o
6
-
7
- CFLAGS=-O3 -Wall -Wextra -Wpedantic -Werror -Wmissing-prototypes -Wredundant-decls -std=c99 -I../../../common $(EXTRAFLAGS)
8
-
9
- all: $(LIB)
10
-
11
- %.o: %.c $(HEADERS)
12
- $(CC) $(CFLAGS) -c -o $@ $<
13
-
14
- $(LIB): $(OBJECTS)
15
- $(AR) -r $@ $(OBJECTS)
16
-
17
- clean:
18
- $(RM) $(OBJECTS)
19
- $(RM) $(LIB)
@@ -1,23 +0,0 @@
1
- # This Makefile can be used with Microsoft Visual Studio's nmake using the command:
2
- # nmake /f Makefile.Microsoft_nmake
3
-
4
- LIBRARY=libml-kem-768_clean.lib
5
- OBJECTS=cbd.obj indcpa.obj kem.obj ntt.obj poly.obj polyvec.obj reduce.obj symmetric-shake.obj verify.obj
6
-
7
- # Warning C4146 is raised when a unary minus operator is applied to an
8
- # unsigned type; this has nonetheless been standard and portable for as
9
- # long as there has been a C standard, and we need it for constant-time
10
- # computations. Thus, we disable that spurious warning.
11
- CFLAGS=/nologo /O2 /I ..\..\..\common /W4 /WX /wd4146
12
-
13
- all: $(LIBRARY)
14
-
15
- # Make sure objects are recompiled if headers change.
16
- $(OBJECTS): *.h
17
-
18
- $(LIBRARY): $(OBJECTS)
19
- LIB.EXE /NOLOGO /WX /OUT:$@ $**
20
-
21
- clean:
22
- -DEL $(OBJECTS)
23
- -DEL $(LIBRARY)
@@ -1,18 +0,0 @@
1
- #ifndef PQCLEAN_MLKEM768_CLEAN_API_H
2
- #define PQCLEAN_MLKEM768_CLEAN_API_H
3
-
4
- #include <stdint.h>
5
-
6
- #define PQCLEAN_MLKEM768_CLEAN_CRYPTO_SECRETKEYBYTES 2400
7
- #define PQCLEAN_MLKEM768_CLEAN_CRYPTO_PUBLICKEYBYTES 1184
8
- #define PQCLEAN_MLKEM768_CLEAN_CRYPTO_CIPHERTEXTBYTES 1088
9
- #define PQCLEAN_MLKEM768_CLEAN_CRYPTO_BYTES 32
10
- #define PQCLEAN_MLKEM768_CLEAN_CRYPTO_ALGNAME "ML-KEM-768"
11
-
12
- int PQCLEAN_MLKEM768_CLEAN_crypto_kem_keypair(uint8_t *pk, uint8_t *sk);
13
-
14
- int PQCLEAN_MLKEM768_CLEAN_crypto_kem_enc(uint8_t *ct, uint8_t *ss, const uint8_t *pk);
15
-
16
- int PQCLEAN_MLKEM768_CLEAN_crypto_kem_dec(uint8_t *ss, const uint8_t *ct, const uint8_t *sk);
17
-
18
- #endif
@@ -1,83 +0,0 @@
1
- #include "cbd.h"
2
- #include "params.h"
3
- #include <stdint.h>
4
-
5
- /*************************************************
6
- * Name: load32_littleendian
7
- *
8
- * Description: load 4 bytes into a 32-bit integer
9
- * in little-endian order
10
- *
11
- * Arguments: - const uint8_t *x: pointer to input byte array
12
- *
13
- * Returns 32-bit unsigned integer loaded from x
14
- **************************************************/
15
- static uint32_t load32_littleendian(const uint8_t x[4]) {
16
- uint32_t r;
17
- r = (uint32_t)x[0];
18
- r |= (uint32_t)x[1] << 8;
19
- r |= (uint32_t)x[2] << 16;
20
- r |= (uint32_t)x[3] << 24;
21
- return r;
22
- }
23
-
24
- /*************************************************
25
- * Name: load24_littleendian
26
- *
27
- * Description: load 3 bytes into a 32-bit integer
28
- * in little-endian order.
29
- * This function is only needed for Kyber-512
30
- *
31
- * Arguments: - const uint8_t *x: pointer to input byte array
32
- *
33
- * Returns 32-bit unsigned integer loaded from x (most significant byte is zero)
34
- **************************************************/
35
-
36
-
37
- /*************************************************
38
- * Name: cbd2
39
- *
40
- * Description: Given an array of uniformly random bytes, compute
41
- * polynomial with coefficients distributed according to
42
- * a centered binomial distribution with parameter eta=2
43
- *
44
- * Arguments: - poly *r: pointer to output polynomial
45
- * - const uint8_t *buf: pointer to input byte array
46
- **************************************************/
47
- static void cbd2(poly *r, const uint8_t buf[2 * KYBER_N / 4]) {
48
- unsigned int i, j;
49
- uint32_t t, d;
50
- int16_t a, b;
51
-
52
- for (i = 0; i < KYBER_N / 8; i++) {
53
- t = load32_littleendian(buf + 4 * i);
54
- d = t & 0x55555555;
55
- d += (t >> 1) & 0x55555555;
56
-
57
- for (j = 0; j < 8; j++) {
58
- a = (d >> (4 * j + 0)) & 0x3;
59
- b = (d >> (4 * j + 2)) & 0x3;
60
- r->coeffs[8 * i + j] = a - b;
61
- }
62
- }
63
- }
64
-
65
- /*************************************************
66
- * Name: cbd3
67
- *
68
- * Description: Given an array of uniformly random bytes, compute
69
- * polynomial with coefficients distributed according to
70
- * a centered binomial distribution with parameter eta=3.
71
- * This function is only needed for Kyber-512
72
- *
73
- * Arguments: - poly *r: pointer to output polynomial
74
- * - const uint8_t *buf: pointer to input byte array
75
- **************************************************/
76
-
77
- void PQCLEAN_MLKEM768_CLEAN_poly_cbd_eta1(poly *r, const uint8_t buf[KYBER_ETA1 * KYBER_N / 4]) {
78
- cbd2(r, buf);
79
- }
80
-
81
- void PQCLEAN_MLKEM768_CLEAN_poly_cbd_eta2(poly *r, const uint8_t buf[KYBER_ETA2 * KYBER_N / 4]) {
82
- cbd2(r, buf);
83
- }
@@ -1,11 +0,0 @@
1
- #ifndef PQCLEAN_MLKEM768_CLEAN_CBD_H
2
- #define PQCLEAN_MLKEM768_CLEAN_CBD_H
3
- #include "params.h"
4
- #include "poly.h"
5
- #include <stdint.h>
6
-
7
- void PQCLEAN_MLKEM768_CLEAN_poly_cbd_eta1(poly *r, const uint8_t buf[KYBER_ETA1 * KYBER_N / 4]);
8
-
9
- void PQCLEAN_MLKEM768_CLEAN_poly_cbd_eta2(poly *r, const uint8_t buf[KYBER_ETA2 * KYBER_N / 4]);
10
-
11
- #endif
@@ -1,327 +0,0 @@
1
- #include "indcpa.h"
2
- #include "ntt.h"
3
- #include "params.h"
4
- #include "poly.h"
5
- #include "polyvec.h"
6
- #include "randombytes.h"
7
- #include "symmetric.h"
8
- #include <stddef.h>
9
- #include <stdint.h>
10
- #include <string.h>
11
-
12
- /*************************************************
13
- * Name: pack_pk
14
- *
15
- * Description: Serialize the public key as concatenation of the
16
- * serialized vector of polynomials pk
17
- * and the public seed used to generate the matrix A.
18
- *
19
- * Arguments: uint8_t *r: pointer to the output serialized public key
20
- * polyvec *pk: pointer to the input public-key polyvec
21
- * const uint8_t *seed: pointer to the input public seed
22
- **************************************************/
23
- static void pack_pk(uint8_t r[KYBER_INDCPA_PUBLICKEYBYTES],
24
- polyvec *pk,
25
- const uint8_t seed[KYBER_SYMBYTES]) {
26
- PQCLEAN_MLKEM768_CLEAN_polyvec_tobytes(r, pk);
27
- memcpy(r + KYBER_POLYVECBYTES, seed, KYBER_SYMBYTES);
28
- }
29
-
30
- /*************************************************
31
- * Name: unpack_pk
32
- *
33
- * Description: De-serialize public key from a byte array;
34
- * approximate inverse of pack_pk
35
- *
36
- * Arguments: - polyvec *pk: pointer to output public-key polynomial vector
37
- * - uint8_t *seed: pointer to output seed to generate matrix A
38
- * - const uint8_t *packedpk: pointer to input serialized public key
39
- **************************************************/
40
- static void unpack_pk(polyvec *pk,
41
- uint8_t seed[KYBER_SYMBYTES],
42
- const uint8_t packedpk[KYBER_INDCPA_PUBLICKEYBYTES]) {
43
- PQCLEAN_MLKEM768_CLEAN_polyvec_frombytes(pk, packedpk);
44
- memcpy(seed, packedpk + KYBER_POLYVECBYTES, KYBER_SYMBYTES);
45
- }
46
-
47
- /*************************************************
48
- * Name: pack_sk
49
- *
50
- * Description: Serialize the secret key
51
- *
52
- * Arguments: - uint8_t *r: pointer to output serialized secret key
53
- * - polyvec *sk: pointer to input vector of polynomials (secret key)
54
- **************************************************/
55
- static void pack_sk(uint8_t r[KYBER_INDCPA_SECRETKEYBYTES], polyvec *sk) {
56
- PQCLEAN_MLKEM768_CLEAN_polyvec_tobytes(r, sk);
57
- }
58
-
59
- /*************************************************
60
- * Name: unpack_sk
61
- *
62
- * Description: De-serialize the secret key; inverse of pack_sk
63
- *
64
- * Arguments: - polyvec *sk: pointer to output vector of polynomials (secret key)
65
- * - const uint8_t *packedsk: pointer to input serialized secret key
66
- **************************************************/
67
- static void unpack_sk(polyvec *sk, const uint8_t packedsk[KYBER_INDCPA_SECRETKEYBYTES]) {
68
- PQCLEAN_MLKEM768_CLEAN_polyvec_frombytes(sk, packedsk);
69
- }
70
-
71
- /*************************************************
72
- * Name: pack_ciphertext
73
- *
74
- * Description: Serialize the ciphertext as concatenation of the
75
- * compressed and serialized vector of polynomials b
76
- * and the compressed and serialized polynomial v
77
- *
78
- * Arguments: uint8_t *r: pointer to the output serialized ciphertext
79
- * poly *pk: pointer to the input vector of polynomials b
80
- * poly *v: pointer to the input polynomial v
81
- **************************************************/
82
- static void pack_ciphertext(uint8_t r[KYBER_INDCPA_BYTES], polyvec *b, poly *v) {
83
- PQCLEAN_MLKEM768_CLEAN_polyvec_compress(r, b);
84
- PQCLEAN_MLKEM768_CLEAN_poly_compress(r + KYBER_POLYVECCOMPRESSEDBYTES, v);
85
- }
86
-
87
- /*************************************************
88
- * Name: unpack_ciphertext
89
- *
90
- * Description: De-serialize and decompress ciphertext from a byte array;
91
- * approximate inverse of pack_ciphertext
92
- *
93
- * Arguments: - polyvec *b: pointer to the output vector of polynomials b
94
- * - poly *v: pointer to the output polynomial v
95
- * - const uint8_t *c: pointer to the input serialized ciphertext
96
- **************************************************/
97
- static void unpack_ciphertext(polyvec *b, poly *v, const uint8_t c[KYBER_INDCPA_BYTES]) {
98
- PQCLEAN_MLKEM768_CLEAN_polyvec_decompress(b, c);
99
- PQCLEAN_MLKEM768_CLEAN_poly_decompress(v, c + KYBER_POLYVECCOMPRESSEDBYTES);
100
- }
101
-
102
- /*************************************************
103
- * Name: rej_uniform
104
- *
105
- * Description: Run rejection sampling on uniform random bytes to generate
106
- * uniform random integers mod q
107
- *
108
- * Arguments: - int16_t *r: pointer to output buffer
109
- * - unsigned int len: requested number of 16-bit integers (uniform mod q)
110
- * - const uint8_t *buf: pointer to input buffer (assumed to be uniformly random bytes)
111
- * - unsigned int buflen: length of input buffer in bytes
112
- *
113
- * Returns number of sampled 16-bit integers (at most len)
114
- **************************************************/
115
- static unsigned int rej_uniform(int16_t *r,
116
- unsigned int len,
117
- const uint8_t *buf,
118
- unsigned int buflen) {
119
- unsigned int ctr, pos;
120
- uint16_t val0, val1;
121
-
122
- ctr = pos = 0;
123
- while (ctr < len && pos + 3 <= buflen) {
124
- val0 = ((buf[pos + 0] >> 0) | ((uint16_t)buf[pos + 1] << 8)) & 0xFFF;
125
- val1 = ((buf[pos + 1] >> 4) | ((uint16_t)buf[pos + 2] << 4)) & 0xFFF;
126
- pos += 3;
127
-
128
- if (val0 < KYBER_Q) {
129
- r[ctr++] = val0;
130
- }
131
- if (ctr < len && val1 < KYBER_Q) {
132
- r[ctr++] = val1;
133
- }
134
- }
135
-
136
- return ctr;
137
- }
138
-
139
- #define gen_a(A,B) PQCLEAN_MLKEM768_CLEAN_gen_matrix(A,B,0)
140
- #define gen_at(A,B) PQCLEAN_MLKEM768_CLEAN_gen_matrix(A,B,1)
141
-
142
- /*************************************************
143
- * Name: PQCLEAN_MLKEM768_CLEAN_gen_matrix
144
- *
145
- * Description: Deterministically generate matrix A (or the transpose of A)
146
- * from a seed. Entries of the matrix are polynomials that look
147
- * uniformly random. Performs rejection sampling on output of
148
- * a XOF
149
- *
150
- * Arguments: - polyvec *a: pointer to ouptput matrix A
151
- * - const uint8_t *seed: pointer to input seed
152
- * - int transposed: boolean deciding whether A or A^T is generated
153
- **************************************************/
154
-
155
- #define GEN_MATRIX_NBLOCKS ((12*KYBER_N/8*(1 << 12)/KYBER_Q + XOF_BLOCKBYTES)/XOF_BLOCKBYTES)
156
- // Not static for benchmarking
157
- void PQCLEAN_MLKEM768_CLEAN_gen_matrix(polyvec *a, const uint8_t seed[KYBER_SYMBYTES], int transposed) {
158
- unsigned int ctr, i, j;
159
- unsigned int buflen;
160
- uint8_t buf[GEN_MATRIX_NBLOCKS * XOF_BLOCKBYTES];
161
- xof_state state;
162
-
163
- for (i = 0; i < KYBER_K; i++) {
164
- for (j = 0; j < KYBER_K; j++) {
165
- if (transposed) {
166
- xof_absorb(&state, seed, (uint8_t)i, (uint8_t)j);
167
- } else {
168
- xof_absorb(&state, seed, (uint8_t)j, (uint8_t)i);
169
- }
170
-
171
- xof_squeezeblocks(buf, GEN_MATRIX_NBLOCKS, &state);
172
- buflen = GEN_MATRIX_NBLOCKS * XOF_BLOCKBYTES;
173
- ctr = rej_uniform(a[i].vec[j].coeffs, KYBER_N, buf, buflen);
174
-
175
- while (ctr < KYBER_N) {
176
- xof_squeezeblocks(buf, 1, &state);
177
- buflen = XOF_BLOCKBYTES;
178
- ctr += rej_uniform(a[i].vec[j].coeffs + ctr, KYBER_N - ctr, buf, buflen);
179
- }
180
- xof_ctx_release(&state);
181
- }
182
- }
183
- }
184
-
185
- /*************************************************
186
- * Name: PQCLEAN_MLKEM768_CLEAN_indcpa_keypair_derand
187
- *
188
- * Description: Generates public and private key for the CPA-secure
189
- * public-key encryption scheme underlying Kyber
190
- *
191
- * Arguments: - uint8_t *pk: pointer to output public key
192
- * (of length KYBER_INDCPA_PUBLICKEYBYTES bytes)
193
- * - uint8_t *sk: pointer to output private key
194
- * (of length KYBER_INDCPA_SECRETKEYBYTES bytes)
195
- * - const uint8_t *coins: pointer to input randomness
196
- * (of length KYBER_SYMBYTES bytes)
197
- **************************************************/
198
- void PQCLEAN_MLKEM768_CLEAN_indcpa_keypair_derand(uint8_t pk[KYBER_INDCPA_PUBLICKEYBYTES],
199
- uint8_t sk[KYBER_INDCPA_SECRETKEYBYTES],
200
- const uint8_t coins[KYBER_SYMBYTES]) {
201
- unsigned int i;
202
- uint8_t buf[2 * KYBER_SYMBYTES];
203
- const uint8_t *publicseed = buf;
204
- const uint8_t *noiseseed = buf + KYBER_SYMBYTES;
205
- uint8_t nonce = 0;
206
- polyvec a[KYBER_K], e, pkpv, skpv;
207
-
208
- memcpy(buf, coins, KYBER_SYMBYTES);
209
- buf[KYBER_SYMBYTES] = KYBER_K;
210
- hash_g(buf, buf, KYBER_SYMBYTES + 1);
211
-
212
- gen_a(a, publicseed);
213
-
214
- for (i = 0; i < KYBER_K; i++) {
215
- PQCLEAN_MLKEM768_CLEAN_poly_getnoise_eta1(&skpv.vec[i], noiseseed, nonce++);
216
- }
217
- for (i = 0; i < KYBER_K; i++) {
218
- PQCLEAN_MLKEM768_CLEAN_poly_getnoise_eta1(&e.vec[i], noiseseed, nonce++);
219
- }
220
-
221
- PQCLEAN_MLKEM768_CLEAN_polyvec_ntt(&skpv);
222
- PQCLEAN_MLKEM768_CLEAN_polyvec_ntt(&e);
223
-
224
- // matrix-vector multiplication
225
- for (i = 0; i < KYBER_K; i++) {
226
- PQCLEAN_MLKEM768_CLEAN_polyvec_basemul_acc_montgomery(&pkpv.vec[i], &a[i], &skpv);
227
- PQCLEAN_MLKEM768_CLEAN_poly_tomont(&pkpv.vec[i]);
228
- }
229
-
230
- PQCLEAN_MLKEM768_CLEAN_polyvec_add(&pkpv, &pkpv, &e);
231
- PQCLEAN_MLKEM768_CLEAN_polyvec_reduce(&pkpv);
232
-
233
- pack_sk(sk, &skpv);
234
- pack_pk(pk, &pkpv, publicseed);
235
- }
236
-
237
-
238
- /*************************************************
239
- * Name: PQCLEAN_MLKEM768_CLEAN_indcpa_enc
240
- *
241
- * Description: Encryption function of the CPA-secure
242
- * public-key encryption scheme underlying Kyber.
243
- *
244
- * Arguments: - uint8_t *c: pointer to output ciphertext
245
- * (of length KYBER_INDCPA_BYTES bytes)
246
- * - const uint8_t *m: pointer to input message
247
- * (of length KYBER_INDCPA_MSGBYTES bytes)
248
- * - const uint8_t *pk: pointer to input public key
249
- * (of length KYBER_INDCPA_PUBLICKEYBYTES)
250
- * - const uint8_t *coins: pointer to input random coins used as seed
251
- * (of length KYBER_SYMBYTES) to deterministically
252
- * generate all randomness
253
- **************************************************/
254
- void PQCLEAN_MLKEM768_CLEAN_indcpa_enc(uint8_t c[KYBER_INDCPA_BYTES],
255
- const uint8_t m[KYBER_INDCPA_MSGBYTES],
256
- const uint8_t pk[KYBER_INDCPA_PUBLICKEYBYTES],
257
- const uint8_t coins[KYBER_SYMBYTES]) {
258
- unsigned int i;
259
- uint8_t seed[KYBER_SYMBYTES];
260
- uint8_t nonce = 0;
261
- polyvec sp, pkpv, ep, at[KYBER_K], b;
262
- poly v, k, epp;
263
-
264
- unpack_pk(&pkpv, seed, pk);
265
- PQCLEAN_MLKEM768_CLEAN_poly_frommsg(&k, m);
266
- gen_at(at, seed);
267
-
268
- for (i = 0; i < KYBER_K; i++) {
269
- PQCLEAN_MLKEM768_CLEAN_poly_getnoise_eta1(sp.vec + i, coins, nonce++);
270
- }
271
- for (i = 0; i < KYBER_K; i++) {
272
- PQCLEAN_MLKEM768_CLEAN_poly_getnoise_eta2(ep.vec + i, coins, nonce++);
273
- }
274
- PQCLEAN_MLKEM768_CLEAN_poly_getnoise_eta2(&epp, coins, nonce++);
275
-
276
- PQCLEAN_MLKEM768_CLEAN_polyvec_ntt(&sp);
277
-
278
- // matrix-vector multiplication
279
- for (i = 0; i < KYBER_K; i++) {
280
- PQCLEAN_MLKEM768_CLEAN_polyvec_basemul_acc_montgomery(&b.vec[i], &at[i], &sp);
281
- }
282
-
283
- PQCLEAN_MLKEM768_CLEAN_polyvec_basemul_acc_montgomery(&v, &pkpv, &sp);
284
-
285
- PQCLEAN_MLKEM768_CLEAN_polyvec_invntt_tomont(&b);
286
- PQCLEAN_MLKEM768_CLEAN_poly_invntt_tomont(&v);
287
-
288
- PQCLEAN_MLKEM768_CLEAN_polyvec_add(&b, &b, &ep);
289
- PQCLEAN_MLKEM768_CLEAN_poly_add(&v, &v, &epp);
290
- PQCLEAN_MLKEM768_CLEAN_poly_add(&v, &v, &k);
291
- PQCLEAN_MLKEM768_CLEAN_polyvec_reduce(&b);
292
- PQCLEAN_MLKEM768_CLEAN_poly_reduce(&v);
293
-
294
- pack_ciphertext(c, &b, &v);
295
- }
296
-
297
- /*************************************************
298
- * Name: PQCLEAN_MLKEM768_CLEAN_indcpa_dec
299
- *
300
- * Description: Decryption function of the CPA-secure
301
- * public-key encryption scheme underlying Kyber.
302
- *
303
- * Arguments: - uint8_t *m: pointer to output decrypted message
304
- * (of length KYBER_INDCPA_MSGBYTES)
305
- * - const uint8_t *c: pointer to input ciphertext
306
- * (of length KYBER_INDCPA_BYTES)
307
- * - const uint8_t *sk: pointer to input secret key
308
- * (of length KYBER_INDCPA_SECRETKEYBYTES)
309
- **************************************************/
310
- void PQCLEAN_MLKEM768_CLEAN_indcpa_dec(uint8_t m[KYBER_INDCPA_MSGBYTES],
311
- const uint8_t c[KYBER_INDCPA_BYTES],
312
- const uint8_t sk[KYBER_INDCPA_SECRETKEYBYTES]) {
313
- polyvec b, skpv;
314
- poly v, mp;
315
-
316
- unpack_ciphertext(&b, &v, c);
317
- unpack_sk(&skpv, sk);
318
-
319
- PQCLEAN_MLKEM768_CLEAN_polyvec_ntt(&b);
320
- PQCLEAN_MLKEM768_CLEAN_polyvec_basemul_acc_montgomery(&mp, &skpv, &b);
321
- PQCLEAN_MLKEM768_CLEAN_poly_invntt_tomont(&mp);
322
-
323
- PQCLEAN_MLKEM768_CLEAN_poly_sub(&mp, &v, &mp);
324
- PQCLEAN_MLKEM768_CLEAN_poly_reduce(&mp);
325
-
326
- PQCLEAN_MLKEM768_CLEAN_poly_tomsg(m, &mp);
327
- }