pq_crypto 0.6.1 → 0.6.3

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 (247) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/SECURITY.md +7 -0
  4. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  5. data/ext/pqcrypto/vendor/.vendored +7 -7
  6. data/ext/pqcrypto/vendor/mldsa-native/README.md +23 -10
  7. data/ext/pqcrypto/vendor/mldsa-native/mldsa/README.md +23 -0
  8. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +114 -58
  9. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +498 -461
  10. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +145 -85
  11. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +456 -422
  12. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +47 -25
  13. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +26 -14
  14. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +56 -81
  15. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +17 -24
  16. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.c +33 -40
  17. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +67 -87
  18. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +19 -14
  19. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +13 -5
  20. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +84 -10
  21. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +10 -5
  22. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +6 -0
  23. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +22 -15
  24. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +376 -0
  25. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +204 -0
  26. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +259 -0
  27. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +1077 -0
  28. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +987 -0
  29. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +16 -10
  30. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +2 -1
  31. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +1 -1
  32. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +4 -2
  33. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +2 -2
  34. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +1 -1
  35. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +60 -0
  36. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +48 -0
  37. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +18 -1
  38. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +658 -582
  39. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +5 -100
  40. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +26 -25
  41. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +334 -0
  42. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +355 -0
  43. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +8 -3
  44. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/{xkcp.h → keccak_f1600_x4_avx2.h} +11 -8
  45. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +44 -0
  46. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +454 -0
  47. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +52 -0
  48. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +37 -28
  49. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +213 -196
  50. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +248 -64
  51. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt_aarch64_asm.S +753 -0
  52. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +129 -0
  53. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +145 -0
  54. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +177 -0
  55. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt_aarch64_asm.S +653 -0
  56. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery_aarch64_asm.S +84 -0
  57. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_aarch64_asm.S +53 -0
  58. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_aarch64_asm.S +55 -0
  59. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_aarch64_asm.S +86 -0
  60. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_aarch64_asm.S +86 -0
  61. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_aarch64_asm.S +103 -0
  62. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_aarch64_asm.S +111 -0
  63. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_aarch64_asm.S +75 -0
  64. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_aarch64_asm.S +72 -0
  65. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +23 -11
  66. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_aarch64_asm.S +189 -0
  67. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_aarch64_asm.S +137 -0
  68. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_aarch64_asm.S +130 -0
  69. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +520 -516
  70. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +34 -33
  71. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +202 -242
  72. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +25 -17
  73. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +112 -28
  74. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +1 -1
  75. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +1 -1
  76. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt_avx2_asm.S +2311 -0
  77. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt_avx2_asm.S +2383 -0
  78. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack_avx2_asm.S +238 -0
  79. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4_avx2_asm.S +139 -0
  80. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5_avx2_asm.S +155 -0
  81. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7_avx2_asm.S +187 -0
  82. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_avx2_asm.S +130 -0
  83. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2_asm.S +190 -0
  84. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +6 -4
  85. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +6 -4
  86. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +9 -8
  87. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +10 -9
  88. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +8 -5
  89. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +8 -5
  90. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +6 -4
  91. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +6 -4
  92. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +130 -129
  93. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +109 -180
  94. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +169 -150
  95. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +56 -40
  96. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +149 -164
  97. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +52 -57
  98. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +132 -167
  99. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +57 -424
  100. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +167 -474
  101. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +308 -0
  102. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +653 -0
  103. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +22 -29
  104. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +37 -43
  105. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +511 -367
  106. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +456 -417
  107. data/ext/pqcrypto/vendor/mlkem-native/README.md +6 -3
  108. data/ext/pqcrypto/vendor/mlkem-native/RELEASE.md +22 -0
  109. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.c +77 -36
  110. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native.h +135 -146
  111. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_asm.S +116 -72
  112. data/ext/pqcrypto/vendor/mlkem-native/mlkem/mlkem_native_config.h +351 -415
  113. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/cbmc.h +43 -20
  114. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/common.h +16 -8
  115. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.c +57 -31
  116. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/compress.h +260 -349
  117. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/debug.h +17 -24
  118. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.c +35 -37
  119. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202.h +43 -57
  120. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.c +14 -15
  121. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/fips202x4.h +5 -4
  122. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/keccakf1600.c +42 -6
  123. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/fips202_native_aarch64.h +31 -20
  124. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x1_scalar_asm.S → keccak_f1600_x1_scalar_aarch64_asm.S} +10 -10
  125. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x1_v84a_asm.S → keccak_f1600_x1_v84a_aarch64_asm.S} +10 -10
  126. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x2_v84a_asm.S → keccak_f1600_x2_v84a_aarch64_asm.S} +10 -10
  127. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x4_v8a_scalar_hybrid_asm.S → keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S} +10 -10
  128. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/{keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S → keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S} +10 -10
  129. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +10 -9
  130. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_scalar.h +2 -1
  131. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x1_v84a.h +1 -1
  132. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x2_v84a.h +4 -2
  133. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_scalar.h +2 -2
  134. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +1 -1
  135. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/fips202_native_armv81m.h +2 -1
  136. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +55 -9
  137. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +26 -25
  138. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +58 -14
  139. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +57 -16
  140. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/auto.h +2 -1
  141. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +2 -2
  142. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/fips202_native_x86_64.h +10 -7
  143. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/{keccak_f1600_x4_avx2.S → keccak_f1600_x4_avx2_asm.S} +13 -11
  144. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/fips202/native/x86_64/src/keccakf1600_constants.c +12 -11
  145. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.c +167 -136
  146. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/indcpa.h +75 -68
  147. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/kem.h +135 -157
  148. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/meta.h +15 -13
  149. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/aarch64_zetas.c +143 -135
  150. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/arith_native_aarch64.h +52 -46
  151. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{intt.S → intt_aarch64_asm.S} +10 -10
  152. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{ntt.S → ntt_aarch64_asm.S} +10 -10
  153. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_mulcache_compute_asm.S → poly_mulcache_compute_aarch64_asm.S} +10 -10
  154. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_reduce_asm.S → poly_reduce_aarch64_asm.S} +10 -10
  155. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tobytes_asm.S → poly_tobytes_aarch64_asm.S} +10 -10
  156. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{poly_tomont_asm.S → poly_tomont_aarch64_asm.S} +10 -12
  157. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_asm_k2.S → polyvec_basemul_acc_montgomery_cached_k2_aarch64_asm.S} +10 -10
  158. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_asm_k3.S → polyvec_basemul_acc_montgomery_cached_k3_aarch64_asm.S} +10 -10
  159. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{polyvec_basemul_acc_montgomery_cached_asm_k4.S → polyvec_basemul_acc_montgomery_cached_k4_aarch64_asm.S} +10 -10
  160. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/{rej_uniform_asm.S → rej_uniform_aarch64_asm.S} +12 -12
  161. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/aarch64/src/rej_uniform_table.c +514 -513
  162. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/api.h +254 -253
  163. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/meta.h +6 -1
  164. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/README.md +6 -0
  165. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/meta.h +77 -0
  166. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/arith_native_ppc64le.h +24 -0
  167. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/consts.c +299 -0
  168. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/consts.h +34 -0
  169. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/intt_ppc_asm.S +3222 -0
  170. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/ntt_ppc_asm.S +1651 -0
  171. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/poly_tomont_ppc_asm.S +294 -0
  172. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/ppc64le/src/reduce_ppc_asm.S +710 -0
  173. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/meta.h +5 -0
  174. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.c +18 -16
  175. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_debug.h +19 -24
  176. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/riscv64/src/rv64v_poly.c +53 -65
  177. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/meta.h +20 -20
  178. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/arith_native_x86_64.h +106 -88
  179. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.c +45 -35
  180. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/compress_consts.h +8 -8
  181. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.c +1 -1
  182. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/consts.h +1 -1
  183. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{intt.S → intt_avx2_asm.S} +8 -8
  184. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntt.S → ntt_avx2_asm.S} +8 -8
  185. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttfrombytes.S → nttfrombytes_avx2_asm.S} +8 -8
  186. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{ntttobytes.S → ntttobytes_avx2_asm.S} +8 -8
  187. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{nttunpack.S → nttunpack_avx2_asm.S} +8 -8
  188. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d10.S → poly_compress_d10_avx2_asm.S} +9 -9
  189. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d11.S → poly_compress_d11_avx2_asm.S} +9 -9
  190. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d4.S → poly_compress_d4_avx2_asm.S} +9 -9
  191. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_compress_d5.S → poly_compress_d5_avx2_asm.S} +9 -9
  192. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d10.S → poly_decompress_d10_avx2_asm.S} +9 -9
  193. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d11.S → poly_decompress_d11_avx2_asm.S} +9 -9
  194. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d4.S → poly_decompress_d4_avx2_asm.S} +9 -9
  195. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{poly_decompress_d5.S → poly_decompress_d5_avx2_asm.S} +9 -9
  196. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{mulcache_compute.S → poly_mulcache_compute_avx2_asm.S} +8 -8
  197. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_asm_k2.S → polyvec_basemul_acc_montgomery_cached_k2_avx2_asm.S} +8 -8
  198. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_asm_k3.S → polyvec_basemul_acc_montgomery_cached_k3_avx2_asm.S} +8 -8
  199. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{polyvec_basemul_acc_montgomery_cached_asm_k4.S → polyvec_basemul_acc_montgomery_cached_k4_avx2_asm.S} +8 -8
  200. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{reduce.S → reduce_avx2_asm.S} +8 -8
  201. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{rej_uniform_asm.S → rej_uniform_avx2_asm.S} +9 -9
  202. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/rej_uniform_table.c +514 -513
  203. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/native/x86_64/src/{tomont.S → tomont_avx2_asm.S} +8 -8
  204. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.c +61 -57
  205. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly.h +89 -116
  206. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.c +31 -32
  207. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/poly_k.h +226 -301
  208. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/randombytes.h +21 -29
  209. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.c +68 -63
  210. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sampling.h +37 -48
  211. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/sys.h +44 -2
  212. data/ext/pqcrypto/vendor/mlkem-native/mlkem/src/verify.h +141 -159
  213. data/lib/pq_crypto/version.rb +1 -1
  214. data/script/vendor_libs.rb +6 -6
  215. metadata +86 -71
  216. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +0 -376
  217. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +0 -204
  218. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +0 -259
  219. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +0 -1077
  220. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +0 -987
  221. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.c +0 -488
  222. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.h +0 -16
  223. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt.S +0 -753
  224. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4.S +0 -129
  225. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5.S +0 -145
  226. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7.S +0 -177
  227. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt.S +0 -653
  228. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery.S +0 -79
  229. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_asm.S +0 -53
  230. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_asm.S +0 -55
  231. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_asm.S +0 -85
  232. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_asm.S +0 -85
  233. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_asm.S +0 -102
  234. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_asm.S +0 -110
  235. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_asm.S +0 -72
  236. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_asm.S +0 -69
  237. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_asm.S +0 -189
  238. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_asm.S +0 -135
  239. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_asm.S +0 -128
  240. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt.S +0 -2311
  241. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt.S +0 -2383
  242. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack.S +0 -239
  243. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise.S +0 -131
  244. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4.S +0 -139
  245. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5.S +0 -155
  246. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7.S +0 -187
  247. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2.c +0 -61
