7#include <botan/internal/aria.h>
9#include <botan/mem_ops.h>
10#include <botan/internal/isa_extn.h>
11#include <botan/internal/simd_4x32.h>
12#include <botan/internal/simd_hwaes.h>
65 return x ^ x.
rotl<8>() ^ x.
rotl<24>();
78 const auto shuf =
SIMD_4x32(0x02030001, 0x06070405, 0x0A0B0809, 0x0E0F0C0D);
83 const SIMD_4x32 tbl(0x0C080400, 0x0D090501, 0x0E0A0602, 0x0F0B0703);
88 B0 = byte_transpose(B0);
89 B1 = byte_transpose(B1);
90 B2 = byte_transpose(B2);
91 B3 = byte_transpose(B3);
100 B0 = byte_transpose(B0);
101 B1 = byte_transpose(B1);
102 B2 = byte_transpose(B2);
103 B3 = byte_transpose(B3);
107 B0 = byte_transpose(B0);
108 B1 = byte_transpose(B1);
109 B2 = byte_transpose(B2);
110 B3 = byte_transpose(B3);
119 B0 = byte_transpose(B0);
120 B1 = byte_transpose(B1);
121 B2 = byte_transpose(B2);
122 B3 = byte_transpose(B3);
126 aria_fo_sbox(B0, B1, B2, B3);
133 aria_mix(B0, B1, B2, B3);
135 B1 = swap_abcd_badc(B1);
139 aria_mix(B0, B1, B2, B3);
143 aria_fe_sbox(B0, B1, B2, B3);
150 aria_mix(B0, B1, B2, B3);
152 B3 = swap_abcd_badc(B3);
156 aria_mix(B0, B1, B2, B3);
159BOTAN_FN_ISA_HWAES
void transform_4(
const uint8_t in[], uint8_t out[], std::span<const uint32_t> KS) {
160 const size_t ROUNDS = (KS.size() / 4) - 1;
169 for(
size_t r = 0; r != ROUNDS; r += 2) {
175 aria_fo(B0, B1, B2, B3);
182 if(r != ROUNDS - 2) {
183 aria_fe(B0, B1, B2, B3);
188 aria_fe_sbox(B0, B1, B2, B3);
203void BOTAN_FN_ISA_HWAES aria_transform(
const uint8_t in[], uint8_t out[],
size_t blocks, std::span<const uint32_t> KS) {
205 transform_4(in, out, KS);
212 uint8_t ibuf[4 * 16] = {0};
213 uint8_t obuf[4 * 16] = {0};
215 transform_4(ibuf, obuf, KS);
224void BOTAN_FN_ISA_HWAES ARIA_128::aria_hwaes_encrypt(
const uint8_t in[], uint8_t out[],
size_t blocks)
const {
225 ARIA_HWAES::aria_transform(in, out, blocks, m_ERK);
228void BOTAN_FN_ISA_HWAES ARIA_128::aria_hwaes_decrypt(
const uint8_t in[], uint8_t out[],
size_t blocks)
const {
229 ARIA_HWAES::aria_transform(in, out, blocks, m_DRK);
232void BOTAN_FN_ISA_HWAES ARIA_192::aria_hwaes_encrypt(
const uint8_t in[], uint8_t out[],
size_t blocks)
const {
233 ARIA_HWAES::aria_transform(in, out, blocks, m_ERK);
236void BOTAN_FN_ISA_HWAES ARIA_192::aria_hwaes_decrypt(
const uint8_t in[], uint8_t out[],
size_t blocks)
const {
237 ARIA_HWAES::aria_transform(in, out, blocks, m_DRK);
240void BOTAN_FN_ISA_HWAES ARIA_256::aria_hwaes_encrypt(
const uint8_t in[], uint8_t out[],
size_t blocks)
const {
241 ARIA_HWAES::aria_transform(in, out, blocks, m_ERK);
244void BOTAN_FN_ISA_HWAES ARIA_256::aria_hwaes_decrypt(
const uint8_t in[], uint8_t out[],
size_t blocks)
const {
245 ARIA_HWAES::aria_transform(in, out, blocks, m_DRK);
static SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 load_be(const void *in) noexcept
static SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 byte_shuffle(const SIMD_4x32 &tbl, const SIMD_4x32 &idx)
static SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 splat(uint32_t B) noexcept
static void BOTAN_FN_ISA_SIMD_4X32 transpose(SIMD_4x32 &B0, SIMD_4x32 &B1, SIMD_4x32 &B2, SIMD_4x32 &B3) noexcept
void BOTAN_FN_ISA_SIMD_4X32 store_be(uint32_t out[4]) const noexcept
BOTAN_FN_ISA_SIMD_4X32 SIMD_4x32 bswap() const noexcept
BOTAN_FN_ISA_SIMD_4X32 SIMD_4x32 rotl() const noexcept
#define BOTAN_FORCE_INLINE
constexpr void copy_mem(T *out, const T *in, size_t n)
consteval uint64_t gfni_matrix(std::string_view s)
SIMD_4x32 BOTAN_FN_ISA_HWAES hw_aes_inv_sbox(SIMD_4x32 x)
SIMD_4x32 BOTAN_FN_ISA_HWAES hw_aes_sbox(SIMD_4x32 x)