Line data Source code
1 : // Copyright (c) 2025 The Dash Core developers
2 : // Distributed under the MIT software license, see the accompanying
3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 :
5 : #if defined(ENABLE_ARM_AES)
6 : #include <crypto/x11/util/util.hpp>
7 :
8 : #include <cstddef>
9 :
10 : #include <arm_neon.h>
11 :
12 : namespace sapphire {
13 : namespace {
14 991717346 : void ALWAYS_INLINE StateRound(uint64_t W[16][2], size_t idx, uint8x16_t& key, uint32_t& k0, uint32_t& k1, uint32_t& k2, uint32_t& k3)
15 : {
16 991717346 : uint8x16_t block = vreinterpretq_u8_u64(vld1q_u64(&W[idx][0]));
17 991717346 : block = util::aes_round(block, key);
18 991717346 : block = util::aes_round_nk(block);
19 991717346 : vst1q_u64(&W[idx][0], vreinterpretq_u64_u8(block));
20 :
21 991717346 : util::unpack_le(key, k0, k1, k2, k3);
22 991717346 : if ((k0 = (k0 + 1)) == 0) {
23 0 : if ((k1 = (k1 + 1)) == 0) {
24 0 : if ((k2 = (k2 + 1)) == 0) {
25 0 : k3 = (k3 + 1);
26 0 : }
27 0 : }
28 0 : }
29 991717346 : }
30 : } // anonymous namespace
31 :
32 : namespace arm_crypto_echo {
33 62096043 : void FullStateRound(uint64_t W[16][2], uint32_t& k0, uint32_t& k1, uint32_t& k2, uint32_t& k3)
34 : {
35 62096043 : uint8x16_t key = util::pack_le(k0, k1, k2, k3);
36 62096043 : StateRound(W, 0, key, k0, k1, k2, k3);
37 62096043 : key = util::pack_le(k0, k1, k2, k3);
38 62096043 : StateRound(W, 1, key, k0, k1, k2, k3);
39 62096043 : key = util::pack_le(k0, k1, k2, k3);
40 62096043 : StateRound(W, 2, key, k0, k1, k2, k3);
41 62096043 : key = util::pack_le(k0, k1, k2, k3);
42 62096043 : StateRound(W, 3, key, k0, k1, k2, k3);
43 62096043 : key = util::pack_le(k0, k1, k2, k3);
44 62096043 : StateRound(W, 4, key, k0, k1, k2, k3);
45 62096043 : key = util::pack_le(k0, k1, k2, k3);
46 62096043 : StateRound(W, 5, key, k0, k1, k2, k3);
47 62096043 : key = util::pack_le(k0, k1, k2, k3);
48 62096043 : StateRound(W, 6, key, k0, k1, k2, k3);
49 62096043 : key = util::pack_le(k0, k1, k2, k3);
50 62096043 : StateRound(W, 7, key, k0, k1, k2, k3);
51 62096043 : key = util::pack_le(k0, k1, k2, k3);
52 62096043 : StateRound(W, 8, key, k0, k1, k2, k3);
53 62096043 : key = util::pack_le(k0, k1, k2, k3);
54 62096043 : StateRound(W, 9, key, k0, k1, k2, k3);
55 62096043 : key = util::pack_le(k0, k1, k2, k3);
56 62096043 : StateRound(W, 10, key, k0, k1, k2, k3);
57 62096043 : key = util::pack_le(k0, k1, k2, k3);
58 62096043 : StateRound(W, 11, key, k0, k1, k2, k3);
59 62096043 : key = util::pack_le(k0, k1, k2, k3);
60 62096043 : StateRound(W, 12, key, k0, k1, k2, k3);
61 62096043 : key = util::pack_le(k0, k1, k2, k3);
62 62096043 : StateRound(W, 13, key, k0, k1, k2, k3);
63 62096043 : key = util::pack_le(k0, k1, k2, k3);
64 62096043 : StateRound(W, 14, key, k0, k1, k2, k3);
65 62096043 : key = util::pack_le(k0, k1, k2, k3);
66 62096043 : StateRound(W, 15, key, k0, k1, k2, k3);
67 62096043 : }
68 : } // namespace arm_crypto_echo
69 : } // namespace sapphire
70 :
71 : #endif // ENABLE_ARM_AES
|