mldsa_gh 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +88 -0
  4. data/ext/mldsa_gh_native/extconf.rb +14 -0
  5. data/ext/mldsa_gh_native/mldsa_gh_native.c +222 -0
  6. data/ext/mldsa_gh_native/mldsa_gh_native_all.c +24 -0
  7. data/ext/mldsa_gh_native/mldsa_gh_native_all.h +26 -0
  8. data/ext/mldsa_gh_native/vendor/mldsa-native/BUILDING.md +108 -0
  9. data/ext/mldsa_gh_native/vendor/mldsa-native/LICENSE +305 -0
  10. data/ext/mldsa_gh_native/vendor/mldsa-native/README.md +247 -0
  11. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/README.md +23 -0
  12. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native.c +803 -0
  13. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native.h +956 -0
  14. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native_asm.S +830 -0
  15. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/mldsa_native_config.h +855 -0
  16. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/cbmc.h +233 -0
  17. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/common.h +301 -0
  18. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/context.h +152 -0
  19. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/ct.c +21 -0
  20. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/ct.h +373 -0
  21. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/debug.c +75 -0
  22. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/debug.h +125 -0
  23. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202.c +270 -0
  24. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202.h +224 -0
  25. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +187 -0
  26. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +125 -0
  27. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +510 -0
  28. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +110 -0
  29. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +85 -0
  30. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +69 -0
  31. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +378 -0
  32. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +207 -0
  33. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +262 -0
  34. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +1080 -0
  35. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +990 -0
  36. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +47 -0
  37. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +27 -0
  38. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +36 -0
  39. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +40 -0
  40. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +32 -0
  41. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +37 -0
  42. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/api.h +129 -0
  43. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/README.md +10 -0
  44. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +67 -0
  45. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +37 -0
  46. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +717 -0
  47. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +42 -0
  48. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_extract_bytes_mve.S +334 -0
  49. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_state_xor_bytes_mve.S +355 -0
  50. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +53 -0
  51. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +35 -0
  52. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/keccak_f1600_x4_avx2.h +34 -0
  53. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +45 -0
  54. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +488 -0
  55. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +52 -0
  56. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +314 -0
  57. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +248 -0
  58. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +367 -0
  59. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_intt_aarch64_asm.S +786 -0
  60. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_ntt_aarch64_asm.S +686 -0
  61. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_pointwise_montgomery_aarch64_asm.S +106 -0
  62. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_caddq_aarch64_asm.S +69 -0
  63. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_chknorm_aarch64_asm.S +76 -0
  64. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_32_aarch64_asm.S +108 -0
  65. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_decompose_88_aarch64_asm.S +108 -0
  66. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_32_aarch64_asm.S +125 -0
  67. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_poly_use_hint_88_aarch64_asm.S +133 -0
  68. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +157 -0
  69. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +173 -0
  70. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +205 -0
  71. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_17_aarch64_asm.S +103 -0
  72. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_polyz_unpack_19_aarch64_asm.S +100 -0
  73. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_aarch64_asm.S +222 -0
  74. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta2_aarch64_asm.S +170 -0
  75. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/mldsa_rej_uniform_eta4_aarch64_asm.S +163 -0
  76. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +52 -0
  77. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +547 -0
  78. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +63 -0
  79. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/api.h +617 -0
  80. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/meta.h +24 -0
  81. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +323 -0
  82. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +330 -0
  83. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +157 -0
  84. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +27 -0
  85. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_intt_avx2_asm.S +2333 -0
  86. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_ntt_avx2_asm.S +2405 -0
  87. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_nttunpack_avx2_asm.S +254 -0
  88. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l4_avx2_asm.S +173 -0
  89. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l5_avx2_asm.S +189 -0
  90. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_acc_l7_avx2_asm.S +221 -0
  91. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_pointwise_avx2_asm.S +158 -0
  92. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_caddq_avx2_asm.S +199 -0
  93. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_chknorm_avx2_asm.S +176 -0
  94. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_32_avx2_asm.S +490 -0
  95. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_decompose_88_avx2_asm.S +489 -0
  96. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_32_avx2_asm.S +123 -0
  97. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_poly_use_hint_88_avx2_asm.S +125 -0
  98. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_17_avx2_asm.S +355 -0
  99. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_polyz_unpack_19_avx2_asm.S +355 -0
  100. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_avx2_asm.S +132 -0
  101. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta2_avx2_asm.S +205 -0
  102. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/mldsa_rej_uniform_eta4_avx2_asm.S +176 -0
  103. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +161 -0
  104. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/packing.c +213 -0
  105. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/packing.h +277 -0
  106. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/params.h +153 -0
  107. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly.c +1066 -0
  108. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly.h +464 -0
  109. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly_kl.c +910 -0
  110. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/poly_kl.h +367 -0
  111. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec.c +509 -0
  112. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec.h +435 -0
  113. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +311 -0
  114. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +652 -0
  115. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/randombytes.h +26 -0
  116. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/reduce.h +144 -0
  117. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/rounding.h +265 -0
  118. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sign.c +1720 -0
  119. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sign.h +850 -0
  120. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/symmetric.h +68 -0
  121. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/sys.h +327 -0
  122. data/ext/mldsa_gh_native/vendor/mldsa-native/mldsa/src/zetas.inc +55 -0
  123. data/lib/mldsa/parameter_set.rb +82 -0
  124. data/lib/mldsa/signing_key.rb +147 -0
  125. data/lib/mldsa/verify_key.rb +72 -0
  126. data/lib/mldsa/version.rb +7 -0
  127. data/lib/mldsa_gh.rb +93 -0
  128. metadata +225 -0
