pq_crypto 0.3.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 (328) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +56 -0
  3. data/CHANGELOG.md +62 -0
  4. data/GET_STARTED.md +366 -40
  5. data/README.md +76 -233
  6. data/SECURITY.md +107 -82
  7. data/ext/pqcrypto/extconf.rb +169 -87
  8. data/ext/pqcrypto/mldsa_api.h +1 -48
  9. data/ext/pqcrypto/mlkem_api.h +1 -18
  10. data/ext/pqcrypto/pq_externalmu.c +89 -204
  11. data/ext/pqcrypto/pqcrypto_native_api.h +129 -0
  12. data/ext/pqcrypto/pqcrypto_ruby_secure.c +484 -84
  13. data/ext/pqcrypto/pqcrypto_secure.c +203 -78
  14. data/ext/pqcrypto/pqcrypto_secure.h +53 -14
  15. data/ext/pqcrypto/pqcrypto_version.h +7 -0
  16. data/ext/pqcrypto/randombytes.h +9 -0
  17. data/ext/pqcrypto/vendor/.vendored +10 -5
  18. data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +105 -0
  19. data/ext/pqcrypto/vendor/mldsa-native/LICENSE +286 -0
  20. data/ext/pqcrypto/vendor/mldsa-native/META.yml +24 -0
  21. data/ext/pqcrypto/vendor/mldsa-native/README.md +221 -0
  22. data/ext/pqcrypto/vendor/mldsa-native/SECURITY.md +8 -0
  23. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +721 -0
  24. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +975 -0
  25. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +724 -0
  26. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +723 -0
  27. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +166 -0
  28. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +321 -0
  29. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.c +21 -0
  30. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +385 -0
  31. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +73 -0
  32. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +130 -0
  33. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.c +277 -0
  34. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +244 -0
  35. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +182 -0
  36. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +117 -0
  37. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +438 -0
  38. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +105 -0
  39. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +71 -0
  40. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +62 -0
  41. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +376 -0
  42. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +204 -0
  43. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +259 -0
  44. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1077 -0
  45. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +987 -0
  46. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +41 -0
  47. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +26 -0
  48. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +35 -0
  49. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +37 -0
  50. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +27 -0
  51. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +36 -0
  52. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +69 -0
  53. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/README.md +10 -0
  54. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +32 -0
  55. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +20 -0
  56. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +638 -0
  57. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +136 -0
  58. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +52 -0
  59. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +29 -0
  60. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.c +488 -0
  61. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.h +16 -0
  62. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/xkcp.h +31 -0
  63. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +247 -0
  64. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +231 -0
  65. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +150 -0
  66. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt.S +753 -0
  67. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4.S +129 -0
  68. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5.S +145 -0
  69. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7.S +177 -0
  70. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt.S +653 -0
  71. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery.S +79 -0
  72. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_asm.S +53 -0
  73. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_asm.S +55 -0
  74. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_asm.S +85 -0
  75. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_asm.S +85 -0
  76. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_asm.S +102 -0
  77. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_asm.S +110 -0
  78. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_asm.S +72 -0
  79. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_asm.S +69 -0
  80. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +40 -0
  81. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_asm.S +189 -0
  82. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_asm.S +135 -0
  83. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_asm.S +128 -0
  84. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +543 -0
  85. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +62 -0
  86. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +649 -0
  87. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +23 -0
  88. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +315 -0
  89. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +124 -0
  90. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +157 -0
  91. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +27 -0
  92. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt.S +2311 -0
  93. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt.S +2383 -0
  94. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack.S +239 -0
  95. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise.S +131 -0
  96. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4.S +139 -0
  97. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5.S +155 -0
  98. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7.S +187 -0
  99. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2.c +61 -0
  100. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_chknorm_avx2.c +52 -0
  101. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +155 -0
  102. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +155 -0
  103. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +102 -0
  104. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +104 -0
  105. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +91 -0
  106. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +93 -0
  107. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_avx2.c +126 -0
  108. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +155 -0
  109. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +139 -0
  110. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +160 -0
  111. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +293 -0
  112. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +224 -0
  113. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +77 -0
  114. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +991 -0
  115. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +393 -0
  116. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +946 -0
  117. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +360 -0
  118. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +877 -0
  119. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +725 -0
  120. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/randombytes.h +26 -0
  121. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +139 -0
  122. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +249 -0
  123. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +1511 -0
  124. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +806 -0
  125. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/symmetric.h +68 -0
  126. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +268 -0
  127. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/zetas.inc +55 -0
  128. data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +104 -0
  129. data/ext/pqcrypto/vendor/mlkem-native/LICENSE +294 -0
  130. data/ext/pqcrypto/vendor/mlkem-native/META.yml +30 -0
  131. data/ext/pqcrypto/vendor/mlkem-native/README.md +223 -0
  132. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +86 -0
  133. data/ext/pqcrypto/vendor/mlkem-native/SECURITY.md +8 -0
  134. data/ext/pqcrypto/vendor/mlkem-native/mlkem/README.md +23 -0
  135. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +660 -0
  136. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +538 -0
  137. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +681 -0
  138. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +709 -0
  139. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +174 -0
  140. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +274 -0
  141. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +717 -0
  142. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +688 -0
  143. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.c +64 -0
  144. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.h +128 -0
  145. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +251 -0
  146. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +158 -0
  147. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +208 -0
  148. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +80 -0
  149. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +463 -0
  150. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.h +98 -0
  151. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +70 -0
  152. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/fips202_native_aarch64.h +69 -0
  153. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +375 -0
  154. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +203 -0
  155. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +258 -0
  156. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +1076 -0
  157. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +986 -0
  158. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +46 -0
  159. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +25 -0
  160. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +34 -0
  161. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +35 -0
  162. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +26 -0
  163. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +35 -0
  164. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/api.h +117 -0
  165. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/README.md +10 -0
  166. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +79 -0
  167. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h +35 -0
  168. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +667 -0
  169. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +40 -0
  170. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +51 -0
  171. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +290 -0
  172. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +314 -0
  173. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +28 -0
  174. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +33 -0
  175. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +41 -0
  176. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2.S +451 -0
  177. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +51 -0
  178. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +622 -0
  179. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +156 -0
  180. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +446 -0
  181. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +326 -0
  182. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/README.md +16 -0
  183. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +122 -0
  184. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +174 -0
  185. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +177 -0
  186. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/intt.S +628 -0
  187. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/ntt.S +562 -0
  188. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_mulcache_compute_asm.S +127 -0
  189. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_reduce_asm.S +150 -0
  190. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tobytes_asm.S +117 -0
  191. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/poly_tomont_asm.S +98 -0
  192. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +261 -0
  193. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +314 -0
  194. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +368 -0
  195. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_asm.S +226 -0
  196. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_table.c +542 -0
  197. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +637 -0
  198. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +25 -0
  199. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/README.md +11 -0
  200. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +128 -0
  201. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +45 -0
  202. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +81 -0
  203. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +145 -0
  204. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_izetas.inc +27 -0
  205. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +805 -0
  206. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas.inc +27 -0
  207. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_zetas_basemul.inc +39 -0
  208. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/README.md +4 -0
  209. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +304 -0
  210. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +309 -0
  211. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +94 -0
  212. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +45 -0
  213. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.c +102 -0
  214. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.h +25 -0
  215. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/intt.S +719 -0
  216. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mulcache_compute.S +90 -0
  217. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntt.S +639 -0
  218. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttfrombytes.S +193 -0
  219. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/ntttobytes.S +181 -0
  220. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/nttunpack.S +174 -0
  221. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d10.S +382 -0
  222. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d11.S +448 -0
  223. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d4.S +163 -0
  224. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_compress_d5.S +220 -0
  225. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d10.S +228 -0
  226. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d11.S +277 -0
  227. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d4.S +180 -0
  228. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/poly_decompress_d5.S +192 -0
  229. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k2.S +502 -0
  230. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k3.S +750 -0
  231. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/polyvec_basemul_acc_montgomery_cached_asm_k4.S +998 -0
  232. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/reduce.S +218 -0
  233. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_asm.S +103 -0
  234. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_table.c +544 -0
  235. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/tomont.S +155 -0
  236. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/params.h +76 -0
  237. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +572 -0
  238. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +317 -0
  239. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +502 -0
  240. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +668 -0
  241. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/randombytes.h +60 -0
  242. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +362 -0
  243. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +118 -0
  244. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/symmetric.h +70 -0
  245. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +260 -0
  246. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.c +20 -0
  247. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +464 -0
  248. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/zetas.inc +30 -0
  249. data/lib/pq_crypto/algorithm_registry.rb +200 -0
  250. data/lib/pq_crypto/hybrid_kem.rb +1 -12
  251. data/lib/pq_crypto/kem.rb +104 -13
  252. data/lib/pq_crypto/pkcs8.rb +387 -0
  253. data/lib/pq_crypto/serialization.rb +1 -14
  254. data/lib/pq_crypto/signature.rb +123 -17
  255. data/lib/pq_crypto/spki.rb +131 -0
  256. data/lib/pq_crypto/version.rb +1 -1
  257. data/lib/pq_crypto.rb +79 -20
  258. data/script/vendor_libs.rb +88 -155
  259. metadata +241 -73
  260. data/ext/pqcrypto/vendor/pqclean/common/aes.c +0 -639
  261. data/ext/pqcrypto/vendor/pqclean/common/aes.h +0 -64
  262. data/ext/pqcrypto/vendor/pqclean/common/compat.h +0 -73
  263. data/ext/pqcrypto/vendor/pqclean/common/crypto_declassify.h +0 -7
  264. data/ext/pqcrypto/vendor/pqclean/common/fips202.c +0 -928
  265. data/ext/pqcrypto/vendor/pqclean/common/fips202.h +0 -166
  266. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/feat.S +0 -168
  267. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.c +0 -684
  268. data/ext/pqcrypto/vendor/pqclean/common/keccak2x/fips202x2.h +0 -60
  269. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SIMD256.c +0 -1028
  270. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-times4-SnP.h +0 -50
  271. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/KeccakP-1600-unrolling.macros +0 -198
  272. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile +0 -8
  273. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/Makefile.Microsoft_nmake +0 -8
  274. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/SIMD256-config.h +0 -3
  275. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/align.h +0 -34
  276. data/ext/pqcrypto/vendor/pqclean/common/keccak4x/brg_endian.h +0 -142
  277. data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.c +0 -101
  278. data/ext/pqcrypto/vendor/pqclean/common/nistseedexpander.h +0 -39
  279. data/ext/pqcrypto/vendor/pqclean/common/randombytes.c +0 -355
  280. data/ext/pqcrypto/vendor/pqclean/common/randombytes.h +0 -27
  281. data/ext/pqcrypto/vendor/pqclean/common/sha2.c +0 -769
  282. data/ext/pqcrypto/vendor/pqclean/common/sha2.h +0 -173
  283. data/ext/pqcrypto/vendor/pqclean/common/sp800-185.c +0 -156
  284. data/ext/pqcrypto/vendor/pqclean/common/sp800-185.h +0 -27
  285. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/LICENSE +0 -5
  286. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile +0 -19
  287. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/Makefile.Microsoft_nmake +0 -23
  288. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/api.h +0 -18
  289. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.c +0 -83
  290. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/cbd.h +0 -11
  291. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.c +0 -327
  292. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/indcpa.h +0 -22
  293. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.c +0 -164
  294. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/kem.h +0 -23
  295. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.c +0 -146
  296. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/ntt.h +0 -14
  297. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/params.h +0 -36
  298. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.c +0 -299
  299. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/poly.h +0 -37
  300. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.c +0 -188
  301. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/polyvec.h +0 -26
  302. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.c +0 -41
  303. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/reduce.h +0 -13
  304. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric-shake.c +0 -71
  305. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/symmetric.h +0 -30
  306. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.c +0 -67
  307. data/ext/pqcrypto/vendor/pqclean/crypto_kem/ml-kem-768/clean/verify.h +0 -13
  308. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/LICENSE +0 -5
  309. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile +0 -19
  310. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/Makefile.Microsoft_nmake +0 -23
  311. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/api.h +0 -50
  312. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.c +0 -98
  313. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/ntt.h +0 -10
  314. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.c +0 -261
  315. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/packing.h +0 -31
  316. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/params.h +0 -44
  317. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.c +0 -799
  318. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/poly.h +0 -52
  319. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.c +0 -415
  320. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/polyvec.h +0 -65
  321. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.c +0 -69
  322. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/reduce.h +0 -17
  323. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.c +0 -92
  324. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/rounding.h +0 -14
  325. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.c +0 -407
  326. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/sign.h +0 -47
  327. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric-shake.c +0 -26
  328. data/ext/pqcrypto/vendor/pqclean/crypto_sign/ml-dsa-65/clean/symmetric.h +0 -34