@@ -8,37 +8,30 @@
8
8
 
9
9
  #if defined(MLKEM_DEBUG)
10
10
 
11
- /*************************************************
12
- * Name: mlk_assert
11
+ /**
12
+ * Check debug assertion.
13
13
  *
14
- * Description: Check debug assertion
14
+ * Prints an error message to stderr and calls exit(1) on failure.
15
15
  *
16
- * Prints an error message to stderr and calls
17
- * exit(1) if not.
18
- *
19
- * Arguments: - file: filename
20
- * - line: line number
21
- * - val: Value asserted to be non-zero
22
- **************************************************/
16
+ * @param[in] file Filename.
17
+ * @param line Line number.
18
+ * @param val Value asserted to be non-zero.
19
+ */
23
20
  #define mlk_debug_check_assert MLK_NAMESPACE(mlkem_debug_assert)
24
21
  void mlk_debug_check_assert(const char *file, int line, const int val);
25
22
 
26
- /*************************************************
27
- * Name: mlk_debug_check_bounds
23
+ /**
24
+ * Check whether values in an array of int16_t are within specified bounds.
28
25
  *
29
- * Description: Check whether values in an array of int16_t
30
- * are within specified bounds.
26
+ * Prints an error message to stderr and calls exit(1) on failure.
31
27
  *
32
- * Prints an error message to stderr and calls
33
- * exit(1) if not.
34
- *
35
- * Arguments: - file: filename
36
- * - line: line number
37
- * - ptr: Base of array to be checked
38
- * - len: Number of int16_t in ptr
39
- * - lower_bound_exclusive: Exclusive lower bound
40
- * - upper_bound_exclusive: Exclusive upper bound
41
- **************************************************/
28
+ * @param[in] file Filename.
29
+ * @param line Line number.
30
+ * @param[in] ptr Base of array to be checked.
31
+ * @param len Number of int16_t in @p ptr.
32
+ * @param lower_bound_exclusive Exclusive lower bound.
33
+ * @param upper_bound_exclusive Exclusive upper bound.
34
+ */
42
35
  #define mlk_debug_check_bounds MLK_NAMESPACE(mlkem_debug_check_bounds)
