pq_crypto 0.6.7 → 0.6.9

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 (214) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/README.md +1 -3
  4. data/ext/pqcrypto/pqcrypto_ruby_secure.c +41 -11
  5. data/ext/pqcrypto/pqcrypto_secure.c +501 -296
  6. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  7. data/ext/pqcrypto/vendor/.vendored +7 -7
  8. data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +71 -0
  9. data/ext/pqcrypto/vendor/mldsa-native/README.md +26 -11
  10. data/ext/pqcrypto/vendor/mldsa-native/RELEASE.md +77 -150
  11. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +93 -40
  12. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +74 -59
  13. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +106 -40
  14. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +94 -92
  15. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/capability.h +31 -0
  16. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +55 -4
  17. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +30 -0
  18. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/context.h +1 -0
  19. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +1 -0
  20. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +1 -0
  21. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -2
  22. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +4 -4
  23. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +4 -4
  24. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +8 -3
  25. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +8 -4
  26. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +12 -0
  27. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +4 -2
  28. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +37 -19
  29. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +37 -19
  30. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +3 -8
  31. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/auto.h +53 -0
  32. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x1_avx512.h +38 -0
  33. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx512.h +38 -0
  34. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +24 -0
  35. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x1_avx512_asm.S +574 -0
  36. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +46 -18
  37. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx512_asm.S +679 -0
  38. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +13 -4
  39. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +6 -4
  40. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +5 -6
  41. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_intt_aarch64_asm.S +4 -2
  42. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_ntt_aarch64_asm.S +4 -2
  43. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_pointwise_montgomery_aarch64_asm.S +6 -4
  44. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_caddq_aarch64_asm.S +4 -2
  45. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_chknorm_aarch64_asm.S +6 -4
  46. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_32_aarch64_asm.S +4 -3
  47. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_88_aarch64_asm.S +4 -3
  48. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_32_aarch64_asm.S +4 -3
  49. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_88_aarch64_asm.S +4 -3
  50. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +4 -2
  51. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +4 -2
  52. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +4 -2
  53. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_17_aarch64_asm.S +5 -3
  54. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_19_aarch64_asm.S +5 -3
  55. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_aarch64_asm.S +110 -120
  56. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta2_aarch64_asm.S +109 -101
  57. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta4_aarch64_asm.S +97 -93
  58. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +1 -9
  59. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +4 -0
  60. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/fastmul.h +74 -0
  61. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/slowmul.h +77 -0
  62. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/arith_native_rv32im.h +124 -0
  63. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_intt_rv32im_asm.S +331 -0
  64. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_intt_rv32im_slowmul_asm.S +381 -0
  65. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_ntt_rv32im_asm.S +304 -0
  66. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_ntt_rv32im_slowmul_asm.S +351 -0
  67. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/mldsa_poly_pointwise_montgomery_rv32im_asm.S +139 -0
  68. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/rv32im/src/rv32im_zetas.c +118 -0
  69. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +6 -5
  70. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +2 -3
  71. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_intt_avx2_asm.S +5 -3
  72. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_ntt_avx2_asm.S +5 -3
  73. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_nttunpack_avx2_asm.S +5 -3
  74. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l4_avx2_asm.S +6 -3
  75. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l5_avx2_asm.S +6 -3
  76. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l7_avx2_asm.S +6 -3
  77. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_avx2_asm.S +5 -3
  78. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_caddq_avx2_asm.S +5 -3
  79. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +7 -5
  80. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +69 -67
  81. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +69 -67
  82. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +12 -16
  83. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +14 -18
  84. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +6 -3
  85. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +6 -3
  86. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +5 -3
  87. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +5 -3
  88. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +5 -3
  89. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +23 -27
  90. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +21 -42
  91. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +28 -1
  92. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +87 -28
  93. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +61 -3
  94. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +23 -19
  95. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +30 -0
  96. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +55 -107
  97. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +67 -107
  98. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +16 -24
  99. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +27 -21
  100. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +8 -8
  101. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +191 -119
  102. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +6 -3
  103. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +16 -42
  104. data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +72 -0
  105. data/ext/pqcrypto/vendor/mlkem-native/README.md +9 -5
  106. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +64 -312
  107. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +77 -34
  108. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +41 -13
  109. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +89 -33
  110. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +50 -46
  111. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/capability.h +30 -0
  112. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +30 -0
  113. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +1 -0
  114. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +4 -5
  115. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.c +1 -0
  116. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +15 -0
  117. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +23 -8
  118. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +11 -3
  119. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +7 -1
  120. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +8 -0
  121. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.h +8 -0
  122. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -2
  123. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +4 -4
  124. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +4 -4
  125. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +8 -3
  126. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +8 -4
  127. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +4 -2
  128. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +37 -19
  129. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +37 -19
  130. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +2 -2
  131. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/auto.h +47 -0
  132. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x1_avx512.h +37 -0
  133. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx512.h +37 -0
  134. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +24 -0
  135. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x1_avx512_asm.S +573 -0
  136. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +46 -18
  137. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx512_asm.S +678 -0
  138. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +13 -4
  139. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +1 -2
  140. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +7 -5
  141. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +29 -5
  142. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +156 -0
  143. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +137 -3
  144. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/compress_d5_table.c +43 -0
  145. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d10_table.c +50 -0
  146. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d11_table.c +53 -0
  147. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d4_table.c +44 -0
  148. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/decompress_d5_table.c +53 -0
  149. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_intt_aarch64_asm.S +5 -3
  150. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_ntt_aarch64_asm.S +4 -2
  151. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d10_aarch64_asm.S +439 -0
  152. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d11_aarch64_asm.S +452 -0
  153. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d4_aarch64_asm.S +106 -0
  154. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_compress_d5_aarch64_asm.S +124 -0
  155. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d10_aarch64_asm.S +108 -0
  156. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d11_aarch64_asm.S +116 -0
  157. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d4_aarch64_asm.S +93 -0
  158. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_decompress_d5_aarch64_asm.S +104 -0
  159. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_frombytes_aarch64_asm.S +84 -0
  160. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_mulcache_compute_aarch64_asm.S +4 -2
  161. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_reduce_aarch64_asm.S +4 -2
  162. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_tobytes_aarch64_asm.S +5 -3
  163. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_poly_tomont_aarch64_asm.S +4 -3
  164. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S +4 -2
  165. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S +4 -2
  166. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S +4 -2
  167. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/mlkem_rej_uniform_aarch64_asm.S +112 -104
  168. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +0 -1
  169. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +2 -2
  170. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/README.md +2 -2
  171. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +16 -21
  172. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/arith_native_ppc64le.h +1 -0
  173. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/consts.c +2 -2
  174. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_intt_ppc_asm.S +6 -5
  175. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_ntt_ppc_asm.S +6 -5
  176. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_poly_tomont_ppc_asm.S +6 -5
  177. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/mlkem_reduce_ppc_asm.S +6 -5
  178. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +5 -4
  179. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +2 -2
  180. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +1 -1
  181. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +5 -5
  182. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_intt_avx2_asm.S +36 -33
  183. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_ntt_avx2_asm.S +67 -65
  184. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_nttfrombytes_avx2_asm.S +8 -5
  185. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_ntttobytes_avx2_asm.S +6 -3
  186. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_nttunpack_avx2_asm.S +5 -3
  187. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d10_avx2_asm.S +7 -5
  188. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d11_avx2_asm.S +7 -4
  189. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d4_avx2_asm.S +7 -5
  190. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_compress_d5_avx2_asm.S +7 -4
  191. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d10_avx2_asm.S +7 -4
  192. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d11_avx2_asm.S +6 -4
  193. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d4_avx2_asm.S +7 -4
  194. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_decompress_d5_avx2_asm.S +6 -4
  195. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_poly_mulcache_compute_avx2_asm.S +5 -3
  196. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S +118 -115
  197. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S +174 -171
  198. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S +230 -227
  199. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_reduce_avx2_asm.S +17 -15
  200. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_rej_uniform_avx2_asm.S +7 -6
  201. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/mlkem_tomont_avx2_asm.S +5 -3
  202. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +4 -9
  203. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +1 -1
  204. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +31 -44
  205. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +1 -1
  206. data/lib/pq_crypto/internal.rb +10 -0
  207. data/lib/pq_crypto/kem.rb +5 -10
  208. data/lib/pq_crypto/pkcs8/der.rb +26 -11
  209. data/lib/pq_crypto/pkcs8/private_key_choice.rb +21 -25
  210. data/lib/pq_crypto/signature.rb +28 -40
  211. data/lib/pq_crypto/spki.rb +36 -23
  212. data/lib/pq_crypto/version.rb +1 -1
  213. data/script/vendor_libs.rb +6 -6
  214. metadata +36 -1