@@ -0,0 +1,463 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+
6
+ /* References
7
+ * ==========
8
+ *
9
+ * - [mupq]
10
+ * Common files for pqm4, pqm3, pqriscv
11
+ * Kannwischer, Petri, Rijneveld, Schwabe, Stoffelen
12
+ * https://github.com/mupq/mupq
13
+ *
14
+ * - [supercop]
15
+ * SUPERCOP benchmarking framework
16
+ * Daniel J. Bernstein
17
+ * http://bench.cr.yp.to/supercop.html
18
+ *
19
+ * - [tweetfips]
20
+ * 'tweetfips202' FIPS202 implementation
21
+ * Van Assche, Bernstein, Schwabe
22
+ * https://keccak.team/2015/tweetfips202.html
23
+ */
24
+
25
+ /* Based on the CC0 implementation from @[mupq] and the public domain
26
+ * implementation @[supercop, crypto_hash/keccakc512/simple/]
27
+ * by Ronny Van Keer, and the public domain @[tweetfips] implementation. */
28
+
29
+
30
+ #include "keccakf1600.h"
31
+ #if !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
32
+
33
+ #define MLK_KECCAK_NROUNDS 24
34
+ #define MLK_KECCAK_ROL(a, offset) ((a << offset) ^ (a >> (64 - offset)))
35
+
36
+ void mlk_keccakf1600_extract_bytes(uint64_t *state, unsigned char *data,
37
+ unsigned offset, unsigned length)
38
+ {
39
+ unsigned i;
40
+ #if defined(MLK_SYS_LITTLE_ENDIAN)
41
+ uint8_t *state_ptr = (uint8_t *)state + offset;
42
+ for (i = 0; i < length; i++)
43
+ __loop__(invariant(i <= length))
44
+ {
45
+ data[i] = state_ptr[i];
46
+ }
47
+ #else /* MLK_SYS_LITTLE_ENDIAN */
48
+ /* Portable version */
49
+ for (i = 0; i < length; i++)
50
+ __loop__(invariant(i <= length))
51
+ {
52
+ data[i] = (state[(offset + i) >> 3] >> (8 * ((offset + i) & 0x07))) & 0xFF;
53
+ }
54
+ #endif /* !MLK_SYS_LITTLE_ENDIAN */
55
+ }
56
+
57
+ void mlk_keccakf1600_xor_bytes(uint64_t *state, const unsigned char *data,
58
+ unsigned offset, unsigned length)
59
+ {
60
+ unsigned i;
61
+ #if defined(MLK_SYS_LITTLE_ENDIAN)
62
+ uint8_t *state_ptr = (uint8_t *)state + offset;
63
+ for (i = 0; i < length; i++)
64
+ __loop__(invariant(i <= length))
65
+ {
66
+ state_ptr[i] ^= data[i];
67
+ }
68
+ #else /* MLK_SYS_LITTLE_ENDIAN */
69
+ /* Portable version */
70
+ for (i = 0; i < length; i++)
71
+ __loop__(invariant(i <= length))
72
+ {
73
+ state[(offset + i) >> 3] ^= (uint64_t)data[i]
74
+ << (8 * ((offset + i) & 0x07));
75
+ }
76
+ #endif /* !MLK_SYS_LITTLE_ENDIAN */
77
+ }
78
+
79
+ static void mlk_keccakf1600x4_extract_bytes_c(uint64_t *state,
80
+ unsigned char *data0,
81
+ unsigned char *data1,
82
+ unsigned char *data2,
83
+ unsigned char *data3,
84
+ unsigned offset, unsigned length)
85
+ {
86
+ mlk_keccakf1600_extract_bytes(state + MLK_KECCAK_LANES * 0, data0, offset,
87
+ length);
88
+ mlk_keccakf1600_extract_bytes(state + MLK_KECCAK_LANES * 1, data1, offset,
89
+ length);
90
+ mlk_keccakf1600_extract_bytes(state + MLK_KECCAK_LANES * 2, data2, offset,
91
+ length);
92
+ mlk_keccakf1600_extract_bytes(state + MLK_KECCAK_LANES * 3, data3, offset,
93
+ length);
94
+ }
95
+
96
+ void mlk_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0,
97
+ unsigned char *data1, unsigned char *data2,
98
+ unsigned char *data3, unsigned offset,
99
+ unsigned length)
100
+ {
101
+ #if defined(MLK_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE)
102
+ if (mlk_keccakf1600_extract_bytes_x4_native(state, data0, data1, data2, data3,
103
+ offset, length) ==
104
+ MLK_NATIVE_FUNC_SUCCESS)
105
+ {
106
+ return;
107
+ }
108
+ #endif /* MLK_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE */
109
+ mlk_keccakf1600x4_extract_bytes_c(state, data0, data1, data2, data3, offset,
110
+ length);
111
+ }
112
+
113
+ static void mlk_keccakf1600x4_xor_bytes_c(uint64_t *state,
114
+ const unsigned char *data0,
115
+ const unsigned char *data1,
116
+ const unsigned char *data2,
117
+ const unsigned char *data3,
118
+ unsigned offset, unsigned length)
119
+ {
120
+ mlk_keccakf1600_xor_bytes(state + MLK_KECCAK_LANES * 0, data0, offset,
121
+ length);
122
+ mlk_keccakf1600_xor_bytes(state + MLK_KECCAK_LANES * 1, data1, offset,
123
+ length);
124
+ mlk_keccakf1600_xor_bytes(state + MLK_KECCAK_LANES * 2, data2, offset,
125
+ length);
126
+ mlk_keccakf1600_xor_bytes(state + MLK_KECCAK_LANES * 3, data3, offset,
127
+ length);
128
+ }
129
+
130
+ void mlk_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
131
+ const unsigned char *data1,
132
+ const unsigned char *data2,
133
+ const unsigned char *data3, unsigned offset,
134
+ unsigned length)
135
+ {
136
+ #if defined(MLK_USE_FIPS202_X4_XOR_BYTES_NATIVE)
137
+ if (mlk_keccakf1600_xor_bytes_x4_native(state, data0, data1, data2, data3,
138
+ offset,
139
+ length) == MLK_NATIVE_FUNC_SUCCESS)
140
+ {
141
+ return;
142
+ }
143
+ #endif /* MLK_USE_FIPS202_X4_XOR_BYTES_NATIVE */
144
+ mlk_keccakf1600x4_xor_bytes_c(state, data0, data1, data2, data3, offset,
145
+ length);
146
+ }
147
+
148
+ void mlk_keccakf1600x4_permute(uint64_t *state)
149
+ {
150
+ #if defined(MLK_USE_FIPS202_X4_NATIVE)
151
+ if (mlk_keccak_f1600_x4_native(state) == MLK_NATIVE_FUNC_SUCCESS)
152
+ {
153
+ return;
154
+ }
155
+ #endif /* MLK_USE_FIPS202_X4_NATIVE */
156
+ mlk_keccakf1600_permute(state + MLK_KECCAK_LANES * 0);
157
+ mlk_keccakf1600_permute(state + MLK_KECCAK_LANES * 1);
158
+ mlk_keccakf1600_permute(state + MLK_KECCAK_LANES * 2);
159
+ mlk_keccakf1600_permute(state + MLK_KECCAK_LANES * 3);
160
+ }
161
+
162
+ static const uint64_t mlk_KeccakF_RoundConstants[MLK_KECCAK_NROUNDS] = {
163
+ (uint64_t)0x0000000000000001ULL, (uint64_t)0x0000000000008082ULL,
164
+ (uint64_t)0x800000000000808aULL, (uint64_t)0x8000000080008000ULL,
165
+ (uint64_t)0x000000000000808bULL, (uint64_t)0x0000000080000001ULL,
166
+ (uint64_t)0x8000000080008081ULL, (uint64_t)0x8000000000008009ULL,
167
+ (uint64_t)0x000000000000008aULL, (uint64_t)0x0000000000000088ULL,
168
+ (uint64_t)0x0000000080008009ULL, (uint64_t)0x000000008000000aULL,
169
+ (uint64_t)0x000000008000808bULL, (uint64_t)0x800000000000008bULL,
170
+ (uint64_t)0x8000000000008089ULL, (uint64_t)0x8000000000008003ULL,
171
+ (uint64_t)0x8000000000008002ULL, (uint64_t)0x8000000000000080ULL,
172
+ (uint64_t)0x000000000000800aULL, (uint64_t)0x800000008000000aULL,
173
+ (uint64_t)0x8000000080008081ULL, (uint64_t)0x8000000000008080ULL,
174
+ (uint64_t)0x0000000080000001ULL, (uint64_t)0x8000000080008008ULL};
175
+
176
+ MLK_STATIC_TESTABLE
177
+ void mlk_keccakf1600_permute_c(uint64_t *state)
178
+ {
179
+ unsigned round;
180
+
181
+ uint64_t Aba, Abe, Abi, Abo, Abu;
182
+ uint64_t Aga, Age, Agi, Ago, Agu;
183
+ uint64_t Aka, Ake, Aki, Ako, Aku;
184
+ uint64_t Ama, Ame, Ami, Amo, Amu;
185
+ uint64_t Asa, Ase, Asi, Aso, Asu;
186
+ uint64_t BCa, BCe, BCi, BCo, BCu;
187
+ uint64_t Da, De, Di, Do, Du;
188
+ uint64_t Eba, Ebe, Ebi, Ebo, Ebu;
189
+ uint64_t Ega, Ege, Egi, Ego, Egu;
190
+ uint64_t Eka, Eke, Eki, Eko, Eku;
191
+ uint64_t Ema, Eme, Emi, Emo, Emu;
192
+ uint64_t Esa, Ese, Esi, Eso, Esu;
193
+
194
+ /* copyFromState(A, state) */
195
+ Aba = state[0];
196
+ Abe = state[1];
197
+ Abi = state[2];
198
+ Abo = state[3];
199
+ Abu = state[4];
200
+ Aga = state[5];
201
+ Age = state[6];
202
+ Agi = state[7];
203
+ Ago = state[8];
204
+ Agu = state[9];
205
+ Aka = state[10];
206
+ Ake = state[11];
207
+ Aki = state[12];
208
+ Ako = state[13];
209
+ Aku = state[14];
210
+ Ama = state[15];
211
+ Ame = state[16];
212
+ Ami = state[17];
213
+ Amo = state[18];
214
+ Amu = state[19];
215
+ Asa = state[20];
216
+ Ase = state[21];
217
+ Asi = state[22];
218
+ Aso = state[23];
219
+ Asu = state[24];
220
+
221
+ for (round = 0; round < MLK_KECCAK_NROUNDS; round += 2)
222
+ __loop__(invariant(round <= MLK_KECCAK_NROUNDS && round % 2 == 0))
223
+ {
224
+ /* prepareTheta */
225
+ BCa = Aba ^ Aga ^ Aka ^ Ama ^ Asa;
226
+ BCe = Abe ^ Age ^ Ake ^ Ame ^ Ase;
227
+ BCi = Abi ^ Agi ^ Aki ^ Ami ^ Asi;
228
+ BCo = Abo ^ Ago ^ Ako ^ Amo ^ Aso;
229
+ BCu = Abu ^ Agu ^ Aku ^ Amu ^ Asu;
230
+
231
+ /* thetaRhoPiChiIotaPrepareTheta(round, A, E) */
232
+ Da = BCu ^ MLK_KECCAK_ROL(BCe, 1);
233
+ De = BCa ^ MLK_KECCAK_ROL(BCi, 1);
234
+ Di = BCe ^ MLK_KECCAK_ROL(BCo, 1);
235
+ Do = BCi ^ MLK_KECCAK_ROL(BCu, 1);
236
+ Du = BCo ^ MLK_KECCAK_ROL(BCa, 1);
237
+
238
+ Aba ^= Da;
239
+ BCa = Aba;
240
+ Age ^= De;
241
+ BCe = MLK_KECCAK_ROL(Age, 44);
242
+ Aki ^= Di;
243
+ BCi = MLK_KECCAK_ROL(Aki, 43);
244
+ Amo ^= Do;
245
+ BCo = MLK_KECCAK_ROL(Amo, 21);
246
+ Asu ^= Du;
247
+ BCu = MLK_KECCAK_ROL(Asu, 14);
248
+ Eba = BCa ^ ((~BCe) & BCi);
249
+ Eba ^= (uint64_t)mlk_KeccakF_RoundConstants[round];
250
+ Ebe = BCe ^ ((~BCi) & BCo);
251
+ Ebi = BCi ^ ((~BCo) & BCu);
252
+ Ebo = BCo ^ ((~BCu) & BCa);
253
+ Ebu = BCu ^ ((~BCa) & BCe);
254
+
255
+ Abo ^= Do;
256
+ BCa = MLK_KECCAK_ROL(Abo, 28);
257
+ Agu ^= Du;
258
+ BCe = MLK_KECCAK_ROL(Agu, 20);
259
+ Aka ^= Da;
260
+ BCi = MLK_KECCAK_ROL(Aka, 3);
261
+ Ame ^= De;
262
+ BCo = MLK_KECCAK_ROL(Ame, 45);
263
+ Asi ^= Di;
264
+ BCu = MLK_KECCAK_ROL(Asi, 61);
265
+ Ega = BCa ^ ((~BCe) & BCi);
266
+ Ege = BCe ^ ((~BCi) & BCo);
267
+ Egi = BCi ^ ((~BCo) & BCu);
268
+ Ego = BCo ^ ((~BCu) & BCa);
269
+ Egu = BCu ^ ((~BCa) & BCe);
270
+
271
+ Abe ^= De;
272
+ BCa = MLK_KECCAK_ROL(Abe, 1);
273
+ Agi ^= Di;
274
+ BCe = MLK_KECCAK_ROL(Agi, 6);
275
+ Ako ^= Do;
276
+ BCi = MLK_KECCAK_ROL(Ako, 25);
277
+ Amu ^= Du;
278
+ BCo = MLK_KECCAK_ROL(Amu, 8);
279
+ Asa ^= Da;
280
+ BCu = MLK_KECCAK_ROL(Asa, 18);
281
+ Eka = BCa ^ ((~BCe) & BCi);
282
+ Eke = BCe ^ ((~BCi) & BCo);
283
+ Eki = BCi ^ ((~BCo) & BCu);
284
+ Eko = BCo ^ ((~BCu) & BCa);
285
+ Eku = BCu ^ ((~BCa) & BCe);
286
+
287
+ Abu ^= Du;
288
+ BCa = MLK_KECCAK_ROL(Abu, 27);
289
+ Aga ^= Da;
290
+ BCe = MLK_KECCAK_ROL(Aga, 36);
291
+ Ake ^= De;
292
+ BCi = MLK_KECCAK_ROL(Ake, 10);
293
+ Ami ^= Di;
294
+ BCo = MLK_KECCAK_ROL(Ami, 15);
295
+ Aso ^= Do;
296
+ BCu = MLK_KECCAK_ROL(Aso, 56);
297
+ Ema = BCa ^ ((~BCe) & BCi);
298
+ Eme = BCe ^ ((~BCi) & BCo);
299
+ Emi = BCi ^ ((~BCo) & BCu);
300
+ Emo = BCo ^ ((~BCu) & BCa);
301
+ Emu = BCu ^ ((~BCa) & BCe);
302
+
303
+ Abi ^= Di;
304
+ BCa = MLK_KECCAK_ROL(Abi, 62);
305
+ Ago ^= Do;
306
+ BCe = MLK_KECCAK_ROL(Ago, 55);
307
+ Aku ^= Du;
308
+ BCi = MLK_KECCAK_ROL(Aku, 39);
309
+ Ama ^= Da;
310
+ BCo = MLK_KECCAK_ROL(Ama, 41);
311
+ Ase ^= De;
312
+ BCu = MLK_KECCAK_ROL(Ase, 2);
313
+ Esa = BCa ^ ((~BCe) & BCi);
314
+ Ese = BCe ^ ((~BCi) & BCo);
315
+ Esi = BCi ^ ((~BCo) & BCu);
316
+ Eso = BCo ^ ((~BCu) & BCa);
317
+ Esu = BCu ^ ((~BCa) & BCe);
318
+
319
+ /* prepareTheta */
320
+ BCa = Eba ^ Ega ^ Eka ^ Ema ^ Esa;
321
+ BCe = Ebe ^ Ege ^ Eke ^ Eme ^ Ese;
322
+ BCi = Ebi ^ Egi ^ Eki ^ Emi ^ Esi;
323
+ BCo = Ebo ^ Ego ^ Eko ^ Emo ^ Eso;
324
+ BCu = Ebu ^ Egu ^ Eku ^ Emu ^ Esu;
325
+
326
+ /* thetaRhoPiChiIotaPrepareTheta(round+1, E, A) */
327
+ Da = BCu ^ MLK_KECCAK_ROL(BCe, 1);
328
+ De = BCa ^ MLK_KECCAK_ROL(BCi, 1);
329
+ Di = BCe ^ MLK_KECCAK_ROL(BCo, 1);
330
+ Do = BCi ^ MLK_KECCAK_ROL(BCu, 1);
331
+ Du = BCo ^ MLK_KECCAK_ROL(BCa, 1);
332
+
333
+ Eba ^= Da;
334
+ BCa = Eba;
335
+ Ege ^= De;
336
+ BCe = MLK_KECCAK_ROL(Ege, 44);
337
+ Eki ^= Di;
338
+ BCi = MLK_KECCAK_ROL(Eki, 43);
339
+ Emo ^= Do;
340
+ BCo = MLK_KECCAK_ROL(Emo, 21);
341
+ Esu ^= Du;
342
+ BCu = MLK_KECCAK_ROL(Esu, 14);
343
+ Aba = BCa ^ ((~BCe) & BCi);
344
+ Aba ^= (uint64_t)mlk_KeccakF_RoundConstants[round + 1];
345
+ Abe = BCe ^ ((~BCi) & BCo);
346
+ Abi = BCi ^ ((~BCo) & BCu);
347
+ Abo = BCo ^ ((~BCu) & BCa);
348
+ Abu = BCu ^ ((~BCa) & BCe);
349
+
350
+ Ebo ^= Do;
351
+ BCa = MLK_KECCAK_ROL(Ebo, 28);
352
+ Egu ^= Du;
353
+ BCe = MLK_KECCAK_ROL(Egu, 20);
354
+ Eka ^= Da;
355
+ BCi = MLK_KECCAK_ROL(Eka, 3);
356
+ Eme ^= De;
357
+ BCo = MLK_KECCAK_ROL(Eme, 45);
358
+ Esi ^= Di;
359
+ BCu = MLK_KECCAK_ROL(Esi, 61);
360
+ Aga = BCa ^ ((~BCe) & BCi);
361
+ Age = BCe ^ ((~BCi) & BCo);
362
+ Agi = BCi ^ ((~BCo) & BCu);
363
+ Ago = BCo ^ ((~BCu) & BCa);
364
+ Agu = BCu ^ ((~BCa) & BCe);
365
+
366
+ Ebe ^= De;
367
+ BCa = MLK_KECCAK_ROL(Ebe, 1);
368
+ Egi ^= Di;
369
+ BCe = MLK_KECCAK_ROL(Egi, 6);
370
+ Eko ^= Do;
371
+ BCi = MLK_KECCAK_ROL(Eko, 25);
372
+ Emu ^= Du;
373
+ BCo = MLK_KECCAK_ROL(Emu, 8);
374
+ Esa ^= Da;
375
+ BCu = MLK_KECCAK_ROL(Esa, 18);
376
+ Aka = BCa ^ ((~BCe) & BCi);
377
+ Ake = BCe ^ ((~BCi) & BCo);
378
+ Aki = BCi ^ ((~BCo) & BCu);
379
+ Ako = BCo ^ ((~BCu) & BCa);
380
+ Aku = BCu ^ ((~BCa) & BCe);
381
+
382
+ Ebu ^= Du;
383
+ BCa = MLK_KECCAK_ROL(Ebu, 27);
384
+ Ega ^= Da;
385
+ BCe = MLK_KECCAK_ROL(Ega, 36);
386
+ Eke ^= De;
387
+ BCi = MLK_KECCAK_ROL(Eke, 10);
388
+ Emi ^= Di;
389
+ BCo = MLK_KECCAK_ROL(Emi, 15);
390
+ Eso ^= Do;
391
+ BCu = MLK_KECCAK_ROL(Eso, 56);
392
+ Ama = BCa ^ ((~BCe) & BCi);
393
+ Ame = BCe ^ ((~BCi) & BCo);
394
+ Ami = BCi ^ ((~BCo) & BCu);
395
+ Amo = BCo ^ ((~BCu) & BCa);
396
+ Amu = BCu ^ ((~BCa) & BCe);
397
+
398
+ Ebi ^= Di;
399
+ BCa = MLK_KECCAK_ROL(Ebi, 62);
400
+ Ego ^= Do;
401
+ BCe = MLK_KECCAK_ROL(Ego, 55);
402
+ Eku ^= Du;
403
+ BCi = MLK_KECCAK_ROL(Eku, 39);
404
+ Ema ^= Da;
405
+ BCo = MLK_KECCAK_ROL(Ema, 41);
406
+ Ese ^= De;
407
+ BCu = MLK_KECCAK_ROL(Ese, 2);
408
+ Asa = BCa ^ ((~BCe) & BCi);
409
+ Ase = BCe ^ ((~BCi) & BCo);
410
+ Asi = BCi ^ ((~BCo) & BCu);
411
+ Aso = BCo ^ ((~BCu) & BCa);
412
+ Asu = BCu ^ ((~BCa) & BCe);
413
+ }
414
+
415
+ /* copyToState(state, A) */
416
+ state[0] = Aba;
417
+ state[1] = Abe;
418
+ state[2] = Abi;
419
+ state[3] = Abo;
420
+ state[4] = Abu;
421
+ state[5] = Aga;
422
+ state[6] = Age;
423
+ state[7] = Agi;
424
+ state[8] = Ago;
425
+ state[9] = Agu;
426
+ state[10] = Aka;
427
+ state[11] = Ake;
428
+ state[12] = Aki;
429
+ state[13] = Ako;
430
+ state[14] = Aku;
431
+ state[15] = Ama;
432
+ state[16] = Ame;
433
+ state[17] = Ami;
434
+ state[18] = Amo;
435
+ state[19] = Amu;
436
+ state[20] = Asa;
437
+ state[21] = Ase;
438
+ state[22] = Asi;
439
+ state[23] = Aso;
440
+ state[24] = Asu;
441
+ }
442
+
443
+ void mlk_keccakf1600_permute(uint64_t *state)
444
+ {
445
+ #if defined(MLK_USE_FIPS202_X1_NATIVE)
446
+ if (mlk_keccak_f1600_x1_native(state) == MLK_NATIVE_FUNC_SUCCESS)
447
+ {
448
+ return;
449
+ }
450
+ #endif /* MLK_USE_FIPS202_X1_NATIVE */
451
+ mlk_keccakf1600_permute_c(state);
452
+ }
453
+
454
+ #else /* !MLK_CONFIG_MULTILEVEL_NO_SHARED */
455
+
456
+ MLK_EMPTY_CU(keccakf1600)
457
+
458
+ #endif /* MLK_CONFIG_MULTILEVEL_NO_SHARED */
459
+
460
+ /* To facilitate single-compilation-unit (SCU) builds, undefine all macros.
461
+ * Don't modify by hand -- this is auto-generated by scripts/autogen. */
462
+ #undef MLK_KECCAK_NROUNDS
463
+ #undef MLK_KECCAK_ROL
@@ -0,0 +1,98 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+ #ifndef MLK_FIPS202_KECCAKF1600_H
6
+ #define MLK_FIPS202_KECCAKF1600_H
7
+ #include "../cbmc.h"
8
+ #include "../common.h"
9
+
10
+ #define MLK_KECCAK_LANES 25
11
+ #define MLK_KECCAK_WAY 4
12
+
13
+ /*
14
+ * WARNING:
15
+ * The contents of this structure, including the placement
16
+ * and interleaving of Keccak lanes, are IMPLEMENTATION-DEFINED.
17
+ * The struct is only exposed here to allow its construction on the stack.
18
+ */
19
+
20
+ #define mlk_keccakf1600_extract_bytes MLK_NAMESPACE(keccakf1600_extract_bytes)
21
+ void mlk_keccakf1600_extract_bytes(uint64_t *state, unsigned char *data,
22
+ unsigned offset, unsigned length)
23
+ __contract__(
24
+ requires(0 <= offset && offset <= MLK_KECCAK_LANES * sizeof(uint64_t) &&
25
+ 0 <= length && length <= MLK_KECCAK_LANES * sizeof(uint64_t) - offset)
26
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLK_KECCAK_LANES))
27
+ requires(memory_no_alias(data, length))
28
+ assigns(memory_slice(data, length))
29
+ );
30
+
31
+ #define mlk_keccakf1600_xor_bytes MLK_NAMESPACE(keccakf1600_xor_bytes)
32
+ void mlk_keccakf1600_xor_bytes(uint64_t *state, const unsigned char *data,
33
+ unsigned offset, unsigned length)
34
+ __contract__(
35
+ requires(0 <= offset && offset <= MLK_KECCAK_LANES * sizeof(uint64_t) &&
36
+ 0 <= length && length <= MLK_KECCAK_LANES * sizeof(uint64_t) - offset)
37
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLK_KECCAK_LANES))
38
+ requires(memory_no_alias(data, length))
39
+ assigns(memory_slice(state, sizeof(uint64_t) * MLK_KECCAK_LANES))
40
+ );
41
+
42
+ #define mlk_keccakf1600x4_extract_bytes \
43
+ MLK_NAMESPACE(keccakf1600x4_extract_bytes)
44
+ void mlk_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0,
45
+ unsigned char *data1, unsigned char *data2,
46
+ unsigned char *data3, unsigned offset,
47
+ unsigned length)
48
+ __contract__(
49
+ requires(0 <= offset && offset <= MLK_KECCAK_LANES * sizeof(uint64_t) &&
50
+ 0 <= length && length <= MLK_KECCAK_LANES * sizeof(uint64_t) - offset)
51
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY))
52
+ requires(memory_no_alias(data0, length))
53
+ requires(memory_no_alias(data1, length))
54
+ requires(memory_no_alias(data2, length))
55
+ requires(memory_no_alias(data3, length))
56
+ assigns(memory_slice(data0, length))
57
+ assigns(memory_slice(data1, length))
58
+ assigns(memory_slice(data2, length))
59
+ assigns(memory_slice(data3, length))
60
+ );
61
+
62
+ #define mlk_keccakf1600x4_xor_bytes MLK_NAMESPACE(keccakf1600x4_xor_bytes)
63
+ void mlk_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
64
+ const unsigned char *data1,
65
+ const unsigned char *data2,
66
+ const unsigned char *data3, unsigned offset,
67
+ unsigned length)
68
+ __contract__(
69
+ requires(0 <= offset && offset <= MLK_KECCAK_LANES * sizeof(uint64_t) &&
70
+ 0 <= length && length <= MLK_KECCAK_LANES * sizeof(uint64_t) - offset)
71
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY))
72
+ requires(memory_no_alias(data0, length))
73
+ /* Case 1: all input buffers are distinct; Case 2: All input buffers are the same */
74
+ requires((data0 == data1 &&
75
+ data0 == data2 &&
76
+ data0 == data3) ||
77
+ (memory_no_alias(data1, length) &&
78
+ memory_no_alias(data2, length) &&
79
+ memory_no_alias(data3, length)))
80
+ assigns(memory_slice(state, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY))
81
+ );
82
+
83
+
84
+ #define mlk_keccakf1600x4_permute MLK_NAMESPACE(keccakf1600x4_permute)
85
+ void mlk_keccakf1600x4_permute(uint64_t *state)
86
+ __contract__(
87
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY))
88
+ assigns(memory_slice(state, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY))
89
+ );
90
+
91
+ #define mlk_keccakf1600_permute MLK_NAMESPACE(keccakf1600_permute)
92
+ void mlk_keccakf1600_permute(uint64_t *state)
93
+ __contract__(
94
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLK_KECCAK_LANES))
95
+ assigns(memory_slice(state, sizeof(uint64_t) * MLK_KECCAK_LANES))
96
+ );
97
+
98
+ #endif /* !MLK_FIPS202_KECCAKF1600_H */
@@ -0,0 +1,70 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+
6
+ /* References
7
+ * ==========
8
+ *
9
+ * - [HYBRID]
10
+ * Hybrid scalar/vector implementations of Keccak and SPHINCS+ on AArch64
11
+ * Becker, Kannwischer
12
+ * https://eprint.iacr.org/2022/1243
13
+ */
14
+
15
+ #ifndef MLK_FIPS202_NATIVE_AARCH64_AUTO_H
16
+ #define MLK_FIPS202_NATIVE_AARCH64_AUTO_H
17
+ /* Default FIPS202 assembly profile for AArch64 systems */
18
+
19
+ /*
20
+ * Default logic to decide which implementation to use.
21
+ *
22
+ */
23
+
24
+ /*
25
+ * Keccak-f1600
26
+ *
27
+ * - On Arm-based Apple CPUs, we pick a pure Neon implementation.
28
+ * - Otherwise, unless MLK_SYS_AARCH64_SLOW_BARREL_SHIFTER is set,
29
+ * we use lazy-rotation scalar assembly from @[HYBRID].
30
+ * - Otherwise, if MLK_SYS_AARCH64_SLOW_BARREL_SHIFTER is set, we
31
+ * fall back to the standard C implementation.
32
+ */
33
+ #if defined(__ARM_FEATURE_SHA3) && defined(__APPLE__)
34
+ #include "x1_v84a.h"
35
+ #elif !defined(MLK_SYS_AARCH64_SLOW_BARREL_SHIFTER)
36
+ #include "x1_scalar.h"
37
+ #endif
38
+
39
+ /*
40
+ * Keccak-f1600x2/x4
41
+ *
42
+ * The optimal implementation is highly CPU-specific; see @[HYBRID].
43
+ *
44
+ * For now, if v8.4-A is not implemented, we fall back to Keccak-f1600.
45
+ * If v8.4-A is implemented and we are on an Apple CPU, we use a plain
46
+ * Neon-based implementation.
47
+ * If v8.4-A is implemented and we are not on an Apple CPU, we use a
48
+ * scalar/Neon/Neon hybrid.
49
+ * The reason for this distinction is that Apple CPUs appear to implement
50
+ * the SHA3 instructions on all SIMD units, while Arm CPUs prior to Cortex-X4
51
+ * don't, and ordinary Neon instructions are still needed.
52
+ */
53
+ #if defined(__ARM_FEATURE_SHA3)
54
+ /*
55
+ * For Apple-M cores, we use a plain implementation leveraging SHA3
56
+ * instructions only.
57
+ */
58
+ #if defined(__APPLE__)
59
+ #include "x2_v84a.h"
60
+ #else
61
+ #include "x4_v8a_v84a_scalar.h"
62
+ #endif
63
+
64
+ #else /* __ARM_FEATURE_SHA3 */
65
+
66
+ #include "x4_v8a_scalar.h"
67
+
68
+ #endif /* !__ARM_FEATURE_SHA3 */
69
+
70
+ #endif /* !MLK_FIPS202_NATIVE_AARCH64_AUTO_H */
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+ #ifndef MLK_FIPS202_NATIVE_AARCH64_SRC_FIPS202_NATIVE_AARCH64_H
6
+ #define MLK_FIPS202_NATIVE_AARCH64_SRC_FIPS202_NATIVE_AARCH64_H
7
+
8
+ #include "../../../../cbmc.h"
9
+ #include "../../../../common.h"
10
+
11
+ #define mlk_keccakf1600_round_constants \
12
+ MLK_NAMESPACE(keccakf1600_round_constants)
13
+ extern const uint64_t mlk_keccakf1600_round_constants[];
14
+
15
+ #define mlk_keccak_f1600_x1_scalar_asm MLK_NAMESPACE(keccak_f1600_x1_scalar_asm)
16
+ void mlk_keccak_f1600_x1_scalar_asm(uint64_t state[25], const uint64_t rc[24])
17
+ /* This must be kept in sync with the HOL-Light specification
18
+ * in proofs/hol_light/aarch64/proofs/keccak_f1600_x1_scalar.ml */
19
+ __contract__(
20
+ requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 1))
21
+ requires(rc == mlk_keccakf1600_round_constants)
22
+ assigns(memory_slice(state, sizeof(uint64_t) * 25 * 1))
23
+ );
24
+
25
+ #define mlk_keccak_f1600_x1_v84a_asm MLK_NAMESPACE(keccak_f1600_x1_v84a_asm)
26
+ void mlk_keccak_f1600_x1_v84a_asm(uint64_t state[25], const uint64_t rc[24])
27
+ /* This must be kept in sync with the HOL-Light specification
28
+ * in proofs/hol_light/aarch64/proofs/keccak_f1600_x1_v84a.ml */
29
+ __contract__(
30
+ requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 1))
31
+ requires(rc == mlk_keccakf1600_round_constants)
32
+ assigns(memory_slice(state, sizeof(uint64_t) * 25 * 1))
33
+ );
34
+
35
+ #define mlk_keccak_f1600_x2_v84a_asm MLK_NAMESPACE(keccak_f1600_x2_v84a_asm)
36
+ void mlk_keccak_f1600_x2_v84a_asm(uint64_t state[50], const uint64_t rc[24])
37
+ /* This must be kept in sync with the HOL-Light specification
38
+ * in proofs/hol_light/aarch64/proofs/keccak_f1600_x2_v84a.ml */
39
+ __contract__(
40
+ requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 2))
41
+ requires(rc == mlk_keccakf1600_round_constants)
42
+ assigns(memory_slice(state, sizeof(uint64_t) * 25 * 2))
43
+ );
44
+
45
+ #define mlk_keccak_f1600_x4_v8a_scalar_hybrid_asm \
46
+ MLK_NAMESPACE(keccak_f1600_x4_v8a_scalar_hybrid_asm)
47
+ void mlk_keccak_f1600_x4_v8a_scalar_hybrid_asm(uint64_t state[100],
48
+ const uint64_t rc[24])
49
+ /* This must be kept in sync with the HOL-Light specification
50
+ * in proofs/hol_light/aarch64/proofs/keccak_f1600_x4_v8a_scalar.ml */
51
+ __contract__(
52
+ requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 4))
53
+ requires(rc == mlk_keccakf1600_round_constants)
54
+ assigns(memory_slice(state, sizeof(uint64_t) * 25 * 4))
55
+ );
56
+
57
+ #define mlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm \
58
+ MLK_NAMESPACE(keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm)
59
+ void mlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm(uint64_t state[100],
60
+ const uint64_t rc[24])
61
+ /* This must be kept in sync with the HOL-Light specification
62
+ * in proofs/hol_light/aarch64/proofs/keccak_f1600_x4_v8a_v84a_scalar.ml */
63
+ __contract__(
64
+ requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 4))
65
+ requires(rc == mlk_keccakf1600_round_constants)
66
+ assigns(memory_slice(state, sizeof(uint64_t) * 25 * 4))
67
+ );
68
+
69
+ #endif /* !MLK_FIPS202_NATIVE_AARCH64_SRC_FIPS202_NATIVE_AARCH64_H */