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 163011353 : 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 163011353 : uint8x16_t block = vreinterpretq_u8_u64(vld1q_u64(&W[idx][0]));
17 163011353 : block = util::aes_round(block, key);
18 163011353 : block = util::aes_round_nk(block);
19 163011353 : vst1q_u64(&W[idx][0], vreinterpretq_u64_u8(block));
20 :
21 163011353 : util::unpack_le(key, k0, k1, k2, k3);
22 163011353 : 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 163011353 : }
30 : } // anonymous namespace
31 :
32 : namespace arm_crypto_echo {
33 10189606 : void FullStateRound(uint64_t W[16][2], uint32_t& k0, uint32_t& k1, uint32_t& k2, uint32_t& k3)
34 : {
35 10189606 : uint8x16_t key = util::pack_le(k0, k1, k2, k3);
36 10189606 : StateRound(W, 0, key, k0, k1, k2, k3);
37 10189606 : key = util::pack_le(k0, k1, k2, k3);
38 10189606 : StateRound(W, 1, key, k0, k1, k2, k3);
39 10189606 : key = util::pack_le(k0, k1, k2, k3);
40 10189606 : StateRound(W, 2, key, k0, k1, k2, k3);
41 10189606 : key = util::pack_le(k0, k1, k2, k3);
42 10189606 : StateRound(W, 3, key, k0, k1, k2, k3);
43 10189606 : key = util::pack_le(k0, k1, k2, k3);
44 10189606 : StateRound(W, 4, key, k0, k1, k2, k3);
45 10189606 : key = util::pack_le(k0, k1, k2, k3);
46 10189606 : StateRound(W, 5, key, k0, k1, k2, k3);
47 10189606 : key = util::pack_le(k0, k1, k2, k3);
48 10189606 : StateRound(W, 6, key, k0, k1, k2, k3);
49 10189606 : key = util::pack_le(k0, k1, k2, k3);
50 10189606 : StateRound(W, 7, key, k0, k1, k2, k3);
51 10189606 : key = util::pack_le(k0, k1, k2, k3);
52 10189606 : StateRound(W, 8, key, k0, k1, k2, k3);
53 10189606 : key = util::pack_le(k0, k1, k2, k3);
54 10189606 : StateRound(W, 9, key, k0, k1, k2, k3);
55 10189606 : key = util::pack_le(k0, k1, k2, k3);
56 10189606 : StateRound(W, 10, key, k0, k1, k2, k3);
57 10189606 : key = util::pack_le(k0, k1, k2, k3);
58 10189606 : StateRound(W, 11, key, k0, k1, k2, k3);
59 10189606 : key = util::pack_le(k0, k1, k2, k3);
60 10189606 : StateRound(W, 12, key, k0, k1, k2, k3);
61 10189606 : key = util::pack_le(k0, k1, k2, k3);
62 10189606 : StateRound(W, 13, key, k0, k1, k2, k3);
63 10189606 : key = util::pack_le(k0, k1, k2, k3);
64 10189606 : StateRound(W, 14, key, k0, k1, k2, k3);
65 10189606 : key = util::pack_le(k0, k1, k2, k3);
66 10189606 : StateRound(W, 15, key, k0, k1, k2, k3);
67 10189606 : }
68 : } // namespace arm_crypto_echo
69 : } // namespace sapphire
70 :
71 : #endif // ENABLE_ARM_AES
|