@@ -53,11 +53,13 @@
53
53
  // Prologue -- if offset is not 8-byte aligned, extract
54
54
  // min(length, 8-(offset%8)) bytes via predicated byte stores.
55
55
  // Main -- process full 8-byte groups: load even/odd lane pair,
56
- // de-interleave, scatter-store to output buffers.
56
+ // de-interleave, scatter-store to aligned output buffers
57
+ // or use predicated byte stores for unaligned buffers.
57
58
  // Tail -- extract remaining <8 bytes via predicated byte stores.
58
59
 
59
60
  #include "../../../../common.h"
60
- #if defined(MLK_FIPS202_ARMV81M_NEED_X4) && \
61
+ #if defined(MLK_SYS_ARMV81M_MVE) && \
62
+ defined(MLK_FIPS202_ARMV81M_NEED_X4) && \
61
63
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
62
64
 
63
65
  /*
@@ -99,13 +101,13 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x4_state_extract_bytes_asm)
99
101
  ldr.w r10, [sp, #0x6c]
100
102
  ldr r6, [sp, #0x70]
101
103
  cmp r6, #0x0
102
- beq.w Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0x2ea
104
+ beq.w Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0x308
103
105
  and r5, r10, #0x7
104
106
  bic r9, r10, #0x7
105
107
  add.w r8, r0, r9, lsl #1
106
108
  add.w r7, r8, #0x190
107
109
  cmp r5, #0x0
108
- beq.w Lmlk_keccak_f1600_x4_state_extract_bytes_asm_pre_main @ imm = #0x112
110
+ beq.w Lmlk_keccak_f1600_x4_state_extract_bytes_asm_pre_main @ imm = #0x108
109
111
  vldrw.u32 q0, [r8], #16
110
112
  vldrw.u32 q1, [r7], #16
111
113
  vrev32.16 q2, q0
@@ -169,18 +171,20 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x4_state_extract_bytes_asm)
169
171
  subs r3, r3, r5
170
172
  subs r4, r4, r5
171
173
  vpstttt
172
- vstrbt.8 q0, [r1], #4
173
- vstrbt.8 q1, [r2], #4
174
- vstrbt.8 q2, [r3], #4
175
- vstrbt.8 q3, [r4], #4
174
+ vstrbt.8 q0, [r1], #8
175
+ vstrbt.8 q1, [r2], #8
176
+ vstrbt.8 q2, [r3], #8
177
+ vstrbt.8 q3, [r4], #8
176
178
  subs.w r6, r6, lr
177
179
  cmp r6, #0x0
178
- beq.w Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0x1cc
179
- vmov q7[2], q7[0], r1, r3
180
- vmov q7[3], q7[1], r2, r4
181
- b Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_body @ imm = #0xe
180
+ beq.w Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0x1ea
182
181
 
183
182
  Lmlk_keccak_f1600_x4_state_extract_bytes_asm_pre_main:
183
+ orr.w r12, r1, r2
184
+ orr.w r12, r12, r3
185
+ orr.w r12, r12, r4
186
+ tst.w r12, #0x3
187
+ bne Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_body_byte @ imm = #0xe2
184
188
  vmov q7[2], q7[0], r1, r3
185
189
  vmov q7[3], q7[1], r2, r4
186
190
  mov.w r12, #0x4
@@ -239,11 +243,17 @@ Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_loop_start:
239
243
 
240
244
  Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_loop_end:
241
245
  ands r6, r6, #0x7
242
- beq Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0xee
246
+ beq.w Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0x104
243
247
  mov.w r12, #0x4
244
248
  vadd.i32 q7, q7, r12
245
249
  vmov r1, r3, q7[2], q7[0]
246
250
  vmov r2, r4, q7[3], q7[1]
251
+
252
+ Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_body_byte:
253
+ cmp r6, #0x0
254
+ beq Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0xee
255
+
256
+ Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_loop_byte_start:
247
257
  vldrw.u32 q0, [r8], #16
248
258
  vldrw.u32 q1, [r7], #16
249
259
  vrev32.16 q2, q0
@@ -294,12 +304,18 @@ Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_loop_end:
294
304
  vpsel q1, q2, q1
295
305
  vmov.f64 d4, d1
296
306
  vmov.f64 d6, d3
297
- vctp.8 r6
307
+ mov.w lr, #0x8
308
+ cmp r6, #0x8
309
+ it lo
310
+ movlo lr, r6
311
+ vctp.8 lr
298
312
  vpstttt
299
- vstrbt.8 q0, [r1], #4
300
- vstrbt.8 q1, [r2], #4
301
- vstrbt.8 q2, [r3], #4
302
- vstrbt.8 q3, [r4], #4
313
+ vstrbt.8 q0, [r1], #8
314
+ vstrbt.8 q1, [r2], #8
315
+ vstrbt.8 q2, [r3], #8
316
+ vstrbt.8 q3, [r4], #8
317
+ subs.w r6, r6, lr
318
+ bne Lmlk_keccak_f1600_x4_state_extract_bytes_asm_main_loop_byte_start @ imm = #-0xf2
303
319
 
304
320
  Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit:
305
321
  vpop {d8, d9, d10, d11, d12, d13, d14, d15}
@@ -324,10 +340,12 @@ Lmlk_keccak_f1600_x4_state_extract_bytes_asm_exit:
324
340
  .cfi_restore lr
325
341
  .cfi_adjust_cfa_offset -0x28
326
342
  .cfi_endproc
343
+ nop
327
344
 
328
345
  MLK_ASM_FN_SIZE(keccak_f1600_x4_state_extract_bytes_asm)
329
346
 
330
- #endif /* MLK_FIPS202_ARMV81M_NEED_X4 && !MLK_CONFIG_MULTILEVEL_NO_SHARED */
347
+ #endif /* MLK_SYS_ARMV81M_MVE && MLK_FIPS202_ARMV81M_NEED_X4 && \
348
+ !MLK_CONFIG_MULTILEVEL_NO_SHARED */
331
349
 
