8#include <botan/internal/shacal2.h>
10#include <botan/internal/simd_32.h>
16inline void SHACAL2_Fwd(
const SIMD_4x32& A,
30inline void SHACAL2_Rev(
const SIMD_4x32& A,
46void SHACAL2::simd_encrypt_4(
const uint8_t in[], uint8_t out[])
const {
60 for(
size_t r = 0; r != 64; r += 8) {
61 SHACAL2_Fwd(A, B, C, D, E, F, G, H, m_RK[r + 0]);
62 SHACAL2_Fwd(H, A, B, C, D, E, F, G, m_RK[r + 1]);
63 SHACAL2_Fwd(G, H, A, B, C, D, E, F, m_RK[r + 2]);
64 SHACAL2_Fwd(F, G, H, A, B, C, D, E, m_RK[r + 3]);
65 SHACAL2_Fwd(E, F, G, H, A, B, C, D, m_RK[r + 4]);
66 SHACAL2_Fwd(D, E, F, G, H, A, B, C, m_RK[r + 5]);
67 SHACAL2_Fwd(C, D, E, F, G, H, A, B, m_RK[r + 6]);
68 SHACAL2_Fwd(B, C, D, E, F, G, H, A, m_RK[r + 7]);
82 H.store_be(out + 112);
85void SHACAL2::simd_decrypt_4(
const uint8_t in[], uint8_t out[])
const {
99 for(
size_t r = 0; r != 64; r += 8) {
100 SHACAL2_Rev(B, C, D, E, F, G, H, A, m_RK[63 - r]);
101 SHACAL2_Rev(C, D, E, F, G, H, A, B, m_RK[62 - r]);
102 SHACAL2_Rev(D, E, F, G, H, A, B, C, m_RK[61 - r]);
103 SHACAL2_Rev(E, F, G, H, A, B, C, D, m_RK[60 - r]);
104 SHACAL2_Rev(F, G, H, A, B, C, D, E, m_RK[59 - r]);
105 SHACAL2_Rev(G, H, A, B, C, D, E, F, m_RK[58 - r]);
106 SHACAL2_Rev(H, A, B, C, D, E, F, G, m_RK[57 - r]);
107 SHACAL2_Rev(A, B, C, D, E, F, G, H, m_RK[56 - r]);
114 E.store_be(out + 16);
115 B.store_be(out + 32);
116 F.store_be(out + 48);
118 C.store_be(out + 64);
119 G.store_be(out + 80);
120 D.store_be(out + 96);
121 H.store_be(out + 112);
static SIMD_4x32 load_be(const void *in) noexcept
static void transpose(SIMD_4x32 &B0, SIMD_4x32 &B1, SIMD_4x32 &B2, SIMD_4x32 &B3) noexcept
static SIMD_4x32 choose(const SIMD_4x32 &mask, const SIMD_4x32 &a, const SIMD_4x32 &b) noexcept
static SIMD_4x32 majority(const SIMD_4x32 &x, const SIMD_4x32 &y, const SIMD_4x32 &z) noexcept
static SIMD_4x32 splat(uint32_t B) noexcept