pq_crypto 0.6.4 → 0.6.6

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 (213) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +180 -0
  3. data/README.md +7 -0
  4. data/ext/pqcrypto/extconf.rb +4 -1
  5. data/ext/pqcrypto/pq_externalmu.c +35 -0
  6. data/ext/pqcrypto/pqcrypto_native_api.h +85 -75
  7. data/ext/pqcrypto/pqcrypto_ruby_secure.c +16 -9
  8. data/ext/pqcrypto/pqcrypto_secure.c +43 -33
  9. data/ext/pqcrypto/pqcrypto_secure.h +52 -47
  10. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  11. data/ext/pqcrypto/vendor/.vendored +7 -7
  12. data/ext/pqcrypto/vendor/mldsa-native/BUILDING.md +5 -2
  13. data/ext/pqcrypto/vendor/mldsa-native/LICENSE +21 -2
  14. data/ext/pqcrypto/vendor/mldsa-native/README.md +20 -7
  15. data/ext/pqcrypto/vendor/mldsa-native/RELEASE.md +160 -0
  16. data/ext/pqcrypto/vendor/mldsa-native/SECURITY.md +1 -1
  17. data/ext/pqcrypto/vendor/mldsa-native/mldsa/README.md +2 -2
  18. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +85 -59
  19. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +292 -348
  20. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +122 -76
  21. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +184 -86
  22. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +49 -4
  23. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +49 -81
  24. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/context.h +152 -0
  25. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +25 -12
  26. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.c +2 -0
  27. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +2 -0
  28. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +2 -2
  29. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +9 -11
  30. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +19 -11
  31. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +6 -4
  32. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +7 -4
  33. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +7 -4
  34. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +12 -9
  35. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +12 -9
  36. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +1 -1
  37. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +3 -2
  38. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +3 -2
  39. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +6 -1
  40. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +3 -2
  41. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +11 -11
  42. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +9 -22
  43. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +8 -5
  44. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +1 -0
  45. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/{state_extract_bytes_x4_mve.S → keccak_f1600_x4_state_extract_bytes_mve.S} +14 -14
  46. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/{state_xor_bytes_x4_mve.S → keccak_f1600_x4_state_xor_bytes_mve.S} +12 -12
  47. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +5 -4
  48. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +2 -2
  49. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +1 -0
  50. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +36 -2
  51. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +62 -4
  52. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +87 -54
  53. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{intt_aarch64_asm.S → mldsa_intt_aarch64_asm.S} +39 -6
  54. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{ntt_aarch64_asm.S → mldsa_ntt_aarch64_asm.S} +39 -6
  55. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{pointwise_montgomery_aarch64_asm.S → mldsa_pointwise_montgomery_aarch64_asm.S} +25 -3
  56. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_caddq_aarch64_asm.S → mldsa_poly_caddq_aarch64_asm.S} +19 -3
  57. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_chknorm_aarch64_asm.S → mldsa_poly_chknorm_aarch64_asm.S} +24 -3
  58. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_decompose_32_aarch64_asm.S → mldsa_poly_decompose_32_aarch64_asm.S} +25 -3
  59. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_decompose_88_aarch64_asm.S → mldsa_poly_decompose_88_aarch64_asm.S} +25 -3
  60. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_use_hint_32_aarch64_asm.S → mldsa_poly_use_hint_32_aarch64_asm.S} +25 -3
  61. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{poly_use_hint_88_aarch64_asm.S → mldsa_poly_use_hint_88_aarch64_asm.S} +25 -3
  62. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S} +31 -3
  63. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S} +31 -3
  64. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S → mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S} +31 -3
  65. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{polyz_unpack_17_aarch64_asm.S → mldsa_polyz_unpack_17_aarch64_asm.S} +31 -3
  66. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{polyz_unpack_19_aarch64_asm.S → mldsa_polyz_unpack_19_aarch64_asm.S} +31 -3
  67. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_aarch64_asm.S → mldsa_rej_uniform_aarch64_asm.S} +48 -15
  68. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_eta2_aarch64_asm.S → mldsa_rej_uniform_eta2_aarch64_asm.S} +42 -9
  69. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/{rej_uniform_eta4_aarch64_asm.S → mldsa_rej_uniform_eta4_aarch64_asm.S} +42 -9
  70. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +11 -3
  71. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/meta.h +3 -2
  72. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +28 -28
  73. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +171 -49
  74. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{intt_avx2_asm.S → mldsa_intt_avx2_asm.S} +23 -1
  75. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{ntt_avx2_asm.S → mldsa_ntt_avx2_asm.S} +23 -1
  76. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{nttunpack_avx2_asm.S → mldsa_nttunpack_avx2_asm.S} +17 -1
  77. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l4_avx2_asm.S → mldsa_pointwise_acc_l4_avx2_asm.S} +37 -3
  78. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l5_avx2_asm.S → mldsa_pointwise_acc_l5_avx2_asm.S} +37 -3
  79. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_acc_l7_avx2_asm.S → mldsa_pointwise_acc_l7_avx2_asm.S} +37 -3
  80. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{pointwise_avx2_asm.S → mldsa_pointwise_avx2_asm.S} +31 -3
  81. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/{poly_caddq_avx2_asm.S → mldsa_poly_caddq_avx2_asm.S} +18 -9
  82. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +176 -0
  83. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +490 -0
  84. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +489 -0
  85. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +123 -0
  86. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +125 -0
  87. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +355 -0
  88. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +355 -0
  89. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +132 -0
  90. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +205 -0
  91. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +176 -0
  92. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +27 -36
  93. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +42 -8
  94. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/params.h +93 -17
  95. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +74 -15
  96. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +97 -11
  97. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +7 -38
  98. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +49 -7
  99. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +16 -17
  100. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +26 -9
  101. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +3 -0
  102. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +18 -19
  103. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +15 -3
  104. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +28 -6
  105. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +311 -246
  106. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +245 -240
  107. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sys.h +64 -5
  108. data/ext/pqcrypto/vendor/mlkem-native/BUILDING.md +5 -2
  109. data/ext/pqcrypto/vendor/mlkem-native/LICENSE +21 -3
  110. data/ext/pqcrypto/vendor/mlkem-native/README.md +4 -6
  111. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +211 -0
  112. data/ext/pqcrypto/vendor/mlkem-native/mlkem/README.md +2 -2
  113. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +25 -34
  114. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +79 -142
  115. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +62 -71
  116. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +77 -39
  117. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +25 -0
  118. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +48 -34
  119. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +25 -5
  120. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +14 -0
  121. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/context.h +51 -0
  122. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +2 -2
  123. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +8 -8
  124. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/auto.h +20 -12
  125. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +5 -3
  126. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +5 -2
  127. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +5 -2
  128. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +10 -7
  129. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +10 -7
  130. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +1 -1
  131. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +3 -2
  132. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +3 -2
  133. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +6 -1
  134. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +3 -2
  135. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/api.h +11 -11
  136. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/mve.h +8 -22
  137. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +8 -5
  138. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_extract_bytes_x4_mve.S → keccak_f1600_x4_state_extract_bytes_mve.S} +14 -14
  139. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/{state_xor_bytes_x4_mve.S → keccak_f1600_x4_state_xor_bytes_mve.S} +12 -12
  140. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +2 -2
  141. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +36 -2
  142. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +22 -0
  143. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +20 -11
  144. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.c +39 -11
  145. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +64 -15
  146. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +44 -2
  147. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +2 -0
  148. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +11 -10
  149. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{intt_aarch64_asm.S → mlkem_intt_aarch64_asm.S} +16 -9
  150. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{ntt_aarch64_asm.S → mlkem_ntt_aarch64_asm.S} +10 -7
  151. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_mulcache_compute_aarch64_asm.S → mlkem_poly_mulcache_compute_aarch64_asm.S} +6 -3
  152. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_reduce_aarch64_asm.S → mlkem_poly_reduce_aarch64_asm.S} +6 -3
  153. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tobytes_aarch64_asm.S → mlkem_poly_tobytes_aarch64_asm.S} +12 -5
  154. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tomont_aarch64_asm.S → mlkem_poly_tomont_aarch64_asm.S} +11 -5
  155. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S} +6 -3
  156. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S} +6 -3
  157. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S} +6 -3
  158. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{rej_uniform_aarch64_asm.S → mlkem_rej_uniform_aarch64_asm.S} +17 -17
  159. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +21 -8
  160. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +1 -1
  161. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +4 -0
  162. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{intt_ppc_asm.S → mlkem_intt_ppc_asm.S} +29 -5
  163. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{ntt_ppc_asm.S → mlkem_ntt_ppc_asm.S} +22 -1
  164. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{poly_tomont_ppc_asm.S → mlkem_poly_tomont_ppc_asm.S} +25 -3
  165. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/{reduce_ppc_asm.S → mlkem_reduce_ppc_asm.S} +22 -1
  166. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +4 -0
  167. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/arith_native_riscv64.h +4 -0
  168. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +6 -2
  169. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +45 -25
  170. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +20 -20
  171. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +14 -3
  172. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +8 -0
  173. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{intt_avx2_asm.S → mlkem_intt_avx2_asm.S} +27 -3
  174. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntt_avx2_asm.S → mlkem_ntt_avx2_asm.S} +23 -1
  175. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttfrombytes_avx2_asm.S → mlkem_nttfrombytes_avx2_asm.S} +27 -3
  176. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntttobytes_avx2_asm.S → mlkem_ntttobytes_avx2_asm.S} +27 -3
  177. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttunpack_avx2_asm.S → mlkem_nttunpack_avx2_asm.S} +17 -1
  178. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d10_avx2_asm.S → mlkem_poly_compress_d10_avx2_asm.S} +34 -3
  179. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d11_avx2_asm.S → mlkem_poly_compress_d11_avx2_asm.S} +33 -2
  180. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d4_avx2_asm.S → mlkem_poly_compress_d4_avx2_asm.S} +34 -3
  181. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d5_avx2_asm.S → mlkem_poly_compress_d5_avx2_asm.S} +33 -2
  182. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d10_avx2_asm.S → mlkem_poly_decompress_d10_avx2_asm.S} +32 -3
  183. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d11_avx2_asm.S → mlkem_poly_decompress_d11_avx2_asm.S} +32 -2
  184. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d4_avx2_asm.S → mlkem_poly_decompress_d4_avx2_asm.S} +32 -3
  185. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d5_avx2_asm.S → mlkem_poly_decompress_d5_avx2_asm.S} +32 -2
  186. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_mulcache_compute_avx2_asm.S → mlkem_poly_mulcache_compute_avx2_asm.S} +29 -1
  187. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S} +35 -1
  188. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S} +35 -1
  189. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S → mlkem_polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S} +35 -1
  190. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{reduce_avx2_asm.S → mlkem_reduce_avx2_asm.S} +17 -1
  191. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{rej_uniform_avx2_asm.S → mlkem_rej_uniform_avx2_asm.S} +40 -7
  192. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{tomont_avx2_asm.S → mlkem_tomont_avx2_asm.S} +20 -3
  193. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +7 -2
  194. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +6 -0
  195. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +25 -4
  196. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +33 -4
  197. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +4 -0
  198. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +4 -0
  199. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +21 -3
  200. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +11 -10
  201. data/lib/pq_crypto/version.rb +1 -1
  202. data/script/vendor_libs.rb +6 -6
  203. metadata +79 -79
  204. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_chknorm_avx2.c +0 -52
  205. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +0 -157
  206. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +0 -157
  207. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +0 -103
  208. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +0 -105
  209. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +0 -94
  210. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +0 -96
  211. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_avx2.c +0 -126
  212. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +0 -157
  213. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +0 -141
