|
| 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 <cstdint> |
| 9 | + |
| 10 | +#include <arm_neon.h> |
| 11 | + |
| 12 | +namespace sapphire { |
| 13 | +namespace arm_crypto_shavite { |
| 14 | +void CompressElement(uint32_t& l0, uint32_t& l1, uint32_t& l2, uint32_t& l3, |
| 15 | + uint32_t r0, uint32_t r1, uint32_t r2, uint32_t r3, const uint32_t* rk) |
| 16 | +{ |
| 17 | + // Pack block + XOR with round key 1 |
| 18 | + uint8x16_t block = util::pack_le(r0, r1, r2, r3); |
| 19 | + block = util::Xor(block, vreinterpretq_u8_u32(vld1q_u32(&rk[0]))); |
| 20 | + // AES round + XOR with round key 2 |
| 21 | + block = util::Xor(util::aes_round_nk(block), vreinterpretq_u8_u32(vld1q_u32(&rk[4]))); |
| 22 | + // AES round + XOR with round key 3 |
| 23 | + block = util::Xor(util::aes_round_nk(block), vreinterpretq_u8_u32(vld1q_u32(&rk[8]))); |
| 24 | + // AES Round + XOR with round key 4 |
| 25 | + block = util::Xor(util::aes_round_nk(block), vreinterpretq_u8_u32(vld1q_u32(&rk[12]))); |
| 26 | + // AES round |
| 27 | + block = util::aes_round_nk(block); |
| 28 | + // Unpack + XOR with l values |
| 29 | + uint32x4_t result = vreinterpretq_u32_u8(block); |
| 30 | + l0 ^= vgetq_lane_u32(result, 0); |
| 31 | + l1 ^= vgetq_lane_u32(result, 1); |
| 32 | + l2 ^= vgetq_lane_u32(result, 2); |
| 33 | + l3 ^= vgetq_lane_u32(result, 3); |
| 34 | +} |
| 35 | +} // namespace arm_crypto_shavite |
| 36 | +} // namespace sapphire |
| 37 | + |
| 38 | +#endif // ENABLE_ARM_AES |
0 commit comments