@@ -0,0 +1,207 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * Copyright (c) The mldsa-native project authors
4
+ * Copyright (c) 2021-2022 Arm Limited
5
+ * Copyright (c) 2022 Matthias Kannwischer
6
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
7
+ */
8
+
9
+ /* References
10
+ * ==========
11
+ *
12
+ * - [HYBRID]
13
+ * Hybrid scalar/vector implementations of Keccak and SPHINCS+ on AArch64
14
+ * Becker, Kannwischer
15
+ * https://eprint.iacr.org/2022/1243
16
+ */
17
+
18
+ /*yaml
19
+ Name: keccak_f1600_x1_v84a_aarch64_asm
20
+ Description: AArch64 ARMv8.4-A implementation of Keccak-f[1600] permutation for single state
21
+ Signature: void mld_keccak_f1600_x1_v84a_aarch64_asm(uint64_t state[25], const uint64_t rc[24])
22
+ ABI:
23
+ Architecture: aarch64
24
+ CallingConvention: AAPCS64
25
+ Features: [NEON, SHA3]
26
+ x0:
27
+ type: buffer
28
+ size_bytes: 200
29
+ permissions: read/write
30
+ c_parameter: uint64_t state[25]
31
+ description: Keccak state (25 x uint64_t)
32
+ x1:
33
+ type: buffer
34
+ size_bytes: 192
35
+ permissions: read-only
36
+ c_parameter: uint64_t const *rc
37
+ description: Round constants (24 x uint64_t)
38
+ Stack:
39
+ bytes: 64
40
+ description: register preservation
41
+ */
42
+
43
+ //
44
+ // Author: Hanno Becker <hanno.becker@arm.com>
45
+ // Author: Matthias Kannwischer <matthias@kannwischer.eu>
46
+ //
47
+ // This implementation is essentially from the paper @[HYBRID].
48
+ // The only difference is interleaving/deinterleaving of Keccak state
49
+ // during load and store, so that the caller need not do this.
50
+ //
51
+
52
+ #include "../../../../common.h"
53
+ #if defined(MLD_FIPS202_AARCH64_NEED_X1_V84A) && \
54
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
55
+
56
+ #if defined(__ARM_FEATURE_SHA3)
57
+
58
+ /*
59
+ * WARNING: This file is auto-derived from the mldsa-native source file
60
+ * dev/fips202/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
61
+ */
62
+
63
+ .text
64
+ .balign 4
65
+ .global MLD_ASM_NAMESPACE(keccak_f1600_x1_v84a_aarch64_asm)
66
+ MLD_ASM_FN_SYMBOL(keccak_f1600_x1_v84a_aarch64_asm)
67
+
68
+ .cfi_startproc
69
+ sub sp, sp, #0x40
70
+ .cfi_adjust_cfa_offset 0x40
71
+ stp d8, d9, [sp]
72
+ .cfi_rel_offset d8, 0x0
73
+ .cfi_rel_offset d9, 0x8
74
+ stp d10, d11, [sp, #0x10]
75
+ .cfi_rel_offset d10, 0x10
76
+ .cfi_rel_offset d11, 0x18
77
+ stp d12, d13, [sp, #0x20]
78
+ .cfi_rel_offset d12, 0x20
79
+ .cfi_rel_offset d13, 0x28
80
+ stp d14, d15, [sp, #0x30]
81
+ .cfi_rel_offset d14, 0x30
82
+ .cfi_rel_offset d15, 0x38
83
+ ldp d0, d1, [x0]
84
+ ldp d2, d3, [x0, #0x10]
85
+ ldp d4, d5, [x0, #0x20]
86
+ ldp d6, d7, [x0, #0x30]
87
+ ldp d8, d9, [x0, #0x40]
88
+ ldp d10, d11, [x0, #0x50]
89
+ ldp d12, d13, [x0, #0x60]
90
+ ldp d14, d15, [x0, #0x70]
91
+ ldp d16, d17, [x0, #0x80]
92
+ ldp d18, d19, [x0, #0x90]
93
+ ldp d20, d21, [x0, #0xa0]
94
+ ldp d22, d23, [x0, #0xb0]
95
+ ldr d24, [x0, #0xc0]
96
+ mov x2, #0x18 // =24
97
+
98
+ Lmld_keccak_f1600_x1_v84a_loop:
99
+ eor3 v30.16b, v0.16b, v5.16b, v10.16b
100
+ eor3 v29.16b, v1.16b, v6.16b, v11.16b
101
+ eor3 v28.16b, v2.16b, v7.16b, v12.16b
102
+ eor3 v27.16b, v3.16b, v8.16b, v13.16b
103
+ eor3 v26.16b, v4.16b, v9.16b, v14.16b
104
+ eor3 v30.16b, v30.16b, v15.16b, v20.16b
105
+ eor3 v29.16b, v29.16b, v16.16b, v21.16b
106
+ eor3 v28.16b, v28.16b, v17.16b, v22.16b
107
+ eor3 v27.16b, v27.16b, v18.16b, v23.16b
108
+ eor3 v26.16b, v26.16b, v19.16b, v24.16b
109
+ rax1 v25.2d, v30.2d, v28.2d
110
+ rax1 v28.2d, v28.2d, v26.2d
111
+ rax1 v26.2d, v26.2d, v29.2d
112
+ rax1 v29.2d, v29.2d, v27.2d
113
+ rax1 v27.2d, v27.2d, v30.2d
114
+ eor v30.16b, v0.16b, v26.16b
115
+ xar v0.2d, v2.2d, v29.2d, #0x2
116
+ xar v2.2d, v12.2d, v29.2d, #0x15
117
+ xar v12.2d, v13.2d, v28.2d, #0x27
118
+ xar v13.2d, v19.2d, v27.2d, #0x38
119
+ xar v19.2d, v23.2d, v28.2d, #0x8
120
+ xar v23.2d, v15.2d, v26.2d, #0x17
121
+ xar v15.2d, v1.2d, v25.2d, #0x3f
122
+ xar v1.2d, v8.2d, v28.2d, #0x9
123
+ xar v8.2d, v16.2d, v25.2d, #0x13
124
+ xar v16.2d, v7.2d, v29.2d, #0x3a
125
+ xar v7.2d, v10.2d, v26.2d, #0x3d
126
+ xar v10.2d, v3.2d, v28.2d, #0x24
127
+ xar v3.2d, v18.2d, v28.2d, #0x2b
128
+ xar v18.2d, v17.2d, v29.2d, #0x31
129
+ xar v17.2d, v11.2d, v25.2d, #0x36
130
+ xar v11.2d, v9.2d, v27.2d, #0x2c
131
+ xar v9.2d, v22.2d, v29.2d, #0x3
132
+ xar v22.2d, v14.2d, v27.2d, #0x19
133
+ xar v14.2d, v20.2d, v26.2d, #0x2e
134
+ xar v20.2d, v4.2d, v27.2d, #0x25
135
+ xar v4.2d, v24.2d, v27.2d, #0x32
136
+ xar v24.2d, v21.2d, v25.2d, #0x3e
137
+ xar v21.2d, v5.2d, v26.2d, #0x1c
138
+ xar v27.2d, v6.2d, v25.2d, #0x14
139
+ ld1r { v31.2d }, [x1], #8
140
+ bcax v5.16b, v10.16b, v7.16b, v11.16b
141
+ bcax v6.16b, v11.16b, v8.16b, v7.16b
142
+ bcax v7.16b, v7.16b, v9.16b, v8.16b
143
+ bcax v8.16b, v8.16b, v10.16b, v9.16b
144
+ bcax v9.16b, v9.16b, v11.16b, v10.16b
145
+ bcax v10.16b, v15.16b, v12.16b, v16.16b
146
+ bcax v11.16b, v16.16b, v13.16b, v12.16b
147
+ bcax v12.16b, v12.16b, v14.16b, v13.16b
148
+ bcax v13.16b, v13.16b, v15.16b, v14.16b
149
+ bcax v14.16b, v14.16b, v16.16b, v15.16b
150
+ bcax v15.16b, v20.16b, v17.16b, v21.16b
151
+ bcax v16.16b, v21.16b, v18.16b, v17.16b
152
+ bcax v17.16b, v17.16b, v19.16b, v18.16b
153
+ bcax v18.16b, v18.16b, v20.16b, v19.16b
154
+ bcax v19.16b, v19.16b, v21.16b, v20.16b
155
+ bcax v20.16b, v0.16b, v22.16b, v1.16b
156
+ bcax v21.16b, v1.16b, v23.16b, v22.16b
157
+ bcax v22.16b, v22.16b, v24.16b, v23.16b
158
+ bcax v23.16b, v23.16b, v0.16b, v24.16b
159
+ bcax v24.16b, v24.16b, v1.16b, v0.16b
160
+ bcax v0.16b, v30.16b, v2.16b, v27.16b
161
+ bcax v1.16b, v27.16b, v3.16b, v2.16b
162
+ bcax v2.16b, v2.16b, v4.16b, v3.16b
163
+ bcax v3.16b, v3.16b, v30.16b, v4.16b
164
+ bcax v4.16b, v4.16b, v27.16b, v30.16b
165
+ eor v0.16b, v0.16b, v31.16b
166
+ sub x2, x2, #0x1
167
+ cbnz x2, Lmld_keccak_f1600_x1_v84a_loop
168
+ stp d0, d1, [x0]
169
+ stp d2, d3, [x0, #0x10]
170
+ stp d4, d5, [x0, #0x20]
171
+ stp d6, d7, [x0, #0x30]
172
+ stp d8, d9, [x0, #0x40]
173
+ stp d10, d11, [x0, #0x50]
174
+ stp d12, d13, [x0, #0x60]
175
+ stp d14, d15, [x0, #0x70]
176
+ stp d16, d17, [x0, #0x80]
177
+ stp d18, d19, [x0, #0x90]
178
+ stp d20, d21, [x0, #0xa0]
179
+ stp d22, d23, [x0, #0xb0]
180
+ str d24, [x0, #0xc0]
181
+ ldp d8, d9, [sp]
182
+ .cfi_restore d8
183
+ .cfi_restore d9
184
+ ldp d10, d11, [sp, #0x10]
185
+ .cfi_restore d10
186
+ .cfi_restore d11
187
+ ldp d12, d13, [sp, #0x20]
188
+ .cfi_restore d12
189
+ .cfi_restore d13
190
+ ldp d14, d15, [sp, #0x30]
191
+ .cfi_restore d14
192
+ .cfi_restore d15
193
+ add sp, sp, #0x40
194
+ .cfi_adjust_cfa_offset -0x40
195
+ ret
196
+ .cfi_endproc
197
+
198
+ MLD_ASM_FN_SIZE(keccak_f1600_x1_v84a_aarch64_asm)
199
+
200
+ #endif /* __ARM_FEATURE_SHA3 */
201
+
202
+ #endif /* MLD_FIPS202_AARCH64_NEED_X1_V84A && !MLD_CONFIG_MULTILEVEL_NO_SHARED \
203
+ */
204
+
205
+ #if defined(__ELF__)
206
+ .section .note.GNU-stack,"",%progbits
207
+ #endif
@@ -0,0 +1,262 @@
1
+ /*
2
+ * Copyright (c) The mlkem-native project authors
3
+ * Copyright (c) The mldsa-native project authors
4
+ * Copyright (c) 2021-2022 Arm Limited
5
+ * Copyright (c) 2022 Matthias Kannwischer
6
+ * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
7
+ */
8
+
9
+ /* References
10
+ * ==========
11
+ *
12
+ * - [HYBRID]
13
+ * Hybrid scalar/vector implementations of Keccak and SPHINCS+ on AArch64
14
+ * Becker, Kannwischer
15
+ * https://eprint.iacr.org/2022/1243
16
+ */
17
+
18
+ /*yaml
19
+ Name: keccak_f1600_x2_v84a_aarch64_asm
20
+ Description: AArch64 ARMv8.4-A implementation of Keccak-f[1600] permutation for two sequential states
21
+ Signature: void mld_keccak_f1600_x2_v84a_aarch64_asm(uint64_t state[50], const uint64_t rc[24])
22
+ ABI:
23
+ Architecture: aarch64
24
+ CallingConvention: AAPCS64
25
+ Features: [NEON, SHA3]
26
+ x0:
27
+ type: buffer
28
+ size_bytes: 400
29
+ permissions: read/write
30
+ c_parameter: uint64_t state[50]
31
+ description: Two sequential Keccak states (state0[25], state1[25])
32
+ x1:
33
+ type: buffer
34
+ size_bytes: 192
35
+ permissions: read-only
36
+ c_parameter: uint64_t const *rc
37
+ description: Round constants (24 x uint64_t)
38
+ Stack:
39
+ bytes: 64
40
+ description: register preservation
41
+ */
42
+
43
+ //
44
+ // Author: Hanno Becker <hanno.becker@arm.com>
45
+ // Author: Matthias Kannwischer <matthias@kannwischer.eu>
46
+ //
47
+ // This implementation is essentially from the paper @[HYBRID].
48
+ // The only difference is interleaving/deinterleaving of Keccak state
49
+ // during load and store, so that the caller need not do this.
50
+ //
51
+
52
+ #include "../../../../common.h"
53
+ #if defined(MLD_FIPS202_AARCH64_NEED_X2_V84A) && \
54
+ !defined(MLD_CONFIG_MULTILEVEL_NO_SHARED)
55
+
56
+ #if defined(__ARM_FEATURE_SHA3)
57
+
58
+ /*
59
+ * WARNING: This file is auto-derived from the mldsa-native source file
60
+ * dev/fips202/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S using scripts/simpasm. Do not modify it directly.
61
+ */
62
+
63
+ .text
64
+ .balign 4
65
+ .global MLD_ASM_NAMESPACE(keccak_f1600_x2_v84a_aarch64_asm)
66
+ MLD_ASM_FN_SYMBOL(keccak_f1600_x2_v84a_aarch64_asm)
67
+
68
+ .cfi_startproc
69
+ sub sp, sp, #0x40
70
+ .cfi_adjust_cfa_offset 0x40
71
+ stp d8, d9, [sp]
72
+ .cfi_rel_offset d8, 0x0
73
+ .cfi_rel_offset d9, 0x8
74
+ stp d10, d11, [sp, #0x10]
75
+ .cfi_rel_offset d10, 0x10
76
+ .cfi_rel_offset d11, 0x18
77
+ stp d12, d13, [sp, #0x20]
78
+ .cfi_rel_offset d12, 0x20
79
+ .cfi_rel_offset d13, 0x28
80
+ stp d14, d15, [sp, #0x30]
81
+ .cfi_rel_offset d14, 0x30
82
+ .cfi_rel_offset d15, 0x38
83
+ add x2, x0, #0xc8
84
+ ldp q25, q26, [x0], #0x20
85
+ ld1 { v27.2d, v28.2d }, [x2], #32
86
+ trn1 v0.2d, v25.2d, v27.2d
87
+ trn2 v1.2d, v25.2d, v27.2d
88
+ trn1 v2.2d, v26.2d, v28.2d
89
+ trn2 v3.2d, v26.2d, v28.2d
90
+ ldp q25, q26, [x0], #0x20
91
+ ld1 { v27.2d, v28.2d }, [x2], #32
92
+ trn1 v4.2d, v25.2d, v27.2d
93
+ trn2 v5.2d, v25.2d, v27.2d
94
+ trn1 v6.2d, v26.2d, v28.2d
95
+ trn2 v7.2d, v26.2d, v28.2d
96
+ ldp q25, q26, [x0], #0x20
97
+ ld1 { v27.2d, v28.2d }, [x2], #32
98
+ trn1 v8.2d, v25.2d, v27.2d
99
+ trn2 v9.2d, v25.2d, v27.2d
100
+ trn1 v10.2d, v26.2d, v28.2d
101
+ trn2 v11.2d, v26.2d, v28.2d
102
+ ldp q25, q26, [x0], #0x20
103
+ ld1 { v27.2d, v28.2d }, [x2], #32
104
+ trn1 v12.2d, v25.2d, v27.2d
105
+ trn2 v13.2d, v25.2d, v27.2d
106
+ trn1 v14.2d, v26.2d, v28.2d
107
+ trn2 v15.2d, v26.2d, v28.2d
108
+ ldp q25, q26, [x0], #0x20
109
+ ld1 { v27.2d, v28.2d }, [x2], #32
110
+ trn1 v16.2d, v25.2d, v27.2d
111
+ trn2 v17.2d, v25.2d, v27.2d
112
+ trn1 v18.2d, v26.2d, v28.2d
113
+ trn2 v19.2d, v26.2d, v28.2d
114
+ ldp q25, q26, [x0], #0x20
115
+ ld1 { v27.2d, v28.2d }, [x2], #32
116
+ trn1 v20.2d, v25.2d, v27.2d
117
+ trn2 v21.2d, v25.2d, v27.2d
118
+ trn1 v22.2d, v26.2d, v28.2d
119
+ trn2 v23.2d, v26.2d, v28.2d
120
+ ldr d25, [x0]
121
+ ldr d27, [x2]
122
+ trn1 v24.2d, v25.2d, v27.2d
123
+ mov x2, #0x18 // =24
124
+
125
+ Lmld_keccak_f1600_x2_v84a_loop:
126
+ eor3 v30.16b, v0.16b, v5.16b, v10.16b
127
+ eor3 v29.16b, v1.16b, v6.16b, v11.16b
128
+ eor3 v28.16b, v2.16b, v7.16b, v12.16b
129
+ eor3 v27.16b, v3.16b, v8.16b, v13.16b
130
+ eor3 v26.16b, v4.16b, v9.16b, v14.16b
131
+ eor3 v30.16b, v30.16b, v15.16b, v20.16b
132
+ eor3 v29.16b, v29.16b, v16.16b, v21.16b
133
+ eor3 v28.16b, v28.16b, v17.16b, v22.16b
134
+ eor3 v27.16b, v27.16b, v18.16b, v23.16b
135
+ eor3 v26.16b, v26.16b, v19.16b, v24.16b
136
+ rax1 v25.2d, v30.2d, v28.2d
137
+ rax1 v28.2d, v28.2d, v26.2d
138
+ rax1 v26.2d, v26.2d, v29.2d
139
+ rax1 v29.2d, v29.2d, v27.2d
140
+ rax1 v27.2d, v27.2d, v30.2d
141
+ eor v30.16b, v0.16b, v26.16b
142
+ xar v0.2d, v2.2d, v29.2d, #0x2
143
+ xar v2.2d, v12.2d, v29.2d, #0x15
144
+ xar v12.2d, v13.2d, v28.2d, #0x27
145
+ xar v13.2d, v19.2d, v27.2d, #0x38
146
+ xar v19.2d, v23.2d, v28.2d, #0x8
147
+ xar v23.2d, v15.2d, v26.2d, #0x17
148
+ xar v15.2d, v1.2d, v25.2d, #0x3f
149
+ xar v1.2d, v8.2d, v28.2d, #0x9
150
+ xar v8.2d, v16.2d, v25.2d, #0x13
151
+ xar v16.2d, v7.2d, v29.2d, #0x3a
152
+ xar v7.2d, v10.2d, v26.2d, #0x3d
153
+ xar v10.2d, v3.2d, v28.2d, #0x24
154
+ xar v3.2d, v18.2d, v28.2d, #0x2b
155
+ xar v18.2d, v17.2d, v29.2d, #0x31
156
+ xar v17.2d, v11.2d, v25.2d, #0x36
157
+ xar v11.2d, v9.2d, v27.2d, #0x2c
158
+ xar v9.2d, v22.2d, v29.2d, #0x3
159
+ xar v22.2d, v14.2d, v27.2d, #0x19
160
+ xar v14.2d, v20.2d, v26.2d, #0x2e
161
+ xar v20.2d, v4.2d, v27.2d, #0x25
162
+ xar v4.2d, v24.2d, v27.2d, #0x32
163
+ xar v24.2d, v21.2d, v25.2d, #0x3e
164
+ xar v21.2d, v5.2d, v26.2d, #0x1c
165
+ xar v27.2d, v6.2d, v25.2d, #0x14
166
+ ld1r { v31.2d }, [x1], #8
167
+ bcax v5.16b, v10.16b, v7.16b, v11.16b
168
+ bcax v6.16b, v11.16b, v8.16b, v7.16b
169
+ bcax v7.16b, v7.16b, v9.16b, v8.16b
170
+ bcax v8.16b, v8.16b, v10.16b, v9.16b
171
+ bcax v9.16b, v9.16b, v11.16b, v10.16b
172
+ bcax v10.16b, v15.16b, v12.16b, v16.16b
173
+ bcax v11.16b, v16.16b, v13.16b, v12.16b
174
+ bcax v12.16b, v12.16b, v14.16b, v13.16b
175
+ bcax v13.16b, v13.16b, v15.16b, v14.16b
176
+ bcax v14.16b, v14.16b, v16.16b, v15.16b
177
+ bcax v15.16b, v20.16b, v17.16b, v21.16b
178
+ bcax v16.16b, v21.16b, v18.16b, v17.16b
179
+ bcax v17.16b, v17.16b, v19.16b, v18.16b
180
+ bcax v18.16b, v18.16b, v20.16b, v19.16b
181
+ bcax v19.16b, v19.16b, v21.16b, v20.16b
182
+ bcax v20.16b, v0.16b, v22.16b, v1.16b
183
+ bcax v21.16b, v1.16b, v23.16b, v22.16b
184
+ bcax v22.16b, v22.16b, v24.16b, v23.16b
185
+ bcax v23.16b, v23.16b, v0.16b, v24.16b
186
+ bcax v24.16b, v24.16b, v1.16b, v0.16b
187
+ bcax v0.16b, v30.16b, v2.16b, v27.16b
188
+ bcax v1.16b, v27.16b, v3.16b, v2.16b
189
+ bcax v2.16b, v2.16b, v4.16b, v3.16b
190
+ bcax v3.16b, v3.16b, v30.16b, v4.16b
191
+ bcax v4.16b, v4.16b, v27.16b, v30.16b
192
+ eor v0.16b, v0.16b, v31.16b
193
+ sub x2, x2, #0x1
194
+ cbnz x2, Lmld_keccak_f1600_x2_v84a_loop
195
+ sub x0, x0, #0xc0
196
+ add x2, x0, #0xc8
197
+ trn1 v25.2d, v0.2d, v1.2d
198
+ trn1 v26.2d, v2.2d, v3.2d
199
+ stp q25, q26, [x0], #0x20
200
+ trn2 v27.2d, v0.2d, v1.2d
201
+ trn2 v28.2d, v2.2d, v3.2d
202
+ st1 { v27.2d, v28.2d }, [x2], #32
203
+ trn1 v25.2d, v4.2d, v5.2d
204
+ trn1 v26.2d, v6.2d, v7.2d
205
+ stp q25, q26, [x0], #0x20
206
+ trn2 v27.2d, v4.2d, v5.2d
207
+ trn2 v28.2d, v6.2d, v7.2d
208
+ st1 { v27.2d, v28.2d }, [x2], #32
209
+ trn1 v25.2d, v8.2d, v9.2d
210
+ trn1 v26.2d, v10.2d, v11.2d
211
+ stp q25, q26, [x0], #0x20
212
+ trn2 v27.2d, v8.2d, v9.2d
213
+ trn2 v28.2d, v10.2d, v11.2d
214
+ st1 { v27.2d, v28.2d }, [x2], #32
215
+ trn1 v25.2d, v12.2d, v13.2d
216
+ trn1 v26.2d, v14.2d, v15.2d
217
+ stp q25, q26, [x0], #0x20
218
+ trn2 v27.2d, v12.2d, v13.2d
219
+ trn2 v28.2d, v14.2d, v15.2d
220
+ st1 { v27.2d, v28.2d }, [x2], #32
221
+ trn1 v25.2d, v16.2d, v17.2d
222
+ trn1 v26.2d, v18.2d, v19.2d
223
+ stp q25, q26, [x0], #0x20
224
+ trn2 v27.2d, v16.2d, v17.2d
225
+ trn2 v28.2d, v18.2d, v19.2d
226
+ st1 { v27.2d, v28.2d }, [x2], #32
227
+ trn1 v25.2d, v20.2d, v21.2d
228
+ trn1 v26.2d, v22.2d, v23.2d
229
+ stp q25, q26, [x0], #0x20
230
+ trn2 v27.2d, v20.2d, v21.2d
231
+ trn2 v28.2d, v22.2d, v23.2d
232
+ st1 { v27.2d, v28.2d }, [x2], #32
233
+ str d24, [x0]
234
+ trn2 v25.2d, v24.2d, v24.2d
235
+ str d25, [x2]
236
+ ldp d8, d9, [sp]
237
+ .cfi_restore d8
238
+ .cfi_restore d9
239
+ ldp d10, d11, [sp, #0x10]
240
+ .cfi_restore d10
241
+ .cfi_restore d11
242
+ ldp d12, d13, [sp, #0x20]
243
+ .cfi_restore d12
244
+ .cfi_restore d13
245
+ ldp d14, d15, [sp, #0x30]
246
+ .cfi_restore d14
247
+ .cfi_restore d15
248
+ add sp, sp, #0x40
249
+ .cfi_adjust_cfa_offset -0x40
250
+ ret
251
+ .cfi_endproc
252
+
253
+ MLD_ASM_FN_SIZE(keccak_f1600_x2_v84a_aarch64_asm)
254
+
255
+ #endif /* __ARM_FEATURE_SHA3 */
256
+
257
+ #endif /* MLD_FIPS202_AARCH64_NEED_X2_V84A && !MLD_CONFIG_MULTILEVEL_NO_SHARED \
258
+ */
259
+
260
+ #if defined(__ELF__)
261
+ .section .note.GNU-stack,"",%progbits
262
+ #endif