@@ -16,10 +16,13 @@
16
16
  */
17
17
 
18
18
  /*yaml
19
- Name: keccak_f1600_x1_v84a_asm
19
+ Name: keccak_f1600_x1_v84a_aarch64_asm
20
20
  Description: AArch64 ARMv8.4-A implementation of Keccak-f[1600] permutation for single state
21
21
  Signature: void mld_keccak_f1600_x1_v84a_aarch64_asm(uint64_t state[25], const uint64_t rc[24])
22
22
  ABI:
23
+ Architecture: aarch64
24
+ CallingConvention: AAPCS64
25
+ Features: [NEON, SHA3]
23
26
  x0:
24
27
  type: buffer
25
28
  size_bytes: 200
@@ -30,7 +33,7 @@
30
33
  type: buffer
31
34
  size_bytes: 192
32
35
  permissions: read-only
33
- c_parameter: const uint64_t rc[24]
36
+ c_parameter: uint64_t const *rc
34
37
  description: Round constants (24 x uint64_t)
35
38
  Stack:
36
39
  bytes: 64
@@ -92,7 +95,7 @@ MLD_ASM_FN_SYMBOL(keccak_f1600_x1_v84a_aarch64_asm)
92
95
  ldr d24, [x0, #0xc0]
93
96
  mov x2, #0x18 // =24
94
97
 
95
- Lkeccak_f1600_x1_v84a_loop:
98
+ Lmld_keccak_f1600_x1_v84a_loop:
96
99
  eor3 v30.16b, v0.16b, v5.16b, v10.16b
97
100
  eor3 v29.16b, v1.16b, v6.16b, v11.16b
98
101
  eor3 v28.16b, v2.16b, v7.16b, v12.16b
@@ -161,7 +164,7 @@ Lkeccak_f1600_x1_v84a_loop:
161
164
  bcax v4.16b, v4.16b, v27.16b, v30.16b
162
165
  eor v0.16b, v0.16b, v31.16b
163
166
  sub x2, x2, #0x1
164
- cbnz x2, Lkeccak_f1600_x1_v84a_loop
167
+ cbnz x2, Lmld_keccak_f1600_x1_v84a_loop
165
168
  stp d0, d1, [x0]
166
169
  stp d2, d3, [x0, #0x10]
167
170
  stp d4, d5, [x0, #0x20]
@@ -16,10 +16,13 @@
16
16
  */
