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
@@ -4,6 +4,34 @@
4
4
  * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
5
  */
6
6
 
7
+ /*yaml
8
+ Name: polyz_unpack_17_aarch64_asm
9
+ Description: AArch64 unpacking of 17-bit packed coefficients
10
+ Signature: void mld_polyz_unpack_17_aarch64_asm(int32_t r[256], const uint8_t buf[576], const uint8_t indices[64])
11
+ ABI:
12
+ Architecture: aarch64
13
+ CallingConvention: AAPCS64
14
+ Features: [NEON]
15
+ x0:
16
+ type: buffer
17
+ size_bytes: 1024
18
+ permissions: write-only
19
+ c_parameter: int32_t r[256]
20
+ description: Output polynomial (256 x int32_t)
21
+ x1:
22
+ type: buffer
23
+ size_bytes: 576
24
+ permissions: read-only
25
+ c_parameter: const uint8_t buf[576]
26
+ description: Packed input bytes
27
+ x2:
28
+ type: buffer
29
+ size_bytes: 64
30
+ permissions: read-only
31
+ c_parameter: const uint8_t indices[64]
32
+ description: Permutation index table (64 x uint8_t)
33
+ */
34
+
7
35
  #include "../../../common.h"
8
36
  #if defined(MLD_ARITH_BACKEND_AARCH64) && \
9
37
  (!defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_NO_VERIFY_API)) && \
@@ -12,7 +40,7 @@
12
40
 
13
41
  /*
14
42
  * WARNING: This file is auto-derived from the mldsa-native source file
15
- * dev/aarch64_opt/src/polyz_unpack_17_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
43
+ * dev/aarch64_opt/src/mldsa_polyz_unpack_17_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
16
44
  */
17
45
 
18
46
  .text
@@ -34,7 +62,7 @@ MLD_ASM_FN_SYMBOL(polyz_unpack_17_aarch64_asm)
34
62
  movi v30.4s, #0x2, lsl #16
35
63
  mov x9, #0x10 // =16
36
64
 
37
- Lpolyz_unpack_17_loop:
65
+ Lmld_polyz_unpack_17_loop:
38
66
  ld1 { v0.16b, v1.16b }, [x1]
39
67
  add x1, x1, #0x14
40
68
  ld1 { v2.16b }, [x1], #16
@@ -59,7 +87,7 @@ Lpolyz_unpack_17_loop:
59
87
  str q7, [x0, #0x30]
60
88
  str q4, [x0], #0x40
61
89
  subs x9, x9, #0x1
62
- b.ne Lpolyz_unpack_17_loop
90
+ b.ne Lmld_polyz_unpack_17_loop
63
91
  ret
64
92
  .cfi_endproc
65
93
 
@@ -4,6 +4,34 @@
4
4
  * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
5
  */
6
6
 
7
+ /*yaml
8
+ Name: polyz_unpack_19_aarch64_asm
9
+ Description: AArch64 unpacking of 19-bit packed coefficients
10
+ Signature: void mld_polyz_unpack_19_aarch64_asm(int32_t r[256], const uint8_t buf[640], const uint8_t indices[64])
11
+ ABI:
12
+ Architecture: aarch64
13
+ CallingConvention: AAPCS64
14
+ Features: [NEON]
15
+ x0:
16
+ type: buffer
17
+ size_bytes: 1024
18
+ permissions: write-only
19
+ c_parameter: int32_t r[256]
20
+ description: Output polynomial (256 x int32_t)
21
+ x1:
22
+ type: buffer
23
+ size_bytes: 640
24
+ permissions: read-only
25
+ c_parameter: const uint8_t buf[640]
26
+ description: Packed input bytes
27
+ x2:
28
+ type: buffer
29
+ size_bytes: 64
30
+ permissions: read-only
31
+ c_parameter: const uint8_t indices[64]
32
+ description: Permutation index table (64 x uint8_t)
33
+ */
34
+
7
35
  #include "../../../common.h"
8
36
  #if defined(MLD_ARITH_BACKEND_AARCH64) && \
9
37
  (!defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_NO_VERIFY_API)) && \