332
350
  #if defined(__ELF__)
333
351
  .section .note.GNU-stack,"",%progbits
@@ -51,12 +51,14 @@
51
51
  // ---------------------------------------------------------------------------
52
52
  // Prologue -- if offset is not 8-byte aligned, absorb
53
53
  // min(length, 8-(offset%8)) bytes via predicated byte loads.
54
- // Main -- process full 8-byte groups via word-level gather loads,
55
- // bit-interleave, then VEOR into even/odd state halves.
54
+ // Main -- process full 8-byte groups via vldrw.u32 gather loads when
55
+ // 32-bit aligned, otherwise byte loads; bit-interleave, then
56
+ // VEOR into even/odd state halves.
56
57
  // Tail -- absorb remaining <8 bytes via predicated byte loads.
57
58
 
58
59
  #include "../../../../common.h"
59
- #if defined(MLK_FIPS202_ARMV81M_NEED_X4) && \
60
+ #if defined(MLK_SYS_ARMV81M_MVE) && \
61
+ defined(MLK_FIPS202_ARMV81M_NEED_X4) && \
60
62
  !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
61
63
 
62
64
  /*
@@ -98,13 +100,13 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x4_state_xor_bytes_asm)
98
100
  ldr.w r10, [sp, #0x6c]
99
101
  ldr r6, [sp, #0x70]
100
102
  cmp r6, #0x0
101
- beq.w Lmlk_keccak_f1600_x4_state_xor_bytes_asm_exit @ imm = #0x346
103
+ beq.w Lmlk_keccak_f1600_x4_state_xor_bytes_asm_exit @ imm = #0x368
102
104
  and r5, r10, #0x7
103
105
  bic r9, r10, #0x7
104
106
  add.w r8, r0, r9, lsl #1
105
107
  add.w r7, r8, #0x190
106
108
  cmp r5, #0x0
107
- beq.w Lmlk_keccak_f1600_x4_state_xor_bytes_asm_pre_main @ imm = #0x12c
109
+ beq.w Lmlk_keccak_f1600_x4_state_xor_bytes_asm_pre_main @ imm = #0x122
108
110
  subs r1, r1, r5
109
111
  subs r2, r2, r5
110
112
  subs r3, r3, r5
@@ -119,10 +121,10 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x4_state_xor_bytes_asm)
119
121
  lsl.w r11, r11, r5
120
122
  vmsr p0, r11
121
123
  vpstttt
122
- vldrbt.u8 q0, [r1], #4
123
- vldrbt.u8 q1, [r2], #4
124
- vldrbt.u8 q2, [r3], #4
125
- vldrbt.u8 q3, [r4], #4
124
+ vldrbt.u8 q0, [r1], #8
125
+ vldrbt.u8 q1, [r2], #8
126
+ vldrbt.u8 q2, [r3], #8
127
+ vldrbt.u8 q3, [r4], #8
126
128
  vmov.f64 d1, d4
127
129
  vmov.f64 d3, d6
128
130
  vrev64.32 q2, q0
@@ -181,11 +183,13 @@ MLK_ASM_FN_SYMBOL(keccak_f1600_x4_state_xor_bytes_asm)
181
183
  veor q5, q5, q1
182
184
  vstrw.32 q4, [r8], #16
183
185
  vstrw.32 q5, [r7], #16
184
- vmov q7[2], q7[0], r1, r3
185
- vmov q7[3], q7[1], r2, r4
186
- b Lmlk_keccak_f1600_x4_state_xor_bytes_asm_main_body @ imm = #0xe
187
186
 
188
187
  Lmlk_keccak_f1600_x4_state_xor_bytes_asm_pre_main:
188
+ orr.w r0, r1, r2
189
+ orr.w r0, r0, r3
190
+ orr.w r0, r0, r4
191
+ tst.w r0, #0x3
192
+ bne.w Lmlk_keccak_f1600_x4_state_xor_bytes_asm_main_body_byte @ imm = #0x104
189
193
  vmov q7[2], q7[0], r1, r3
190
194
  vmov q7[3], q7[1], r2, r4
191
195
  mov.w r0, #0x4
@@ -252,17 +256,27 @@ Lmlk_keccak_f1600_x4_state_xor_bytes_asm_main_loop_start:
252
256
 
253
257
  Lmlk_keccak_f1600_x4_state_xor_bytes_asm_main_loop_end:
254
258
  ands r6, r6, #0x7
255
- beq.w Lmlk_keccak_f1600_x4_state_xor_bytes_asm_exit @ imm = #0x110
259
+ beq.w Lmlk_keccak_f1600_x4_state_xor_bytes_asm_exit @ imm = #0x128
256
260
  mov.w r0, #0x4
257
261
  vadd.i32 q7, q7, r0
258
262
  vmov r1, r3, q7[2], q7[0]
259
263
  vmov r2, r4, q7[3], q7[1]
260
- vctp.8 r6
264
+
265
+ Lmlk_keccak_f1600_x4_state_xor_bytes_asm_main_body_byte:
266
+ cmp r6, #0x0
267
+ beq.w Lmlk_keccak_f1600_x4_state_xor_bytes_asm_exit @ imm = #0x112
268
+
269
+ Lmlk_keccak_f1600_x4_state_xor_bytes_asm_main_loop_byte_start:
270
+ mov.w lr, #0x8
271
+ cmp r6, #0x8
272
+ it lo
273
+ movlo lr, r6
274
+ vctp.8 lr
261
275
  vpstttt
262
- vldrbt.u8 q0, [r1]
263
- vldrbt.u8 q1, [r2]
264
- vldrbt.u8 q2, [r3]
265
- vldrbt.u8 q3, [r4]
276
+ vldrbt.u8 q0, [r1], #8
277
+ vldrbt.u8 q1, [r2], #8
278
+ vldrbt.u8 q2, [r3], #8
279
+ vldrbt.u8 q3, [r4], #8
266
280
  vmov.f64 d1, d4
267
281
  vmov.f64 d3, d6
268
282
  vrev64.32 q2, q0
@@ -321,6 +335,8 @@ Lmlk_keccak_f1600_x4_state_xor_bytes_asm_main_loop_end:
321
335
  veor q5, q5, q1
322
336
  vstrw.32 q4, [r8], #16
323
337
  vstrw.32 q5, [r7], #16
338
+ subs.w r6, r6, lr
339
+ bne.w Lmlk_keccak_f1600_x4_state_xor_bytes_asm_main_loop_byte_start @ imm = #-0x112
324
340
 
325
341
  Lmlk_keccak_f1600_x4_state_xor_bytes_asm_exit:
326
342
  vpop {d8, d9, d10, d11, d12, d13, d14, d15}
@@ -345,10 +361,12 @@ Lmlk_keccak_f1600_x4_state_xor_bytes_asm_exit:
345
361
  .cfi_restore lr
346
362
  .cfi_adjust_cfa_offset -0x28
347
363
  .cfi_endproc
364
+ nop
348
365
 
349
366
  MLK_ASM_FN_SIZE(keccak_f1600_x4_state_xor_bytes_asm)
350
367
 
351
- #endif /* MLK_FIPS202_ARMV81M_NEED_X4 && !MLK_CONFIG_MULTILEVEL_NO_SHARED */
368
+ #endif /* MLK_SYS_ARMV81M_MVE && MLK_FIPS202_ARMV81M_NEED_X4 && \
369
+ !MLK_CONFIG_MULTILEVEL_NO_SHARED */
352
370
 