17
17
 
18
18
  /*yaml
19
- Name: keccak_f1600_x2_v84a_asm
19
+ Name: keccak_f1600_x2_v84a_aarch64_asm
20
20
  Description: AArch64 ARMv8.4-A implementation of Keccak-f[1600] permutation for two sequential states
21
21
  Signature: void mld_keccak_f1600_x2_v84a_aarch64_asm(uint64_t state[50], const uint64_t rc[24])
22
22
  ABI:
23
+ Architecture: aarch64
24
+ CallingConvention: AAPCS64
25
+ Features: [NEON, SHA3]
23
26
  x0:
24
27
  type: buffer
25
28
  size_bytes: 400
@@ -30,7 +33,7 @@
30
33
  type: buffer
31
34
  size_bytes: 192
32
35
  permissions: read-only
33
- c_parameter: const uint64_t rc[24]
36
+ c_parameter: uint64_t const *rc
34
37
  description: Round constants (24 x uint64_t)
35
38
  Stack:
36
39
  bytes: 64
@@ -119,7 +122,7 @@ MLD_ASM_FN_SYMBOL(keccak_f1600_x2_v84a_aarch64_asm)
119
122
  trn1 v24.2d, v25.2d, v27.2d
120
123
  mov x2, #0x18 // =24
121
124
 
122
- Lkeccak_f1600_x2_v84a_loop:
125
+ Lmld_keccak_f1600_x2_v84a_loop:
123
126
  eor3 v30.16b, v0.16b, v5.16b, v10.16b
124
127
  eor3 v29.16b, v1.16b, v6.16b, v11.16b
125
128
  eor3 v28.16b, v2.16b, v7.16b, v12.16b
@@ -188,7 +191,7 @@ Lkeccak_f1600_x2_v84a_loop:
188
191
  bcax v4.16b, v4.16b, v27.16b, v30.16b
189
192
  eor v0.16b, v0.16b, v31.16b
190
193
  sub x2, x2, #0x1
191
- cbnz x2, Lkeccak_f1600_x2_v84a_loop
194
+ cbnz x2, Lmld_keccak_f1600_x2_v84a_loop
192
195
  sub x0, x0, #0xc0
193
196
  add x2, x0, #0xc8
194
197
  trn1 v25.2d, v0.2d, v1.2d
@@ -10,10 +10,13 @@
10
10
  // Author: Matthias Kannwischer <matthias@kannwischer.eu>
11
11
 
12
12
  /*yaml
13
- Name: keccak_f1600_x4_v8a_scalar_hybrid_asm
13
+ Name: keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm
14
14
  Description: AArch64 hybrid scalar/vector implementation of Keccak-f[1600] permutation for four sequential states
15
15
  Signature: void mld_keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm(uint64_t state[100], const uint64_t rc[24])
16
16
  ABI:
17
+ Architecture: aarch64
18
+ CallingConvention: AAPCS64
19
+ Features: [NEON]
17
20
  x0:
18
21
  type: buffer
19
22
  size_bytes: 800
@@ -24,7 +27,7 @@
24
27
  type: buffer
25
28
  size_bytes: 192
26
29
  permissions: read-only
27
- c_parameter: const uint64_t rc[24]
30
+ c_parameter: uint64_t const *rc
28
31
  description: Round constants (24 x uint64_t)
29
32
  Stack:
30
33
  bytes: 224
@@ -141,7 +144,7 @@ MLD_ASM_FN_SYMBOL(keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm)
141
144
  ldr x25, [x0, #0xc0]
142
145
  sub x0, x0, #0x190
143
146
 
144
- Lkeccak_f1600_x4_v8a_scalar_hybrid_initial:
147
+ Lmld_keccak_f1600_x4_v8a_scalar_hybrid_initial:
145
148
  eor x30, x24, x25
146
149
  eor x27, x9, x10
147
150
  eor v30.16b, v0.16b, v5.16b
@@ -524,7 +527,7 @@ Lkeccak_f1600_x4_v8a_scalar_hybrid_initial:
524
527
  str x30, [sp, #0x10]
525
528
  eor v0.16b, v0.16b, v28.16b
526
529
 
527
- Lkeccak_f1600_x4_v8a_scalar_hybrid_loop:
530
+ Lmld_keccak_f1600_x4_v8a_scalar_hybrid_loop:
528
531
  eor x0, x15, x11, ror #52
529
532
  eor x0, x0, x13, ror #48
530
533
  eor v30.16b, v0.16b, v5.16b
@@ -912,8 +915,8 @@ Lkeccak_f1600_x4_v8a_scalar_hybrid_loop:
912
915
  str x30, [sp, #0x10]
913
916
  eor v0.16b, v0.16b, v28.16b
914
917
 
915
- Lkeccak_f1600_x4_v8a_scalar_hybrid_loop_end:
916
- b.le Lkeccak_f1600_x4_v8a_scalar_hybrid_loop
918
+ Lmld_keccak_f1600_x4_v8a_scalar_hybrid_loop_end:
919
+ b.le Lmld_keccak_f1600_x4_v8a_scalar_hybrid_loop
917
920
  ror x2, x2, #0x3d
918
921
  ror x3, x3, #0x27
919
922
  ror x4, x4, #0x36
@@ -939,7 +942,7 @@ Lkeccak_f1600_x4_v8a_scalar_hybrid_loop_end:
939
942
  ror x25, x25, #0x9
940
943
  ldr x30, [sp, #0x20]
941
944
  cmp x30, #0x1
942
- b.eq Lkeccak_f1600_x4_v8a_scalar_hybrid_done
945
+ b.eq Lmld_keccak_f1600_x4_v8a_scalar_hybrid_done
943
946
  mov x30, #0x1 // =1
944
947
  str x30, [sp, #0x20]
945
948
  ldr x0, [sp]
@@ -973,9 +976,9 @@ Lkeccak_f1600_x4_v8a_scalar_hybrid_loop_end:
973
976
  ldp x15, x20, [x0, #0xb0]
974
977
  ldr x25, [x0, #0xc0]
975
978
  sub x0, x0, #0x258
976
- b Lkeccak_f1600_x4_v8a_scalar_hybrid_initial
979
+ b Lmld_keccak_f1600_x4_v8a_scalar_hybrid_initial
977
980
 
978
- Lkeccak_f1600_x4_v8a_scalar_hybrid_done:
981
+ Lmld_keccak_f1600_x4_v8a_scalar_hybrid_done:
979
982
  ldr x0, [sp]
980
983
  add x0, x0, #0x258
981
984
  stp x1, x6, [x0]
@@ -10,10 +10,13 @@
10
10
  // Author: Matthias Kannwischer <matthias@kannwischer.eu>
11
11
 
12
12
  /*yaml
13
- Name: keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm
13
+ Name: keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm
14
14
  Description: AArch64 hybrid scalar/vector implementation of Keccak-f[1600] permutation for four sequential states with ARMv8.4-A optimizations
15
15
  Signature: void mld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm(uint64_t state[100], const uint64_t rc[24])
16
16
  ABI:
17
+ Architecture: aarch64
18
+ CallingConvention: AAPCS64
19
+ Features: [NEON, SHA3]
17
20
  x0:
18
21
  type: buffer
19
22
  size_bytes: 800
@@ -24,7 +27,7 @@
24
27
  type: buffer
25
28
  size_bytes: 192
26
29
  permissions: read-only
27
- c_parameter: const uint64_t rc[24]
30
+ c_parameter: uint64_t const *rc
28
31
  description: Round constants (24 x uint64_t)
29
32
  Stack:
30
33
  bytes: 224
@@ -143,7 +146,7 @@ MLD_ASM_FN_SYMBOL(keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm)
143
146
  ldr x25, [x0, #0xc0]
144
147
  sub x0, x0, #0x190
145
148
 
146
- Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_initial:
149
+ Lmld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_initial:
147
150
  eor x30, x24, x25
148
151
  eor x27, x9, x10
149
152
  eor3 v30.16b, v0.16b, v5.16b, v10.16b
@@ -479,7 +482,7 @@ Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_initial:
479
482
  str x30, [sp, #0x10]
480
483
  eor v0.16b, v0.16b, v28.16b
481
484
 
482
- Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_loop:
485
+ Lmld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_loop:
483
486
  eor x0, x15, x11, ror #52
484
487
  eor x0, x0, x13, ror #48
485
488
  eor3 v30.16b, v0.16b, v5.16b, v10.16b
@@ -820,8 +823,8 @@ Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_loop:
820
823
  str x30, [sp, #0x10]
821
824
  eor v0.16b, v0.16b, v28.16b
822
825
 
823
- Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_loop_end:
824
- b.le Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_loop
826
+ Lmld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_loop_end:
827
+ b.le Lmld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_loop
825
828
  ror x2, x2, #0x3d
826
829
  ror x3, x3, #0x27
827
830
  ror x4, x4, #0x36
@@ -847,7 +850,7 @@ Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_loop_end:
847
850
  ror x25, x25, #0x9
848
851
  ldr x30, [sp, #0x20]
849
852
  cmp x30, #0x1
850
- b.eq Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_done
853
+ b.eq Lmld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_done
851
854
  mov x30, #0x1 // =1
852
855
  str x30, [sp, #0x20]
853
856
  ldr x0, [sp]
@@ -881,9 +884,9 @@ Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_loop_end:
881
884
  ldp x15, x20, [x0, #0xb0]
882
885
  ldr x25, [x0, #0xc0]
883
886
  sub x0, x0, #0x258
884
- b Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_initial
887
+ b Lmld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_initial
885
888
 
886
- Lkeccak_f1600_x4_v8a_v84a_scalar_hybrid_done:
889
+ Lmld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_done:
887
890
  ldr x0, [sp]
888
891
  add x0, x0, #0x258
889
892
  stp x1, x6, [x0]
@@ -8,7 +8,7 @@
8
8
  #define MLD_FIPS202_NATIVE_AARCH64_X1_SCALAR_H
9
9
 
10
10
  /* Part of backend API */
