7#include <botan/internal/shacal2.h>
9#include <botan/internal/simd_avx2.h>
24 H += E.sigma1() + SIMD_8x32::choose(E, F, G) + SIMD_8x32::splat(RK);
26 H += A.sigma0() + SIMD_8x32::majority(A, B, C);
38 H -= A.sigma0() + SIMD_8x32::majority(A, B, C);
40 H -= E.sigma1() + SIMD_8x32::choose(E, F, G) + SIMD_8x32::splat(RK);
45void BOTAN_AVX2_FN SHACAL2::avx2_encrypt_8(
const uint8_t in[], uint8_t out[])
const {
46 SIMD_8x32::reset_registers();
48 SIMD_8x32 A = SIMD_8x32::load_be(in);
49 SIMD_8x32 B = SIMD_8x32::load_be(in + 32);
50 SIMD_8x32 C = SIMD_8x32::load_be(in + 64);
51 SIMD_8x32 D = SIMD_8x32::load_be(in + 96);
53 SIMD_8x32 E = SIMD_8x32::load_be(in + 128);
54 SIMD_8x32 F = SIMD_8x32::load_be(in + 160);
55 SIMD_8x32 G = SIMD_8x32::load_be(in + 192);
56 SIMD_8x32 H = SIMD_8x32::load_be(in + 224);
58 SIMD_8x32::transpose(A, B, C, D, E, F, G, H);
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]);
71 SIMD_8x32::transpose(A, B, C, D, E, F, G, H);
78 E.store_be(out + 128);
79 F.store_be(out + 160);
80 G.store_be(out + 192);
81 H.store_be(out + 224);
83 SIMD_8x32::zero_registers();
86BOTAN_AVX2_FN void SHACAL2::avx2_decrypt_8(
const uint8_t in[], uint8_t out[])
const {
87 SIMD_8x32::reset_registers();
89 SIMD_8x32 A = SIMD_8x32::load_be(in);
90 SIMD_8x32 B = SIMD_8x32::load_be(in + 32);
91 SIMD_8x32 C = SIMD_8x32::load_be(in + 64);
92 SIMD_8x32 D = SIMD_8x32::load_be(in + 96);
94 SIMD_8x32 E = SIMD_8x32::load_be(in + 128);
95 SIMD_8x32 F = SIMD_8x32::load_be(in + 160);
96 SIMD_8x32 G = SIMD_8x32::load_be(in + 192);
97 SIMD_8x32 H = SIMD_8x32::load_be(in + 224);
99 SIMD_8x32::transpose(A, B, C, D, E, F, G, H);
101 for(
size_t r = 0; r != 64; r += 8) {
102 SHACAL2_Rev(B, C, D, E, F, G, H, A, m_RK[63 - r]);
103 SHACAL2_Rev(C, D, E, F, G, H, A, B, m_RK[62 - r]);
104 SHACAL2_Rev(D, E, F, G, H, A, B, C, m_RK[61 - r]);
105 SHACAL2_Rev(E, F, G, H, A, B, C, D, m_RK[60 - r]);
106 SHACAL2_Rev(F, G, H, A, B, C, D, E, m_RK[59 - r]);
107 SHACAL2_Rev(G, H, A, B, C, D, E, F, m_RK[58 - r]);
108 SHACAL2_Rev(H, A, B, C, D, E, F, G, m_RK[57 - r]);
109 SHACAL2_Rev(A, B, C, D, E, F, G, H, m_RK[56 - r]);
112 SIMD_8x32::transpose(A, B, C, D, E, F, G, H);
115 B.store_be(out + 32);
116 C.store_be(out + 64);
117 D.store_be(out + 96);
119 E.store_be(out + 128);
120 F.store_be(out + 160);
121 G.store_be(out + 192);
122 H.store_be(out + 224);
124 SIMD_8x32::zero_registers();
#define BOTAN_FORCE_INLINE