@@ -12,7 +40,7 @@
12
40
 
13
41
  /*
14
42
  * WARNING: This file is auto-derived from the mldsa-native source file
15
- * dev/aarch64_opt/src/polyz_unpack_19_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
43
+ * dev/aarch64_opt/src/mldsa_polyz_unpack_19_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
16
44
  */
17
45
 
18
46
  .text
@@ -31,7 +59,7 @@ MLD_ASM_FN_SYMBOL(polyz_unpack_19_aarch64_asm)
31
59
  movi v30.4s, #0x8, lsl #16
32
60
  mov x9, #0x10 // =16
33
61
 
34
- Lpolyz_unpack_19_loop:
62
+ Lmld_polyz_unpack_19_loop:
35
63
  ld1 { v0.16b, v1.16b }, [x1]
36
64
  add x1, x1, #0x18
37
65
  ld1 { v2.16b }, [x1], #16
@@ -56,7 +84,7 @@ Lpolyz_unpack_19_loop:
56
84
  str q7, [x0, #0x30]
57
85
  str q4, [x0], #0x40
58
86
  subs x9, x9, #0x1
59
- b.ne Lpolyz_unpack_19_loop
87
+ b.ne Lmld_polyz_unpack_19_loop
60
88
  ret
61
89
  .cfi_endproc
62
90
 
@@ -4,13 +4,46 @@
4
4
  * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
5
  */
6
6
 
7
+ /*yaml
8
+ Name: rej_uniform_aarch64_asm
9
+ Description: AArch64 rejection sampling of uniform coefficients mod q
10
+ Signature: uint64_t mld_rej_uniform_aarch64_asm(int32_t r[256], const uint8_t *buf, unsigned buflen, const uint8_t table[256])
11
+ ABI:
12
+ Architecture: aarch64
13
+ CallingConvention: AAPCS64
14
+ Features: [NEON]
15
+ x0:
16
+ type: buffer
17
+ size_bytes: 1024
18
+ permissions: write-only
19
+ c_parameter: int32_t r[256]
20
+ description: Output buffer (256 x int32_t)
21
+ x1:
22
+ type: buffer
23
+ size_bytes: x2
24
+ permissions: read-only
25
+ c_parameter: const uint8_t *buf
26
+ description: Input buffer
27
+ x2:
28
+ type: scalar
29
+ c_parameter: unsigned buflen
30
+ description: Length of input buffer (must be a multiple of 24)
31
+ test_with: 840 # MLD_POLY_UNIFORM_NBLOCKS * SHAKE128_RATE = 5 * 168
32
+ x3:
33
+ type: buffer
34
+ size_bytes: 256
35
+ permissions: read-only
36
+ c_parameter: const uint8_t table[256]
37
+ description: Lookup table (256 x uint8_t)
38
+ */
39
+
7
40
  #include "../../../common.h"
8
41
  #if defined(MLD_ARITH_BACKEND_AARCH64) && \
9
42
  !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
10
43
 
11
44
  /*
12
45
  * WARNING: This file is auto-derived from the mldsa-native source file
13
- * dev/aarch64_opt/src/rej_uniform_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
46
+ * dev/aarch64_opt/src/mldsa_rej_uniform_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
14
47
  */
15
48
 
16
49
  .text
@@ -35,23 +68,23 @@ MLD_ASM_FN_SYMBOL(rej_uniform_aarch64_asm)
35
68
  mov x11, #0x0 // =0
36
69
  eor v16.16b, v16.16b, v16.16b
37
70
 
38
- Lrej_uniform_initial_zero:
71
+ Lmld_rej_uniform_initial_zero:
39
72
  str q16, [x7], #0x40
40
73
  stur q16, [x7, #-0x30]
41
74
  stur q16, [x7, #-0x20]
42
75
  stur q16, [x7, #-0x10]
43
76
  add x11, x11, #0x10
44
77
  cmp x11, #0x100
45
- b.lt Lrej_uniform_initial_zero
78
+ b.lt Lmld_rej_uniform_initial_zero
46
79
  mov x7, x8
47
80
  mov x9, #0x0 // =0
48
81
  mov x4, #0x100 // =256
49
82
  cmp x2, #0x30
50
- b.lo Lrej_uniform_loop48_end
83
+ b.lo Lmld_rej_uniform_loop48_end
51
84
 
52
- Lrej_uniform_loop48:
85
+ Lmld_rej_uniform_loop48:
53
86
  cmp x9, x4
54
- b.hs Lrej_uniform_memory_copy
87
+ b.hs Lmld_rej_uniform_memory_copy
55
88
  sub x2, x2, #0x30
56
89
  ld3 { v0.16b, v1.16b, v2.16b }, [x1], #48
57
90
  movi v4.16b, #0x80
@@ -113,13 +146,13 @@ Lrej_uniform_loop48:
113
146
  add x9, x9, x12
114
147
  add x9, x9, x14
115
148
  cmp x2, #0x30
116
- b.hs Lrej_uniform_loop48
149
+ b.hs Lmld_rej_uniform_loop48
117
150
 
118
- Lrej_uniform_loop48_end:
151
+ Lmld_rej_uniform_loop48_end:
119
152
  cmp x9, x4
120
- b.hs Lrej_uniform_memory_copy
153
+ b.hs Lmld_rej_uniform_memory_copy
121
154
  cmp x2, #0x18
122
- b.lo Lrej_uniform_memory_copy
155
+ b.lo Lmld_rej_uniform_memory_copy
123
156
  sub x2, x2, #0x18
124
157
  ld3 { v0.8b, v1.8b, v2.8b }, [x1], #24
125
158
  movi v4.16b, #0x80
@@ -153,13 +186,13 @@ Lrej_uniform_loop48_end:
153
186
  add x9, x9, x12
154
187
  add x9, x9, x13
155
188
 
156
- Lrej_uniform_memory_copy:
189
+ Lmld_rej_uniform_memory_copy:
157
190
  cmp x9, x4
158
191
  csel x9, x9, x4, lo
159
192
  mov x11, #0x0 // =0
160
193
  mov x7, x8
161
194
 
162
- Lrej_uniform_final_copy:
195
+ Lmld_rej_uniform_final_copy:
163
196
  ldr q16, [x7], #0x40
164
197
  ldur q17, [x7, #-0x30]
165
198
  ldur q18, [x7, #-0x20]
@@ -170,11 +203,11 @@ Lrej_uniform_final_copy:
170
203
  stur q19, [x0, #-0x10]
171
204
  add x11, x11, #0x10
172
205
  cmp x11, #0x100
173
- b.lt Lrej_uniform_final_copy
206
+ b.lt Lmld_rej_uniform_final_copy
174
207
  mov x0, x9
175
- b Lrej_uniform_return
208
+ b Lmld_rej_uniform_return
176
209
 
177
- Lrej_uniform_return:
210
+ Lmld_rej_uniform_return:
178
211
  add sp, sp, #0x440
179
212
  .cfi_adjust_cfa_offset -0x440
180
213
  ret
@@ -4,6 +4,39 @@
4
4
  * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
5
  */
6
6
 
7
+ /*yaml
8
+ Name: rej_uniform_eta2_aarch64_asm
9
+ Description: AArch64 rejection sampling of eta=2 secret coefficients
10
+ Signature: uint64_t mld_rej_uniform_eta2_aarch64_asm(int32_t r[256], const uint8_t *buf, unsigned buflen, const uint8_t table[4096])
11
+ ABI:
12
+ Architecture: aarch64
13
+ CallingConvention: AAPCS64
14
+ Features: [NEON]
15
+ x0:
16
+ type: buffer
17
+ size_bytes: 1024
18
+ permissions: write-only
19
+ c_parameter: int32_t r[256]
20
+ description: Output buffer (256 x int32_t)
21
+ x1:
22
+ type: buffer
23
+ size_bytes: x2
24
+ permissions: read-only
25
+ c_parameter: const uint8_t *buf
26
+ description: Input buffer
27
+ x2:
28
+ type: scalar
29
+ c_parameter: unsigned buflen
30
+ description: Length of input buffer (must be a multiple of 8)
31
+ test_with: 136 # MLD_AARCH64_REJ_UNIFORM_ETA2_BUFLEN
32
+ x3:
33
+ type: buffer
34
+ size_bytes: 4096
35
+ permissions: read-only
36
+ c_parameter: const uint8_t table[4096]
37
+ description: Lookup table (4096 x uint8_t)
38
+ */
39
+
7
40
  #include "../../../common.h"
8
41
  #if defined(MLD_ARITH_BACKEND_AARCH64) && \
9
42
  !defined(MLD_CONFIG_NO_KEYPAIR_API) && \
@@ -12,7 +45,7 @@
12
45
 
13
46
  /*
14
47
  * WARNING: This file is auto-derived from the mldsa-native source file
15
- * dev/aarch64_opt/src/rej_uniform_eta2_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
48
+ * dev/aarch64_opt/src/mldsa_rej_uniform_eta2_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
16
49
  */
17
50
 
18
51
  .text
@@ -39,21 +72,21 @@ MLD_ASM_FN_SYMBOL(rej_uniform_eta2_aarch64_asm)
39
72
  mov x11, #0x0 // =0
40
73
  eor v16.16b, v16.16b, v16.16b
41
74
 
42
- Lrej_uniform_eta2_initial_zero:
75
+ Lmld_rej_uniform_eta2_initial_zero:
43
76
  str q16, [x7], #0x40
44
77
  stur q16, [x7, #-0x30]
45
78
  stur q16, [x7, #-0x20]
46
79
  stur q16, [x7, #-0x10]
47
80
  add x11, x11, #0x20
48
81
  cmp x11, #0x100
49
- b.lt Lrej_uniform_eta2_initial_zero
82
+ b.lt Lmld_rej_uniform_eta2_initial_zero
50
83
  mov x7, x8
51
84
  mov x9, #0x0 // =0
52
85
  mov x4, #0x100 // =256
53
86
 
54
- Lrej_uniform_eta2_loop8:
87
+ Lmld_rej_uniform_eta2_loop8:
55
88
  cmp x9, x4
56
- b.hs Lrej_uniform_eta2_memory_copy
89
+ b.hs Lmld_rej_uniform_eta2_memory_copy
57
90
  sub x2, x2, #0x8
58
91
  ld1 { v0.8b }, [x1], #8
59
92
  movi v26.8b, #0xf
@@ -88,9 +121,9 @@ Lrej_uniform_eta2_loop8:
88
121
  add x12, x12, x13
89
122
  add x9, x9, x12
90
123
  cmp x2, #0x8
91
- b.hs Lrej_uniform_eta2_loop8
124
+ b.hs Lmld_rej_uniform_eta2_loop8
92
125
 
93
- Lrej_uniform_eta2_memory_copy:
126
+ Lmld_rej_uniform_eta2_memory_copy:
94
127
  cmp x9, x4
95
128
  csel x9, x9, x4, lo
96
129
  mov w7, #0x199a // =6554
@@ -100,7 +133,7 @@ Lrej_uniform_eta2_memory_copy:
100
133
  mov x11, #0x0 // =0
101
134
  mov x7, x8
102
135
 
103
- Lrej_uniform_eta2_final_copy:
136
+ Lmld_rej_uniform_eta2_final_copy:
104
137
  ldr q16, [x7], #0x20
105
138
  ldur q18, [x7, #-0x10]
106
139
  sqdmulh v28.8h, v16.8h, v26.8h
@@ -119,7 +152,7 @@ Lrej_uniform_eta2_final_copy:
119
152
  stur q19, [x0, #-0x10]
120
153
  add x11, x11, #0x10
121
154
  cmp x11, #0x100
122
- b.lt Lrej_uniform_eta2_final_copy
155
+ b.lt Lmld_rej_uniform_eta2_final_copy
123
156
  mov x0, x9
124
157
  add sp, sp, #0x240
125
158
  .cfi_adjust_cfa_offset -0x240
@@ -4,6 +4,39 @@
4
4
  * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
5
5
  */
6
6
 
7
+ /*yaml
8
+ Name: rej_uniform_eta4_aarch64_asm
9
+ Description: AArch64 rejection sampling of eta=4 secret coefficients
10
+ Signature: uint64_t mld_rej_uniform_eta4_aarch64_asm(int32_t r[256], const uint8_t *buf, unsigned buflen, const uint8_t table[4096])
11
+ ABI:
12
+ Architecture: aarch64
13
+ CallingConvention: AAPCS64
14
+ Features: [NEON]
15
+ x0:
16
+ type: buffer
17
+ size_bytes: 1024
18
+ permissions: write-only
19
+ c_parameter: int32_t r[256]
20
+ description: Output buffer (256 x int32_t)
21
+ x1:
22
+ type: buffer
23
+ size_bytes: x2
24
+ permissions: read-only
25
+ c_parameter: const uint8_t *buf
26
+ description: Input buffer
27
+ x2:
28
+ type: scalar
29
+ c_parameter: unsigned buflen
30
+ description: Length of input buffer (must be a multiple of 8)
31
+ test_with: 272 # MLD_AARCH64_REJ_UNIFORM_ETA4_BUFLEN
32
+ x3:
33
+ type: buffer
34
+ size_bytes: 4096
35
+ permissions: read-only
36
+ c_parameter: const uint8_t table[4096]
37
+ description: Lookup table (4096 x uint8_t)
38
+ */
39
+
7
40
  #include "../../../common.h"
8
41
  #if defined(MLD_ARITH_BACKEND_AARCH64) && \
9
42
  !defined(MLD_CONFIG_NO_KEYPAIR_API) && \
@@ -12,7 +45,7 @@
12
45
 
13
46
  /*
14
47
  * WARNING: This file is auto-derived from the mldsa-native source file
15
- * dev/aarch64_opt/src/rej_uniform_eta4_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
48
+ * dev/aarch64_opt/src/mldsa_rej_uniform_eta4_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
16
49
  */
17
50
 
18
51
  .text
@@ -40,21 +73,21 @@ MLD_ASM_FN_SYMBOL(rej_uniform_eta4_aarch64_asm)
40
73
  mov x11, #0x0 // =0
41
74
  eor v16.16b, v16.16b, v16.16b
42
75
 
43
- Lrej_uniform_eta4_initial_zero:
76
+ Lmld_rej_uniform_eta4_initial_zero:
44
77
  str q16, [x7], #0x40
45
78
  stur q16, [x7, #-0x30]
46
79
  stur q16, [x7, #-0x20]
47
80
  stur q16, [x7, #-0x10]
48
81
  add x11, x11, #0x20
49
82
  cmp x11, #0x100
50
- b.lt Lrej_uniform_eta4_initial_zero
83
+ b.lt Lmld_rej_uniform_eta4_initial_zero
51
84
  mov x7, x8
52
85
  mov x9, #0x0 // =0
53
86
  mov x4, #0x100 // =256
54
87
 
55
- Lrej_uniform_eta4_loop8:
88
+ Lmld_rej_uniform_eta4_loop8:
56
89
  cmp x9, x4
57
- b.hs Lrej_uniform_eta4_memory_copy
90
+ b.hs Lmld_rej_uniform_eta4_memory_copy
58
91
  sub x2, x2, #0x8
59
92
  ld1 { v0.8b }, [x1], #8
60
93
  movi v26.8b, #0xf
@@ -89,15 +122,15 @@ Lrej_uniform_eta4_loop8:
89
122
  add x12, x12, x13
90
123
  add x9, x9, x12
91
124
  cmp x2, #0x8
92
- b.hs Lrej_uniform_eta4_loop8
125
+ b.hs Lmld_rej_uniform_eta4_loop8
93
126
 
94
- Lrej_uniform_eta4_memory_copy:
127
+ Lmld_rej_uniform_eta4_memory_copy:
95
128
  cmp x9, x4
96
129
  csel x9, x9, x4, lo
97
130
  mov x11, #0x0 // =0
98
131
  mov x7, x8
99
132
 
100
- Lrej_uniform_eta4_final_copy:
133
+ Lmld_rej_uniform_eta4_final_copy:
101
134
  ldr q16, [x7], #0x20
102
135
  ldur q18, [x7, #-0x10]
103
136
  sub v16.8h, v7.8h, v16.8h
@@ -112,7 +145,7 @@ Lrej_uniform_eta4_final_copy:
112
145
  stur q19, [x0, #-0x10]
113
146
  add x11, x11, #0x10
114
147
  cmp x11, #0x100
115
- b.lt Lrej_uniform_eta4_final_copy
148
+ b.lt Lmld_rej_uniform_eta4_final_copy
116
149
  mov x0, x9
117
150
  add sp, sp, #0x240
118
151
  .cfi_adjust_cfa_offset -0x240
@@ -37,11 +37,17 @@
37
37
  */
38
38
  #define MLD_NATIVE_FUNC_FALLBACK (-1)
39
39
 
40
+ /* Absolute exclusive upper bound for the output of fqmul.
41
+ *
42
+ * NOTE: This is the same bound as in poly.h and has to be kept
43
+ * in sync. */
44
+ #define MLD_FQMUL_BOUND ((5 * MLDSA_Q + 3) / 4)
45
+
40
46
  /* Bound on absolute value of coefficients after NTT.
41
47
  *
42
48
  * NOTE: This is the same bound as in poly.h and has to be kept
43
49
  * in sync. */
44
- #define MLD_NTT_BOUND (9 * MLDSA_Q)
50
+ #define MLD_NTT_BOUND (9 * MLD_FQMUL_BOUND)
45
51
 
46
52
  /* Absolute exclusive upper bound for the output of the inverse NTT
47
53
  *
@@ -215,7 +221,8 @@ __contract__(
215
221
  requires(memory_no_alias(buf, buflen))
216
222
  assigns(memory_slice(r, sizeof(int32_t) * len))
217
223
  ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || (0 <= return_value && return_value <= len))
218
- ensures((return_value != MLD_NATIVE_FUNC_FALLBACK) ==> (array_abs_bound(r, 0, return_value, MLDSA_ETA + 1)))
224
+ /* check-magic: 3 == 2 + 1 (decl gated on MLDSA_ETA == 2) */
225
+ ensures((return_value != MLD_NATIVE_FUNC_FALLBACK) ==> (array_abs_bound(r, 0, return_value, 3)))
219
226
  );
220
227
  #endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_ETA == 2 */
221
228
  #endif /* MLD_USE_NATIVE_REJ_UNIFORM_ETA2 */
@@ -249,7 +256,8 @@ __contract__(
249
256
  requires(memory_no_alias(buf, buflen))
250
257
  assigns(memory_slice(r, sizeof(int32_t) * len))
251
258
  ensures(return_value == MLD_NATIVE_FUNC_FALLBACK || (0 <= return_value && return_value <= len))
252
- ensures((return_value != MLD_NATIVE_FUNC_FALLBACK) ==> (array_abs_bound(r, 0, return_value, MLDSA_ETA + 1)))
259
+ /* check-magic: 5 == 4 + 1 (decl gated on MLDSA_ETA == 4) */
260
+ ensures((return_value != MLD_NATIVE_FUNC_FALLBACK) ==> (array_abs_bound(r, 0, return_value, 5)))
253
261
  );
254
262
  #endif /* MLD_CONFIG_MULTILEVEL_WITH_SHARED || MLDSA_ETA == 4 */
255
263
  #endif /* MLD_USE_NATIVE_REJ_UNIFORM_ETA4 */
@@ -12,11 +12,12 @@
12
12
  */
13
13
  #include "../sys.h"
14
14
 
15
- #ifdef MLD_SYS_AARCH64
15
+ #ifdef MLD_SYS_AARCH64_NEON
16
16
  #include "aarch64/meta.h"
17
17
  #endif
18
18
 
19
- #ifdef MLD_SYS_X86_64_AVX2
19
+ /* The x86_64 backend requires toolchain support for the SysV ABI */
20
+ #if defined(MLD_SYS_X86_64_AVX2) && defined(MLD_SYSV_ABI_SUPPORTED)
20
21
  #include "x86_64/meta.h"
21
22
  #endif
22
23