11
- #define MLD_USE_FIPS202_X1_NATIVE
11
+ #define MLD_USE_NATIVE_FIPS202_X1
12
12
  /* Guard for assembly file */
13
13
  #define MLD_FIPS202_AARCH64_NEED_X1_SCALAR
14
14
 
@@ -12,7 +12,7 @@
12
12
  #endif
13
13
 
14
14
  /* Part of backend API */
15
- #define MLD_USE_FIPS202_X1_NATIVE
15
+ #define MLD_USE_NATIVE_FIPS202_X1
16
16
  /* Guard for assembly file */
17
17
  #define MLD_FIPS202_AARCH64_NEED_X1_V84A
18
18
 
@@ -22,7 +22,8 @@
22
22
  MLD_MUST_CHECK_RETURN_VALUE
23
23
  static MLD_INLINE int mld_keccak_f1600_x1_native(uint64_t *state)
24
24
  {
25
- if (!mld_sys_check_capability(MLD_SYS_CAP_SHA3))
25
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON) ||
26
+ !mld_sys_check_capability(MLD_SYS_CAP_AARCH64_SHA3))
26
27
  {
27
28
  return MLD_NATIVE_FUNC_FALLBACK;
28
29
  }
@@ -12,7 +12,7 @@
12
12
  #endif