43
36
  void mlk_debug_check_bounds(const char *file, int line, const int16_t *ptr,
44
37
  unsigned len, int lower_bound_exclusive,
@@ -39,26 +39,23 @@
39
39
  #include "fips202.h"
40
40
  #include "keccakf1600.h"
41
41
 
42
- /*************************************************
43
- * Name: mlk_keccak_absorb_once
42
+ /**
43
+ * Absorb step of Keccak; non-incremental, starts by zeroeing the state.
44
44
  *
45
- * Description: Absorb step of Keccak;
46
- * non-incremental, starts by zeroeing the state.
45
+ * @warning Must only be called once.
47
46
  *
48
- * WARNING: Must only be called once.
49
- *
50
- * Arguments: - uint64_t *s: pointer to (uninitialized) output Keccak
51
- * state
52
- * - unsigned r: rate in bytes (e.g., 168 for SHAKE128)
53
- * - const uint8_t *m: pointer to input to be absorbed into s
54
- * - size_t mlen: length of input in bytes
55
- * - uint8_t p: domain-separation byte for different
56
- * Keccak-derived functions
57
- **************************************************/
47
+ * @param[out] s Pointer to (uninitialized) output Keccak state.
48
+ * @param r Rate in bytes (e.g., 168 for SHAKE128).
49
+ * @param[in] m Input to be absorbed into @p s.
50
+ * @param mlen Length of input in bytes.
51
+ * @param p Domain-separation byte for different Keccak-derived
52
+ * functions.
53
+ */
58
54
  static void mlk_keccak_absorb_once(uint64_t *s, unsigned r, const uint8_t *m,
59
55
  size_t mlen, uint8_t p)
60
56
  __contract__(
61
57
  requires(mlen <= MLK_MAX_BUFFER_SIZE)
58
+ requires(r > 0)
62
59
  requires(r <= sizeof(uint64_t) * MLK_KECCAK_LANES)
63
60
  requires(memory_no_alias(s, sizeof(uint64_t) * MLK_KECCAK_LANES))
64
61
  requires(memory_no_alias(m, mlen))
@@ -67,7 +64,8 @@ __contract__(
67
64
  /* Initialize state */
68
65
  size_t i;
69
66
  for (i = 0; i < 25; ++i)
70
- __loop__(invariant(i <= 25))
67
+ __loop__(invariant(i <= 25)
68
+ decreases(25 - i))
71
69
  {
72
70
  s[i] = 0;
73
71
  }
@@ -76,7 +74,8 @@ __contract__(
76
74
  __loop__(
77
75
  assigns(mlen, m, memory_slice(s, sizeof(uint64_t) * MLK_KECCAK_LANES))
78
76
  invariant(mlen <= loop_entry(mlen))
79
- invariant(m == loop_entry(m) + (loop_entry(mlen) - mlen)))
77
+ invariant(m == loop_entry(m) + (loop_entry(mlen) - mlen))
78
+ decreases(mlen))
80
79
  {
81
80
  mlk_keccakf1600_xor_bytes(s, m, 0, r);
82
81
  mlk_keccakf1600_permute(s);
@@ -104,16 +103,14 @@ __contract__(
104
103
  }
105
104
  }
106
105
 
107
- /*************************************************
108
- * Name: mlk_keccak_squeezeblocks
109
- *
110
- * Description: block-level Keccak squeeze
106
+ /**
107
+ * Block-level Keccak squeeze.
111
108
  *
112
- * Arguments: - uint8_t *h: pointer to output bytes
113
- * - size_t nblocks: number of blocks to be squeezed
114
- * - uint64_t *s_inc: pointer to input/output state
115
- * - unsigned r: rate in bytes (e.g., 168 for SHAKE128)
116
- **************************************************/
109
+ * @param[out] h Output bytes.
110
+ * @param nblocks Number of blocks to be squeezed.
111
+ * @param[in,out] s Input/output state.
112
+ * @param r Rate in bytes (e.g., 168 for SHAKE128).
113
+ */
117
114
  static void mlk_keccak_squeezeblocks(uint8_t *h, size_t nblocks, uint64_t *s,
118
115
  unsigned r)
119
116
  __contract__(
@@ -130,7 +127,8 @@ __contract__(
130
127
  memory_slice(s, sizeof(uint64_t) * MLK_KECCAK_LANES),
131
128
  memory_slice(h, nblocks * r))
132
129
  invariant(nblocks <= loop_entry(nblocks) &&
133
- h == loop_entry(h) + r * (loop_entry(nblocks) - nblocks)))
130
+ h == loop_entry(h) + r * (loop_entry(nblocks) - nblocks))
131
+ decreases(nblocks))
134
132
  {
135
133
  mlk_keccakf1600_permute(s);
136
134
  mlk_keccakf1600_extract_bytes(s, h, 0, r);
@@ -139,22 +137,21 @@ __contract__(
139
137
  }
140
138
  }
141
139
 
142
- /*************************************************
143
- * Name: mlk_keccak_squeeze_once
144
- *
145
- * Description: Keccak squeeze; can be called on byte-level
140
+ /**
141
+ * Keccak squeeze; can be called on byte-level.
146
142
  *
147
- * WARNING: This must only be called once.
143
+ * @warning Must only be called once.
148
144
  *
149
- * Arguments: - uint8_t *h: pointer to output bytes
150
- * - size_t outlen: number of bytes to be squeezed
151
- * - uint64_t *s_inc: pointer to Keccak state
152
- * - unsigned r: rate in bytes (e.g., 168 for SHAKE128)
153
- **************************************************/
145
+ * @param[out] h Output bytes.
146
+ * @param outlen Number of bytes to be squeezed.
147
+ * @param[in,out] s Keccak state.
148
+ * @param r Rate in bytes (e.g., 168 for SHAKE128).
149
+ */
154
150
  static void mlk_keccak_squeeze_once(uint8_t *h, size_t outlen, uint64_t *s,
155
151
  unsigned r)
156
152
  __contract__(
157
153
  requires(outlen <= MLK_MAX_BUFFER_SIZE)
154
+ requires(r > 0)
158
155
  requires(r <= sizeof(uint64_t) * MLK_KECCAK_LANES)
159
156
  requires(memory_no_alias(s, sizeof(uint64_t) * MLK_KECCAK_LANES))
160
157
  requires(memory_no_alias(h, outlen))
@@ -168,7 +165,8 @@ __contract__(
168
165
  memory_slice(s, sizeof(uint64_t) * MLK_KECCAK_LANES),
169
166
  memory_slice(h, outlen))
170
167
  invariant(outlen <= loop_entry(outlen) &&
171
- h == loop_entry(h) + (loop_entry(outlen) - outlen)))
168
+ h == loop_entry(h) + (loop_entry(outlen) - outlen))
169
+ decreases(outlen))
172
170
  {
173
171
  mlk_keccakf1600_permute(s);
174
172
 
@@ -14,35 +14,30 @@
14
14
  #define SHA3_384_RATE 104
15
15
  #define SHA3_512_RATE 72
16
16
 
17
- /* Context for non-incremental API */
17
+ /** Context for the non-incremental SHAKE128 API. */
18
18
  typedef struct
19
19
  {
20
- uint64_t ctx[25];
20
+ uint64_t ctx[25]; /**< Keccak state. */
21
21
  } MLK_ALIGN mlk_shake128ctx;
22
22
 
23
23
  #define mlk_shake128_absorb_once MLK_NAMESPACE(shake128_absorb_once)
24
- /*************************************************
25
- * Name: mlk_shake128_absorb_once
24
+ /**
25
+ * One-shot absorb step of the SHAKE128 XOF.
26
26
  *
27
- * Description: One-shot absorb step of the SHAKE128 XOF.
27
+ * For call-sites (in mlkem-native):
28
+ * - This function MUST ONLY be called straight after mlk_shake128_init().
29
+ * - This function MUST ONLY be called once.
28
30
  *
29
- * For call-sites (in mlkem-native):
30
- * - This function MUST ONLY be called straight after
31
- * mlk_shake128_init().
32
- * - This function MUST ONLY be called once.
31
+ * Consequently, for providers of custom FIPS202 code to be used with
32
+ * mlkem-native:
33
+ * - You may assume that the input context is freshly initialized via
34
+ * mlk_shake128_init().
35
+ * - You may assume that this function is called exactly once.
33
36
  *
34
- * Consequently, for providers of custom FIPS202 code
35
- * to be used with mlkem-native:
36
- * - You may assume that the input context is
37
- * freshly initialized via mlk_shake128_init().
38
- * - You may assume that this function is
39
- * called exactly once.
40
- *
41
- * Arguments: - mlk_shake128ctx *state: pointer to SHAKE128 context
42
- * - const uint8_t *input: pointer to input to be absorbed into
43
- * the state
44
- * - size_t inlen: length of input in bytes
45
- **************************************************/
37
+ * @param[in,out] state SHAKE128 context.
38
+ * @param[in] input Input to be absorbed into the state.
39
+ * @param inlen Length of input in bytes.
40
+ */
46
41
  void mlk_shake128_absorb_once(mlk_shake128ctx *state, const uint8_t *input,
47
42
  size_t inlen)
48
43
  __contract__(
@@ -53,18 +48,15 @@ __contract__(
53
48
  );
54
49
 
55
50
  #define mlk_shake128_squeezeblocks MLK_NAMESPACE(shake128_squeezeblocks)
56
- /*************************************************
57
- * Name: mlk_shake128_squeezeblocks
58
- *
59
- * Description: Squeeze step of SHAKE128 XOF. Squeezes full blocks of
60
- * SHAKE128_RATE bytes each. Modifies the state. Can be called
61
- * multiple times to keep squeezing, i.e., is incremental.
51
+ /**
52
+ * Squeeze step of SHAKE128 XOF. Squeezes full blocks of SHAKE128_RATE bytes
53
+ * each. Modifies the state. Can be called multiple times to keep squeezing,
54
+ * i.e., is incremental.
62
55
  *
63
- * Arguments: - uint8_t *output: pointer to output blocks
64
- * - size_t nblocks: number of blocks to be squeezed (written
65
- * to output)
66
- * - mlk_shake128ctx *state: pointer to in/output Keccak state
67
- **************************************************/
56
+ * @param[out] output Output blocks.
57
+ * @param nblocks Number of blocks to be squeezed (written to output).
58
+ * @param[in,out] state Keccak state.
59
+ */
68
60
  void mlk_shake128_squeezeblocks(uint8_t *output, size_t nblocks,
69
61
  mlk_shake128ctx *state)
70
62
  __contract__(
@@ -83,16 +75,14 @@ void mlk_shake128_release(mlk_shake128ctx *state);
83
75
  /* One-stop SHAKE256 call. Aliasing between input and
84
76
  * output is not permitted */
85
77
  #define mlk_shake256 MLK_NAMESPACE(shake256)
86
- /*************************************************
87
- * Name: mlk_shake256
88
- *
89
- * Description: SHAKE256 XOF with non-incremental API
78
+ /**
79
+ * SHAKE256 XOF with non-incremental API.
90
80
  *
91
- * Arguments: - uint8_t *output: pointer to output
92
- * - size_t outlen: requested output length in bytes
93
- * - const uint8_t *input: pointer to input
94
- * - size_t inlen: length of input in bytes
95
- **************************************************/
81
+ * @param[out] output Output buffer.
82
+ * @param outlen Requested output length in bytes.
83
+ * @param[in] input Input buffer.
84
+ * @param inlen Length of input in bytes.
85
+ */
96
86
  void mlk_shake256(uint8_t *output, size_t outlen, const uint8_t *input,
97
87
  size_t inlen)
98
88
  __contract__(
@@ -107,15 +97,13 @@ __contract__(
107
97
  * output is not permitted */
108
98
  #define SHA3_256_HASHBYTES 32
109
99
  #define mlk_sha3_256 MLK_NAMESPACE(sha3_256)
110
- /*************************************************
111
- * Name: mlk_sha3_256
112
- *
113
- * Description: SHA3-256 with non-incremental API
100
+ /**
101
+ * SHA3-256 with non-incremental API.
114
102
  *
115
- * Arguments: - uint8_t *output: pointer to output
116
- * - const uint8_t *input: pointer to input
117
- * - size_t inlen: length of input in bytes
118
- **************************************************/
103
+ * @param[out] output Output buffer.
104
+ * @param[in] input Input buffer.
105
+ * @param inlen Length of input in bytes.
106
+ */
119
107
  void mlk_sha3_256(uint8_t *output, const uint8_t *input, size_t inlen)
120
108
  __contract__(
121
109
  requires(inlen <= MLK_MAX_BUFFER_SIZE)
@@ -128,15 +116,13 @@ __contract__(
128
116
  * output is not permitted */
129
117
  #define SHA3_512_HASHBYTES 64
130
118
  #define mlk_sha3_512 MLK_NAMESPACE(sha3_512)
131
- /*************************************************
132
- * Name: mlk_sha3_512
119
+ /**
120
+ * SHA3-512 with non-incremental API.
133
121
  *
134
- * Description: SHA3-512 with non-incremental API
135
- *
136
- * Arguments: - uint8_t *output: pointer to output
137
- * - const uint8_t *input: pointer to input
138
- * - size_t inlen: length of input in bytes
139
- **************************************************/
122
+ * @param[out] output Output buffer.
123
+ * @param[in] input Input buffer.
124
+ * @param inlen Length of input in bytes.
125
+ */
140
126
  void mlk_sha3_512(uint8_t *output, const uint8_t *input, size_t inlen)
141
127
  __contract__(
142
128
  requires(inlen <= MLK_MAX_BUFFER_SIZE)
@@ -29,6 +29,7 @@ static void mlk_keccak_absorb_once_x4(uint64_t *s, unsigned r,
29
29
  __contract__(
30
30
  requires(inlen <= MLK_MAX_BUFFER_SIZE)
31
31
  requires(memory_no_alias(s, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY))
32
+ requires(r > 0)
32
33
  requires(r <= sizeof(uint64_t) * MLK_KECCAK_LANES)
33
34
  requires(memory_no_alias(in0, inlen))
34
35
  requires(memory_no_alias(in1, inlen))
@@ -43,7 +44,8 @@ __contract__(
43
44
  invariant(in0 == loop_entry(in0) + (loop_entry(inlen) - inlen))
44
45
  invariant(in1 == loop_entry(in1) + (loop_entry(inlen) - inlen))
45
46
  invariant(in2 == loop_entry(in2) + (loop_entry(inlen) - inlen))
46
- invariant(in3 == loop_entry(in3) + (loop_entry(inlen) - inlen)))
47
+ invariant(in3 == loop_entry(in3) + (loop_entry(inlen) - inlen))
48
+ decreases(inlen))
47
49
  {
48
50
  mlk_keccakf1600x4_xor_bytes(s, in0, in1, in2, in3, 0, r);
49
51
  mlk_keccakf1600x4_permute(s);
@@ -93,27 +95,24 @@ __contract__(
93
95
  assigns(memory_slice(out2, nblocks * r))
94
96
  assigns(memory_slice(out3, nblocks * r)))
95
97
  {
98
+ size_t current_offset = 0;
96
99
  while (nblocks > 0)
97
100
  __loop__(
98
- assigns(out0, out1, out2, out3, nblocks,
101
+ assigns(nblocks, current_offset,
99
102
  memory_slice(s, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY),
100
103
  memory_slice(out0, nblocks * r),
101
104
  memory_slice(out1, nblocks * r),
102
105
  memory_slice(out2, nblocks * r),
103
106
  memory_slice(out3, nblocks * r))
104
- invariant(nblocks <= loop_entry(nblocks) &&
105
- out0 == loop_entry(out0) + r * (loop_entry(nblocks) - nblocks) &&
106
- out1 == loop_entry(out1) + r * (loop_entry(nblocks) - nblocks) &&
107
- out2 == loop_entry(out2) + r * (loop_entry(nblocks) - nblocks) &&
108
- out3 == loop_entry(out3) + r * (loop_entry(nblocks) - nblocks)))
107
+ invariant(nblocks <= loop_entry(nblocks))
108
+ invariant(current_offset == (loop_entry(nblocks) - nblocks) * r)
109
+ decreases(nblocks))
109
110
  {
110
111
  mlk_keccakf1600x4_permute(s);
111
- mlk_keccakf1600x4_extract_bytes(s, out0, out1, out2, out3, 0, r);
112
-
113
- out0 += r;
114
- out1 += r;
115
- out2 += r;
116
- out3 += r;
112
+ mlk_keccakf1600x4_extract_bytes(
113
+ s, &out0[current_offset], &out1[current_offset], &out2[current_offset],
114
+ &out3[current_offset], 0, r);
115
+ current_offset += r;
117
116
  nblocks--;
118
117
  }
119
118
  }
@@ -163,8 +162,8 @@ static void mlk_shake256x4_squeezeblocks(uint8_t *out0, uint8_t *out1,
163
162
  }
164
163
 
165
164
  void mlk_shake256x4(uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3,
166
- size_t outlen, uint8_t *in0, uint8_t *in1, uint8_t *in2,
167
- uint8_t *in3, size_t inlen)
165
+ size_t outlen, const uint8_t *in0, const uint8_t *in1,
166
+ const uint8_t *in2, const uint8_t *in3, size_t inlen)
168
167
  {
169
168
  mlk_shake256x4_ctx statex;
170
169
  size_t nblocks = outlen / SHAKE256_RATE;
@@ -12,10 +12,11 @@
12
12
  #include "fips202.h"
13
13
  #include "keccakf1600.h"
14
14
 
15
- /* Context for non-incremental API */
15
+ /** Context for the non-incremental 4-way SHAKE128 API. */
16
16
  typedef struct
17
17
  {
18
- uint64_t ctx[MLK_KECCAK_LANES * MLK_KECCAK_WAY];
18
+ uint64_t ctx[MLK_KECCAK_LANES *
19
+ MLK_KECCAK_WAY]; /**< 4-way Keccak state, stored sequentially. */
19
20
  } MLK_ALIGN mlk_shake128x4ctx;
20
21
 
21
22
  #define mlk_shake128x4_absorb_once MLK_NAMESPACE(shake128x4_absorb_once)
@@ -58,8 +59,8 @@ void mlk_shake128x4_release(mlk_shake128x4ctx *state);
58
59
 
59
60
  #define mlk_shake256x4 MLK_NAMESPACE(shake256x4)
60
61
  void mlk_shake256x4(uint8_t *out0, uint8_t *out1, uint8_t *out2, uint8_t *out3,
61
- size_t outlen, uint8_t *in0, uint8_t *in1, uint8_t *in2,
62
- uint8_t *in3, size_t inlen)
62
+ size_t outlen, const uint8_t *in0, const uint8_t *in1,
63
+ const uint8_t *in2, const uint8_t *in3, size_t inlen)
63
64
  __contract__(
64
65
  requires(inlen <= MLK_MAX_BUFFER_SIZE)
65
66
  requires(outlen <= MLK_MAX_BUFFER_SIZE)
@@ -31,7 +31,7 @@
31
31
  #if !defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)
32
32
 
33
33
  #define MLK_KECCAK_NROUNDS 24
34
- #define MLK_KECCAK_ROL(a, offset) ((a << offset) ^ (a >> (64 - offset)))
34
+ #define MLK_KECCAK_ROL(a, offset) (((a) << (offset)) ^ ((a) >> (64 - (offset))))
35
35
 
36
36
  void mlk_keccakf1600_extract_bytes(uint64_t *state, unsigned char *data,
37
37
  unsigned offset, unsigned length)
@@ -40,14 +40,16 @@ void mlk_keccakf1600_extract_bytes(uint64_t *state, unsigned char *data,
40
40
  #if defined(MLK_SYS_LITTLE_ENDIAN)
41
41
  uint8_t *state_ptr = (uint8_t *)state + offset;
42
42
  for (i = 0; i < length; i++)
43
- __loop__(invariant(i <= length))
43
+ __loop__(invariant(i <= length)
44
+ decreases(length - i))
44
45
  {
45
46
  data[i] = state_ptr[i];
46
47
  }
47
48
  #else /* MLK_SYS_LITTLE_ENDIAN */
48
49
  /* Portable version */
49
50
  for (i = 0; i < length; i++)
50
- __loop__(invariant(i <= length))
51
+ __loop__(invariant(i <= length)
52
+ decreases(length - i))
51
53
  {
52
54
  data[i] = (state[(offset + i) >> 3] >> (8 * ((offset + i) & 0x07))) & 0xFF;
53
55
  }
@@ -61,14 +63,16 @@ void mlk_keccakf1600_xor_bytes(uint64_t *state, const unsigned char *data,
61
63
  #if defined(MLK_SYS_LITTLE_ENDIAN)
62
64
  uint8_t *state_ptr = (uint8_t *)state + offset;
63
65
  for (i = 0; i < length; i++)
64
- __loop__(invariant(i <= length))
66
+ __loop__(invariant(i <= length)
67
+ decreases(length - i))
65
68
  {
66
69
  state_ptr[i] ^= data[i];
67
70
  }
68
71
  #else /* MLK_SYS_LITTLE_ENDIAN */
69
72
  /* Portable version */
70
73
  for (i = 0; i < length; i++)
71
- __loop__(invariant(i <= length))
74
+ __loop__(invariant(i <= length)
75
+ decreases(length - i))
72
76
  {
73
77
  state[(offset + i) >> 3] ^= (uint64_t)data[i]
74
78
  << (8 * ((offset + i) & 0x07));
@@ -82,6 +86,19 @@ static void mlk_keccakf1600x4_extract_bytes_c(uint64_t *state,
82
86
  unsigned char *data2,
83
87
  unsigned char *data3,
84
88
  unsigned offset, unsigned length)
89
+ __contract__(
90
+ requires(0 <= offset && offset <= MLK_KECCAK_LANES * sizeof(uint64_t) &&
91
+ 0 <= length && length <= MLK_KECCAK_LANES * sizeof(uint64_t) - offset)
92
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY))
93
+ requires(memory_no_alias(data0, length))
94
+ requires(memory_no_alias(data1, length))
95
+ requires(memory_no_alias(data2, length))
96
+ requires(memory_no_alias(data3, length))
97
+ assigns(memory_slice(data0, length))
98
+ assigns(memory_slice(data1, length))
99
+ assigns(memory_slice(data2, length))
100
+ assigns(memory_slice(data3, length))
101
+ )
85
102
  {
86
103
  mlk_keccakf1600_extract_bytes(state + MLK_KECCAK_LANES * 0, data0, offset,
87
104
  length);
@@ -116,6 +133,20 @@ static void mlk_keccakf1600x4_xor_bytes_c(uint64_t *state,
116
133
  const unsigned char *data2,
117
134
  const unsigned char *data3,
118
135
  unsigned offset, unsigned length)
136
+ __contract__(
137
+ requires(0 <= offset && offset <= MLK_KECCAK_LANES * sizeof(uint64_t) &&
138
+ 0 <= length && length <= MLK_KECCAK_LANES * sizeof(uint64_t) - offset)
139
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY))
140
+ requires(memory_no_alias(data0, length))
141
+ /* Case 1: all input buffers are distinct; Case 2: All input buffers are the same */
142
+ requires((data0 == data1 &&
143
+ data0 == data2 &&
144
+ data0 == data3) ||
145
+ (memory_no_alias(data1, length) &&
146
+ memory_no_alias(data2, length) &&
147
+ memory_no_alias(data3, length)))
148
+ assigns(memory_slice(state, sizeof(uint64_t) * MLK_KECCAK_LANES * MLK_KECCAK_WAY))
149
+ )
119
150
  {
120
151
  mlk_keccakf1600_xor_bytes(state + MLK_KECCAK_LANES * 0, data0, offset,
121
152
  length);
@@ -175,6 +206,10 @@ static const uint64_t mlk_KeccakF_RoundConstants[MLK_KECCAK_NROUNDS] = {
175
206
 
176
207
  MLK_STATIC_TESTABLE
177
208
  void mlk_keccakf1600_permute_c(uint64_t *state)
209
+ __contract__(
210
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLK_KECCAK_LANES))
211
+ assigns(memory_slice(state, sizeof(uint64_t) * MLK_KECCAK_LANES))
212
+ )
178
213
  {
179
214
  unsigned round;
180
215
 
@@ -219,7 +254,8 @@ void mlk_keccakf1600_permute_c(uint64_t *state)
219
254
  Asu = state[24];
220
255
 
221
256
  for (round = 0; round < MLK_KECCAK_NROUNDS; round += 2)
222
- __loop__(invariant(round <= MLK_KECCAK_NROUNDS && round % 2 == 0))
257
+ __loop__(invariant(round <= MLK_KECCAK_NROUNDS && round % 2 == 0)
258
+ decreases(MLK_KECCAK_NROUNDS - round))
223
259
  {
224
260
  /* prepareTheta */
225
261
  BCa = Aba ^ Aga ^ Aka ^ Ama ^ Asa;
@@ -10,56 +10,67 @@
10
10
 
11
11
  #define mlk_keccakf1600_round_constants \
12
12
  MLK_NAMESPACE(keccakf1600_round_constants)
13
- extern const uint64_t mlk_keccakf1600_round_constants[];
13
+ MLK_INTERNAL_DATA_DECLARATION const uint64_t
14
+ mlk_keccakf1600_round_constants[24];
14
15
 
15
- #define mlk_keccak_f1600_x1_scalar_asm MLK_NAMESPACE(keccak_f1600_x1_scalar_asm)
16
- void mlk_keccak_f1600_x1_scalar_asm(uint64_t state[25], const uint64_t rc[24])
16
+ #define mlk_keccak_f1600_x1_scalar_aarch64_asm \
17
+ MLK_NAMESPACE(keccak_f1600_x1_scalar_aarch64_asm)
18
+ void mlk_keccak_f1600_x1_scalar_aarch64_asm(uint64_t state[25],
19
+ const uint64_t rc[24])
17
20
  /* This must be kept in sync with the HOL-Light specification
18
- * in proofs/hol_light/aarch64/proofs/keccak_f1600_x1_scalar.ml */
21
+ * in proofs/hol_light/aarch64/proofs/keccak_f1600_x1_scalar_aarch64_asm.ml */
19
22
  __contract__(
20
23
  requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 1))
21
24
  requires(rc == mlk_keccakf1600_round_constants)
22
25
  assigns(memory_slice(state, sizeof(uint64_t) * 25 * 1))
23
26
  );
24
27
 
25
- #define mlk_keccak_f1600_x1_v84a_asm MLK_NAMESPACE(keccak_f1600_x1_v84a_asm)
26
- void mlk_keccak_f1600_x1_v84a_asm(uint64_t state[25], const uint64_t rc[24])
28
+ #define mlk_keccak_f1600_x1_v84a_aarch64_asm \
29
+ MLK_NAMESPACE(keccak_f1600_x1_v84a_aarch64_asm)
30
+ void mlk_keccak_f1600_x1_v84a_aarch64_asm(uint64_t state[25],
31
+ const uint64_t rc[24])
27
32
  /* This must be kept in sync with the HOL-Light specification
28
- * in proofs/hol_light/aarch64/proofs/keccak_f1600_x1_v84a.ml */
33
+ * in proofs/hol_light/aarch64/proofs/keccak_f1600_x1_v84a_aarch64_asm.ml */
29
34
  __contract__(
30
35
  requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 1))
31
36
  requires(rc == mlk_keccakf1600_round_constants)
32
37
  assigns(memory_slice(state, sizeof(uint64_t) * 25 * 1))
33
38
  );
34
39
 
35
- #define mlk_keccak_f1600_x2_v84a_asm MLK_NAMESPACE(keccak_f1600_x2_v84a_asm)
36
- void mlk_keccak_f1600_x2_v84a_asm(uint64_t state[50], const uint64_t rc[24])
40
+ #define mlk_keccak_f1600_x2_v84a_aarch64_asm \
41
+ MLK_NAMESPACE(keccak_f1600_x2_v84a_aarch64_asm)
42
+ void mlk_keccak_f1600_x2_v84a_aarch64_asm(uint64_t state[50],
43
+ const uint64_t rc[24])
37
44
  /* This must be kept in sync with the HOL-Light specification
38
- * in proofs/hol_light/aarch64/proofs/keccak_f1600_x2_v84a.ml */
45
+ * in proofs/hol_light/aarch64/proofs/keccak_f1600_x2_v84a_aarch64_asm.ml */
39
46
  __contract__(
40
47
  requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 2))
41
48
  requires(rc == mlk_keccakf1600_round_constants)
42
49
  assigns(memory_slice(state, sizeof(uint64_t) * 25 * 2))
43
50
  );
44
51
 
45
- #define mlk_keccak_f1600_x4_v8a_scalar_hybrid_asm \
46
- MLK_NAMESPACE(keccak_f1600_x4_v8a_scalar_hybrid_asm)
47
- void mlk_keccak_f1600_x4_v8a_scalar_hybrid_asm(uint64_t state[100],
48
- const uint64_t rc[24])
52
+ #define mlk_keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm \
53
+ MLK_NAMESPACE(keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm)
54
+ void mlk_keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm(uint64_t state[100],
55
+ const uint64_t rc[24])
49
56
  /* This must be kept in sync with the HOL-Light specification
50
- * in proofs/hol_light/aarch64/proofs/keccak_f1600_x4_v8a_scalar.ml */
57
+ * in
58
+ * proofs/hol_light/aarch64/proofs/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.ml
59
+ */
51
60
  __contract__(
52
61
  requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 4))
53
62
  requires(rc == mlk_keccakf1600_round_constants)
54
63
  assigns(memory_slice(state, sizeof(uint64_t) * 25 * 4))
55
64
  );
56
65
 
57
- #define mlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm \
58
- MLK_NAMESPACE(keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm)
59
- void mlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm(uint64_t state[100],
60
- const uint64_t rc[24])
66
+ #define mlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm \
67
+ MLK_NAMESPACE(keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm)
68
+ void mlk_keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm(
69
+ uint64_t state[100], const uint64_t rc[24])
61
70
  /* This must be kept in sync with the HOL-Light specification
62
- * in proofs/hol_light/aarch64/proofs/keccak_f1600_x4_v8a_v84a_scalar.ml */
71
+ * in
72
+ * proofs/hol_light/aarch64/proofs/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.ml
73
+ */
63
74
  __contract__(
64
75
  requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 4))
65
76
  requires(rc == mlk_keccakf1600_round_constants)