353
371
  #if defined(__ELF__)
354
372
  .section .note.GNU-stack,"",%progbits
@@ -16,8 +16,8 @@
16
16
  #endif
17
17
 
18
18
  /* The x86_64 backend requires toolchain support for the SysV ABI */
19
- #if defined(MLK_SYS_X86_64_AVX2) && defined(MLK_SYSV_ABI_SUPPORTED)
20
- #include "x86_64/keccak_f1600_x4_avx2.h"
19
+ #if defined(MLK_SYS_X86_64) && defined(MLK_SYSV_ABI_SUPPORTED)
20
+ #include "x86_64/auto.h"
21
21
  #endif
22
22
 
23
23
  /* We do not yet include the FIPS202 backend for Armv8.1-M+MVE by default
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+
6
+ #ifndef MLK_FIPS202_NATIVE_X86_64_AUTO_H
7
+ #define MLK_FIPS202_NATIVE_X86_64_AUTO_H
8
+ /* Default FIPS202 assembly profile for x86_64 systems */
9
+
10
+ /*
11
+ * Default logic to decide which implementation to use.
12
+ *
13
+ * Each function has a single implementation. If its capability check
14
+ * fails at runtime (see MLK_CONFIG_CUSTOM_CAPABILITY_FUNC), the function
15
+ * falls back to the default C code, not to another x86_64
16
+ * implementation. For example, if AVX-512 is enabled at compile time but
17
+ * the AVX-512 check fails, Keccak-f1600x4 is computed by four calls to
18
+ * Keccak-f1600, which runs in C; the AVX2 implementation of
19
+ * Keccak-f1600x4 is not used.
20
+ */
21
+
22
+ /*
23
+ * Keccak-f1600
24
+ *
25
+ * - If AVX-512 (F, VL and DQ) is enabled, we use the AVX-512
26
+ * implementation.
27
+ * - Otherwise, we fall back to the standard C implementation.
28
+ */
29
+ #if defined(MLK_SYS_X86_64_AVX512)
30
+ #include "keccak_f1600_x1_avx512.h"
31
+ #endif
32
+
33
+ /*
34
+ * Keccak-f1600x4
35
+ *
36
+ * - If AVX-512 (F, VL and DQ) is enabled, we use the AVX-512
37
+ * implementation.
38
+ * - Otherwise, if AVX2 is enabled, we use the AVX2 implementation.
39
+ * - Otherwise, Keccak-f1600x4 is computed by four calls to Keccak-f1600.
40
+ */
41
+ #if defined(MLK_SYS_X86_64_AVX512)
42
+ #include "keccak_f1600_x4_avx512.h"
43
+ #elif defined(MLK_SYS_X86_64_AVX2)
44
+ #include "keccak_f1600_x4_avx2.h"
45
+ #endif
46
+
47
+ #endif /* !MLK_FIPS202_NATIVE_X86_64_AUTO_H */
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+
6
+ #ifndef MLK_FIPS202_NATIVE_X86_64_KECCAK_F1600_X1_AVX512_H
7
+ #define MLK_FIPS202_NATIVE_X86_64_KECCAK_F1600_X1_AVX512_H
8
+
9
+ #include "../../../common.h"
10
+
11
+ #if !defined(MLK_SYS_X86_64_AVX512)
12
+ #error This backend can only be used if AVX-512 (F, VL and DQ) is enabled.
13
+ #endif
14
+
15
+ /* Guard for assembly file */
16
+ #define MLK_FIPS202_X86_64_NEED_X1_AVX512
17
+
18
+ /* Part of backend API */
19
+ #define MLK_USE_NATIVE_FIPS202_X1
20
+
21
+ #if !defined(__ASSEMBLER__)
22
+ #include "../api.h"
23
+ #include "src/fips202_native_x86_64.h"
24
+ MLK_MUST_CHECK_RETURN_VALUE
25
+ static MLK_INLINE int mlk_keccak_f1600_x1_native(uint64_t *state)
26
+ {
27
+ if (!mlk_sys_check_capability(MLK_SYS_CAP_X86_64_AVX512))
28
+ {
29
+ return MLK_NATIVE_FUNC_FALLBACK;
30
+ }
31
+
32
+ mlk_keccak_f1600_x1_avx512_asm(state, mlk_keccakf1600_round_constants);
33
+ return MLK_NATIVE_FUNC_SUCCESS;
34
+ }
35
+ #endif /* !__ASSEMBLER__ */
36
+
37
+ #endif /* !MLK_FIPS202_NATIVE_X86_64_KECCAK_F1600_X1_AVX512_H */
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
4
+ */
5
+
6
+ #ifndef MLK_FIPS202_NATIVE_X86_64_KECCAK_F1600_X4_AVX512_H
7
+ #define MLK_FIPS202_NATIVE_X86_64_KECCAK_F1600_X4_AVX512_H
8
+
9
+ #include "../../../common.h"
10
+
11
+ #if !defined(MLK_SYS_X86_64_AVX512)
12
+ #error This backend can only be used if AVX-512 (F, VL and DQ) is enabled.
13
+ #endif
14
+
15
+ /* Guard for assembly file */
16
+ #define MLK_FIPS202_X86_64_NEED_X4_AVX512
17
+
18
+ /* Part of backend API */
19
+ #define MLK_USE_NATIVE_FIPS202_X4
20
+
21
+ #if !defined(__ASSEMBLER__)
22
+ #include "../api.h"
23
+ #include "src/fips202_native_x86_64.h"
24
+ MLK_MUST_CHECK_RETURN_VALUE
25
+ static MLK_INLINE int mlk_keccak_f1600_x4_native(uint64_t *state)
26
+ {
27
+ if (!mlk_sys_check_capability(MLK_SYS_CAP_X86_64_AVX512))
28
+ {
29
+ return MLK_NATIVE_FUNC_FALLBACK;
30
+ }
31
+
32
+ mlk_keccak_f1600_x4_avx512_asm(state, mlk_keccakf1600_round_constants);
33
+ return MLK_NATIVE_FUNC_SUCCESS;
34
+ }
35
+ #endif /* !__ASSEMBLER__ */
36
+
37
+ #endif /* !MLK_FIPS202_NATIVE_X86_64_KECCAK_F1600_X4_AVX512_H */
@@ -41,4 +41,28 @@ __contract__(
41
41
  assigns(memory_slice(states, sizeof(uint64_t) * 25 * 4))
42
42
  );