13
13
 
14
14
  /* Part of backend API */
15
- #define MLD_USE_FIPS202_X4_NATIVE
15
+ #define MLD_USE_NATIVE_FIPS202_X4
16
16
  /* Guard for assembly file */
17
17
  #define MLD_FIPS202_AARCH64_NEED_X2_V84A
18
18
 
@@ -23,7 +23,8 @@
23
23
  MLD_MUST_CHECK_RETURN_VALUE
24
24
  static MLD_INLINE int mld_keccak_f1600_x4_native(uint64_t *state)
25
25
  {
26
- if (!mld_sys_check_capability(MLD_SYS_CAP_SHA3))
26
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON) ||
27
+ !mld_sys_check_capability(MLD_SYS_CAP_AARCH64_SHA3))
27
28
  {
28
29
  return MLD_NATIVE_FUNC_FALLBACK;
29
30
  }
@@ -8,7 +8,7 @@
8
8
  #define MLD_FIPS202_NATIVE_AARCH64_X4_V8A_SCALAR_H
9
9
 
10
10
  /* Part of backend API */
11
- #define MLD_USE_FIPS202_X4_NATIVE
11
+ #define MLD_USE_NATIVE_FIPS202_X4
12
12
  /* Guard for assembly file */
13
13
  #define MLD_FIPS202_AARCH64_NEED_X4_V8A_SCALAR_HYBRID
14
14
 
@@ -18,6 +18,11 @@
18
18
  MLD_MUST_CHECK_RETURN_VALUE
19
19
  static MLD_INLINE int mld_keccak_f1600_x4_native(uint64_t *state)
20
20
  {
21
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON))
22
+ {
23
+ return MLD_NATIVE_FUNC_FALLBACK;
24
+ }
25
+
21
26
  mld_keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm(
22
27
  state, mld_keccakf1600_round_constants);
23
28
  return MLD_NATIVE_FUNC_SUCCESS;
@@ -12,7 +12,7 @@
12
12
  #endif
13
13
 
14
14
  /* Part of backend API */
15
- #define MLD_USE_FIPS202_X4_NATIVE
15
+ #define MLD_USE_NATIVE_FIPS202_X4
16
16
  /* Guard for assembly file */
17
17
  #define MLD_FIPS202_AARCH64_NEED_X4_V8A_V84A_SCALAR_HYBRID
18
18
 
@@ -22,7 +22,8 @@
22
22
  MLD_MUST_CHECK_RETURN_VALUE
23
23
  static MLD_INLINE int mld_keccak_f1600_x4_native(uint64_t *state)
24
24
  {
25
- if (!mld_sys_check_capability(MLD_SYS_CAP_SHA3))
25
+ if (!mld_sys_check_capability(MLD_SYS_CAP_AARCH64_NEON) ||
26
+ !mld_sys_check_capability(MLD_SYS_CAP_AARCH64_SHA3))
26
27
  {
27
28
  return MLD_NATIVE_FUNC_FALLBACK;
28
29
  }
@@ -39,13 +39,13 @@
39
39
  * A _backend_ is a specific implementation of parts of this interface.
40
40
  *
41
41
  * You can replace 1-fold or 4-fold batched Keccak-F1600.
42
- * To enable, set MLD_USE_FIPS202_X1_NATIVE or MLD_USE_FIPS202_X4_NATIVE
42
+ * To enable, set MLD_USE_NATIVE_FIPS202_X1 or MLD_USE_NATIVE_FIPS202_X4
43
43
  * in your backend, and define the inline wrappers mld_keccak_f1600_x1_native()
44
44
  * and/or mld_keccak_f1600_x4_native(), respectively, to forward to your
45
45
  * implementation.
46
46
  */
47
47
 
48
- #if defined(MLD_USE_FIPS202_X1_NATIVE)
48
+ #if defined(MLD_USE_NATIVE_FIPS202_X1)
49
49
  MLD_MUST_CHECK_RETURN_VALUE
50
50
  static MLD_INLINE int mld_keccak_f1600_x1_native(uint64_t *state)
51
51
  __contract__(
@@ -54,8 +54,8 @@ __contract__(
54
54
  ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || return_value == MLD_NATIVE_FUNC_SUCCESS)
55
55
  ensures((return_value == MLD_NATIVE_FUNC_FALLBACK) ==> array_unchanged_u64(state, 25 * 1))
56
56
  );
57
- #endif /* MLD_USE_FIPS202_X1_NATIVE */
58
- #if defined(MLD_USE_FIPS202_X4_NATIVE)
57
+ #endif /* MLD_USE_NATIVE_FIPS202_X1 */
58
+ #if defined(MLD_USE_NATIVE_FIPS202_X4)
59
59
  MLD_MUST_CHECK_RETURN_VALUE
60
60
  static MLD_INLINE int mld_keccak_f1600_x4_native(uint64_t *state)
61
61
  __contract__(
@@ -64,7 +64,7 @@ __contract__(
64
64
  ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || return_value == MLD_NATIVE_FUNC_SUCCESS)
65
65
  ensures((return_value == MLD_NATIVE_FUNC_FALLBACK) ==> array_unchanged_u64(state, 25 * 4))
66
66
  );
67
- #endif /* MLD_USE_FIPS202_X4_NATIVE */
67
+ #endif /* MLD_USE_NATIVE_FIPS202_X4 */
68
68
 
69
69
  /*
70
70
  * Native x4 XOR bytes and extract bytes interface.
@@ -78,12 +78,12 @@ __contract__(
78
78
  * NOTE: We assume that the custom representation of the zero state is the
79
79
  * all-zero state.
80
80
  *
81
- * MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE: Backend provides native XOR bytes
82
- * MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE: Backend provides native extract
81
+ * MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES: Backend provides native XOR bytes
82
+ * MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES: Backend provides native extract
83
83
  * bytes
84
84
  */
85
85
 
86
- #if defined(MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE)
86
+ #if defined(MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES)
87
87
  MLD_MUST_CHECK_RETURN_VALUE
88
88
  static MLD_INLINE int mld_keccakf1600_xor_bytes_x4_native(
89
89
  uint64_t *state, const unsigned char *data0, const unsigned char *data1,
@@ -103,9 +103,9 @@ __contract__(
103
103
  assigns(memory_slice(state, sizeof(uint64_t) * 25 * 4))
104
104
  ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || return_value == MLD_NATIVE_FUNC_SUCCESS)
105
105
  ensures((return_value == MLD_NATIVE_FUNC_FALLBACK) ==> array_unchanged_u64(state, 25 * 4)));
106
- #endif /* MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE */
106
+ #endif /* MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES */
107
107
 
108
- #if defined(MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE)
108
+ #if defined(MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES)
109
109
  MLD_MUST_CHECK_RETURN_VALUE
110
110
  static MLD_INLINE int mld_keccakf1600_extract_bytes_x4_native(
111
111
  uint64_t *state, unsigned char *data0, unsigned char *data1,
@@ -124,6 +124,6 @@ __contract__(
124
124
  assigns(memory_slice(data2, length))
125
125
  assigns(memory_slice(data3, length))
126
126
  ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || return_value == MLD_NATIVE_FUNC_SUCCESS));
127
- #endif /* MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE */
127
+ #endif /* MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES */
128
128
 
129
129
  #endif /* !MLD_FIPS202_NATIVE_API_H */
@@ -10,14 +10,15 @@
10
10
  #define MLD_FIPS202_NATIVE_ARMV81M
11
11
 
12
12
  /* Part of backend API */
13
- #define MLD_USE_FIPS202_X4_NATIVE
14
- #define MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE
15
- #define MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE
13
+ #define MLD_USE_NATIVE_FIPS202_X4
14
+ #define MLD_USE_NATIVE_FIPS202_X4_XOR_BYTES
15
+ #define MLD_USE_NATIVE_FIPS202_X4_EXTRACT_BYTES
16
16
  /* Guard for assembly file */
17
17
  #define MLD_FIPS202_ARMV81M_NEED_X4
18
18
 
19
19
  #if !defined(__ASSEMBLER__)
20
20
  #include "../api.h"
21
+ #include "src/fips202_native_armv81m.h"
21
22
 
22
23
  /*
23
24
  * Native x4 permutation
@@ -25,6 +26,7 @@
25
26
  */
26
27
  #define mld_keccak_f1600_x4_native_impl \
27
28
  MLD_NAMESPACE(keccak_f1600_x4_native_impl)
29
+ MLD_INTERNAL_API
28
30
  int mld_keccak_f1600_x4_native_impl(uint64_t *state);
29
31
 
30
32
  MLD_MUST_CHECK_RETURN_VALUE
@@ -36,42 +38,27 @@ static MLD_INLINE int mld_keccak_f1600_x4_native(uint64_t *state)
36
38
  /*
37
39
  * Native x4 XOR bytes (with on-the-fly bit interleaving)
38
40
  */
39
- #define mld_keccak_f1600_x4_state_xor_bytes \
40
- MLD_NAMESPACE(keccak_f1600_x4_state_xor_bytes_asm)
41
- void mld_keccak_f1600_x4_state_xor_bytes(void *state, const uint8_t *data0,
42
- const uint8_t *data1,
43
- const uint8_t *data2,
44
- const uint8_t *data3, unsigned offset,
45
- unsigned length);
46
-
47
41
  MLD_MUST_CHECK_RETURN_VALUE
48
42
  static MLD_INLINE int mld_keccakf1600_xor_bytes_x4_native(
49
43
  uint64_t *state, const uint8_t *data0, const uint8_t *data1,
50
44
  const uint8_t *data2, const uint8_t *data3, unsigned offset,
51
45
  unsigned length)
52
46
  {
53
- mld_keccak_f1600_x4_state_xor_bytes(state, data0, data1, data2, data3, offset,
54
- length);
47
+ mld_keccak_f1600_x4_state_xor_bytes_asm(state, data0, data1, data2, data3,
48
+ offset, length);
55
49
  return MLD_NATIVE_FUNC_SUCCESS;
56
50
  }
57
51
 
58
52
  /*
59
53
  * Native x4 extract bytes (with on-the-fly bit de-interleaving)
60
54
  */
61
- #define mld_keccak_f1600_x4_state_extract_bytes \
62
- MLD_NAMESPACE(keccak_f1600_x4_state_extract_bytes_asm)
63
- void mld_keccak_f1600_x4_state_extract_bytes(void *state, uint8_t *data0,
64
- uint8_t *data1, uint8_t *data2,
65
- uint8_t *data3, unsigned offset,
66
- unsigned length);
67
-
68
55
  MLD_MUST_CHECK_RETURN_VALUE
69
56
  static MLD_INLINE int mld_keccakf1600_extract_bytes_x4_native(
70
57
  uint64_t *state, uint8_t *data0, uint8_t *data1, uint8_t *data2,
71
58
  uint8_t *data3, unsigned offset, unsigned length)
72
59
  {
73
- mld_keccak_f1600_x4_state_extract_bytes(state, data0, data1, data2, data3,
74
- offset, length);
60
+ mld_keccak_f1600_x4_state_extract_bytes_asm(state, data0, data1, data2, data3,
61
+ offset, length);
75
62
  return MLD_NATIVE_FUNC_SUCCESS;
76
63
  }
77
64
 
@@ -10,6 +10,9 @@
10
10
  Description: Armv8.1-M MVE implementation of batched (x4) Keccak-f[1600] permutation using bit-interleaved state
11
11
  Signature: void mld_keccak_f1600_x4_mve_asm(void *state, void *tmpstate, const uint32_t *rc)
12
12
  ABI:
13
+ Architecture: armv81m
14
+ CallingConvention: AAPCS32
15
+ Features: [MVE]
13
16
  r0:
14
17
  type: buffer
15
18
  size_bytes: 800
@@ -112,9 +115,9 @@ MLD_ASM_FN_SYMBOL(keccak_f1600_x4_mve_asm)
112
115
  vldrw.u32 q0, [r3]
113
116
  vldrw.u32 q1, [r2]
114
117
  vldrw.u32 q2, [r2, #32]
115
- wls lr, lr, Lkeccak_f1600_x4_mve_asm_roundend @ imm = #0x8c0
118
+ wls lr, lr, Lmld_keccak_f1600_x4_mve_asm_roundend @ imm = #0x8c0
116
119
 
117
- Lkeccak_f1600_x4_mve_asm_roundstart:
120
+ Lmld_keccak_f1600_x4_mve_asm_roundstart:
118
121
  vldrw.u32 q6, [r2, #112]
119
122
  veor q7, q6, q2
120
123
  vldrw.u32 q2, [r2, #80]
@@ -675,10 +678,10 @@ Lkeccak_f1600_x4_mve_asm_roundstart:
675
678
  veor q0, q4, q6
676
679
  vstrw.32 q0, [r5]
677
680
 
678
- Lkeccak_f1600_x4_mve_asm_roundend_pre:
679
- le lr, Lkeccak_f1600_x4_mve_asm_roundstart @ imm = #-0x8c0
681
+ Lmld_keccak_f1600_x4_mve_asm_roundend_pre:
682
+ le lr, Lmld_keccak_f1600_x4_mve_asm_roundstart @ imm = #-0x8c0
680
683
 
681
- Lkeccak_f1600_x4_mve_asm_roundend:
684
+ Lmld_keccak_f1600_x4_mve_asm_roundend:
682
685
  add sp, #0x80
683
686
  .cfi_adjust_cfa_offset -0x80
684
687
  vpop {d8, d9, d10, d11, d12, d13, d14, d15}
@@ -19,6 +19,7 @@
19
19
  */
20
20
  #define mld_keccak_f1600_x4_native_impl \
21
21
  MLD_NAMESPACE(keccak_f1600_x4_native_impl)
22
+ MLD_INTERNAL_API
22
23
  int mld_keccak_f1600_x4_native_impl(uint64_t *state)
23
24
  {
24
25
  MLD_ALIGN uint64_t state_tmp[100];
@@ -9,7 +9,7 @@
9
9
  // Overview
10
10
  // ---------------------------------------------------------------------------
11
11
  // MVE/Helium implementation of KeccakF1600x4_StateExtractBytes
12
- // (inverse of state_xor_bytes_x4_mve.S).
12
+ // (inverse of keccak_f1600_x4_state_xor_bytes_mve.S).
13
13
  //
14
14
  // void KeccakF1600x4_StateExtractBytes(state, d0, d1, d2, d3, offset, length)
15
15
  //
@@ -62,7 +62,7 @@
62
62
 
63
63
  /*
64
64
  * WARNING: This file is auto-derived from the mldsa-native source file
65
- * dev/fips202/armv81m/src/state_extract_bytes_x4_mve.S using scripts/simpasm. Do not modify it directly.
65
+ * dev/fips202/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S using scripts/simpasm. Do not modify it directly.
66
66
  */
67
67
 
68
68
  .thumb
@@ -99,13 +99,13 @@ MLD_ASM_FN_SYMBOL(keccak_f1600_x4_state_extract_bytes_asm)
99
99
  ldr.w r10, [sp, #0x6c]
100
100
  ldr r6, [sp, #0x70]
101
101
  cmp r6, #0x0
102
- beq.w Lkeccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0x2ea
102
+ beq.w Lmld_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0x2ea
103
103
  and r5, r10, #0x7
104
104
  bic r9, r10, #0x7
105
105
  add.w r8, r0, r9, lsl #1
106
106
  add.w r7, r8, #0x190
107
107
  cmp r5, #0x0
108
- beq.w Lkeccak_f1600_x4_state_extract_bytes_asm_pre_main @ imm = #0x112
108
+ beq.w Lmld_keccak_f1600_x4_state_extract_bytes_asm_pre_main @ imm = #0x112
109
109
  vldrw.u32 q0, [r8], #16
110
110
  vldrw.u32 q1, [r7], #16
111
111
  vrev32.16 q2, q0
@@ -175,22 +175,22 @@ MLD_ASM_FN_SYMBOL(keccak_f1600_x4_state_extract_bytes_asm)
175
175
  vstrbt.8 q3, [r4], #4
176
176
  subs.w r6, r6, lr
177
177
  cmp r6, #0x0
178
- beq.w Lkeccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0x1cc
178
+ beq.w Lmld_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0x1cc
179
179
  vmov q7[2], q7[0], r1, r3
180
180
  vmov q7[3], q7[1], r2, r4
181
- b Lkeccak_f1600_x4_state_extract_bytes_asm_main_body @ imm = #0xe
181
+ b Lmld_keccak_f1600_x4_state_extract_bytes_asm_main_body @ imm = #0xe
182
182
 
183
- Lkeccak_f1600_x4_state_extract_bytes_asm_pre_main:
183
+ Lmld_keccak_f1600_x4_state_extract_bytes_asm_pre_main:
184
184
  vmov q7[2], q7[0], r1, r3
185
185
  vmov q7[3], q7[1], r2, r4
186
186
  mov.w r12, #0x4
187
187
  vsub.i32 q7, q7, r12
188
188
 
189
- Lkeccak_f1600_x4_state_extract_bytes_asm_main_body:
189
+ Lmld_keccak_f1600_x4_state_extract_bytes_asm_main_body:
190
190
  lsr.w lr, r6, #0x3
191
- wls lr, lr, Lkeccak_f1600_x4_state_extract_bytes_asm_main_loop_end @ imm = #0xb4
191
+ wls lr, lr, Lmld_keccak_f1600_x4_state_extract_bytes_asm_main_loop_end @ imm = #0xb4
192
192
 
193
- Lkeccak_f1600_x4_state_extract_bytes_asm_main_loop_start:
193
+ Lmld_keccak_f1600_x4_state_extract_bytes_asm_main_loop_start:
194
194
  vldrw.u32 q0, [r8], #16
195
195
  vldrw.u32 q1, [r7], #16
196
196
  vrev32.16 q2, q0
@@ -235,11 +235,11 @@ Lkeccak_f1600_x4_state_extract_bytes_asm_main_loop_start:
235
235
  vorr q1, q1, q3
236
236
  vstrw.32 q0, [q7, #4]!
237
237
  vstrw.32 q1, [q7, #4]!
238
- le lr, Lkeccak_f1600_x4_state_extract_bytes_asm_main_loop_start @ imm = #-0xb4
238
+ le lr, Lmld_keccak_f1600_x4_state_extract_bytes_asm_main_loop_start @ imm = #-0xb4
239
239
 
240
- Lkeccak_f1600_x4_state_extract_bytes_asm_main_loop_end:
240
+ Lmld_keccak_f1600_x4_state_extract_bytes_asm_main_loop_end:
241
241
  ands r6, r6, #0x7
242
- beq Lkeccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0xee
242
+ beq Lmld_keccak_f1600_x4_state_extract_bytes_asm_exit @ imm = #0xee
243
243
  mov.w r12, #0x4
244
244
  vadd.i32 q7, q7, r12
245
245
  vmov r1, r3, q7[2], q7[0]
@@ -301,7 +301,7 @@ Lkeccak_f1600_x4_state_extract_bytes_asm_main_loop_end:
301
301
  vstrbt.8 q2, [r3], #4
302
302
  vstrbt.8 q3, [r4], #4
303
303
 
304
- Lkeccak_f1600_x4_state_extract_bytes_asm_exit:
304
+ Lmld_keccak_f1600_x4_state_extract_bytes_asm_exit:
305
305
  vpop {d8, d9, d10, d11, d12, d13, d14, d15}
306
306
  .cfi_restore d8
307
307
  .cfi_restore d9
@@ -61,7 +61,7 @@
61
61
 
62
62
  /*
63
63
  * WARNING: This file is auto-derived from the mldsa-native source file
64
- * dev/fips202/armv81m/src/state_xor_bytes_x4_mve.S using scripts/simpasm. Do not modify it directly.
64
+ * dev/fips202/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S using scripts/simpasm. Do not modify it directly.
65
65
  */
66
66
 
67
67
  .thumb
@@ -98,13 +98,13 @@ MLD_ASM_FN_SYMBOL(keccak_f1600_x4_state_xor_bytes_asm)
98
98
  ldr.w r10, [sp, #0x6c]
99
99
  ldr r6, [sp, #0x70]
100
100
  cmp r6, #0x0
101
- beq.w Lkeccak_f1600_x4_state_xor_bytes_asm_exit @ imm = #0x346
101
+ beq.w Lmld_keccak_f1600_x4_state_xor_bytes_asm_exit @ imm = #0x346
102
102
  and r5, r10, #0x7
103
103
  bic r9, r10, #0x7
104
104
  add.w r8, r0, r9, lsl #1
105
105
  add.w r7, r8, #0x190
106
106
  cmp r5, #0x0
107
- beq.w Lkeccak_f1600_x4_state_xor_bytes_asm_pre_main @ imm = #0x12c
107
+ beq.w Lmld_keccak_f1600_x4_state_xor_bytes_asm_pre_main @ imm = #0x12c
108
108
  subs r1, r1, r5
109
109
  subs r2, r2, r5
110
110
  subs r3, r3, r5
@@ -183,19 +183,19 @@ MLD_ASM_FN_SYMBOL(keccak_f1600_x4_state_xor_bytes_asm)
183
183
  vstrw.32 q5, [r7], #16
184
184
  vmov q7[2], q7[0], r1, r3
185
185
  vmov q7[3], q7[1], r2, r4
186
- b Lkeccak_f1600_x4_state_xor_bytes_asm_main_body @ imm = #0xe
186
+ b Lmld_keccak_f1600_x4_state_xor_bytes_asm_main_body @ imm = #0xe
187
187
 
188
- Lkeccak_f1600_x4_state_xor_bytes_asm_pre_main:
188
+ Lmld_keccak_f1600_x4_state_xor_bytes_asm_pre_main:
189
189
  vmov q7[2], q7[0], r1, r3
190
190
  vmov q7[3], q7[1], r2, r4
191
191
  mov.w r0, #0x4
192
192
  vsub.i32 q7, q7, r0
193
193
 
194
- Lkeccak_f1600_x4_state_xor_bytes_asm_main_body:
194
+ Lmld_keccak_f1600_x4_state_xor_bytes_asm_main_body:
195
195
  lsr.w lr, r6, #0x3
196
- wls lr, lr, Lkeccak_f1600_x4_state_xor_bytes_asm_main_loop_end @ imm = #0xd4
196
+ wls lr, lr, Lmld_keccak_f1600_x4_state_xor_bytes_asm_main_loop_end @ imm = #0xd4
197
197
 
198
- Lkeccak_f1600_x4_state_xor_bytes_asm_main_loop_start:
198
+ Lmld_keccak_f1600_x4_state_xor_bytes_asm_main_loop_start:
199
199
  vldrw.u32 q0, [q7, #4]!
200
200
  vldrw.u32 q1, [q7, #4]!
201
201
  vmov q2, q0
@@ -248,11 +248,11 @@ Lkeccak_f1600_x4_state_xor_bytes_asm_main_loop_start:
248
248
  veor q5, q5, q1
249
249
  vstrw.32 q4, [r8], #16
250
250
  vstrw.32 q5, [r7], #16
251
- le lr, Lkeccak_f1600_x4_state_xor_bytes_asm_main_loop_start @ imm = #-0xd4
251
+ le lr, Lmld_keccak_f1600_x4_state_xor_bytes_asm_main_loop_start @ imm = #-0xd4
252
252
 
253
- Lkeccak_f1600_x4_state_xor_bytes_asm_main_loop_end:
253
+ Lmld_keccak_f1600_x4_state_xor_bytes_asm_main_loop_end:
254
254
  ands r6, r6, #0x7
255
- beq.w Lkeccak_f1600_x4_state_xor_bytes_asm_exit @ imm = #0x110
255
+ beq.w Lmld_keccak_f1600_x4_state_xor_bytes_asm_exit @ imm = #0x110
256
256
  mov.w r0, #0x4
257
257
  vadd.i32 q7, q7, r0
258
258
  vmov r1, r3, q7[2], q7[0]
@@ -322,7 +322,7 @@ Lkeccak_f1600_x4_state_xor_bytes_asm_main_loop_end:
322
322
  vstrw.32 q4, [r8], #16
323
323
  vstrw.32 q5, [r7], #16
324
324
 
325
- Lkeccak_f1600_x4_state_xor_bytes_asm_exit:
325
+ Lmld_keccak_f1600_x4_state_xor_bytes_asm_exit:
326
326
  vpop {d8, d9, d10, d11, d12, d13, d14, d15}
327
327
  .cfi_restore d8
328
328
  .cfi_restore d9