43
43
 
44
+ #define mlk_keccak_f1600_x1_avx512_asm \
45
+ MLK_NAMESPACE(keccak_f1600_x1_avx512_asm)
46
+ MLK_SYSV_ABI
47
+ void mlk_keccak_f1600_x1_avx512_asm(uint64_t state[25], const uint64_t rc[24])
48
+ /* This must be kept in sync with the HOL-Light specification
49
+ * in proofs/hol_light/x86_64/proofs/keccak_f1600_x1_avx512_asm.ml */
50
+ __contract__(
51
+ requires(memory_no_alias(state, sizeof(uint64_t) * 25))
52
+ requires(rc == mlk_keccakf1600_round_constants)
53
+ assigns(memory_slice(state, sizeof(uint64_t) * 25))
54
+ );
55
+
56
+ #define mlk_keccak_f1600_x4_avx512_asm \
57
+ MLK_NAMESPACE(keccak_f1600_x4_avx512_asm)
58
+ MLK_SYSV_ABI
59
+ void mlk_keccak_f1600_x4_avx512_asm(uint64_t states[100], const uint64_t rc[24])
60
+ /* This must be kept in sync with the HOL-Light specification
61
+ * in proofs/hol_light/x86_64/proofs/keccak_f1600_x4_avx512_asm.ml */
62
+ __contract__(
63
+ requires(memory_no_alias(states, sizeof(uint64_t) * 25 * 4))
64
+ requires(rc == mlk_keccakf1600_round_constants)
65
+ assigns(memory_slice(states, sizeof(uint64_t) * 25 * 4))
66
+ );
67
+
44
68
  #endif /* !MLK_FIPS202_NATIVE_X86_64_SRC_FIPS202_NATIVE_X86_64_H */