7#include <botan/internal/aes.h>
9#include <botan/internal/bit_ops.h>
10#include <botan/internal/bswap.h>
11#include <botan/internal/cpuid.h>
12#include <botan/internal/ct_utils.h>
13#include <botan/internal/loadstor.h>
14#include <botan/internal/rotate.h>
18#if defined(BOTAN_HAS_AES_POWER8) || defined(BOTAN_HAS_AES_ARMV8) || defined(BOTAN_HAS_AES_NI)
19 #define BOTAN_HAS_HW_AES_SUPPORT
85void AES_SBOX(uint32_t V[8]) {
86 const uint32_t U0 = V[0];
87 const uint32_t U1 = V[1];
88 const uint32_t U2 = V[2];
89 const uint32_t U3 = V[3];
90 const uint32_t U4 = V[4];
91 const uint32_t U5 = V[5];
92 const uint32_t U6 = V[6];
93 const uint32_t U7 = V[7];
95 const uint32_t y14 = U3 ^ U5;
96 const uint32_t y13 = U0 ^ U6;
97 const uint32_t y9 = U0 ^ U3;
98 const uint32_t y8 = U0 ^ U5;
99 const uint32_t t0 = U1 ^ U2;
100 const uint32_t y1 = t0 ^ U7;
101 const uint32_t y4 = y1 ^ U3;
102 const uint32_t y12 = y13 ^ y14;
103 const uint32_t y2 = y1 ^ U0;
104 const uint32_t y5 = y1 ^ U6;
105 const uint32_t y3 = y5 ^ y8;
106 const uint32_t t1 = U4 ^ y12;
107 const uint32_t y15 = t1 ^ U5;
108 const uint32_t y20 = t1 ^ U1;
109 const uint32_t y6 = y15 ^ U7;
110 const uint32_t y10 = y15 ^ t0;
111 const uint32_t y11 = y20 ^ y9;
112 const uint32_t y7 = U7 ^ y11;
113 const uint32_t y17 = y10 ^ y11;
114 const uint32_t y19 = y10 ^ y8;
115 const uint32_t y16 = t0 ^ y11;
116 const uint32_t y21 = y13 ^ y16;
117 const uint32_t y18 = U0 ^ y16;
118 const uint32_t t2 = y12 & y15;
119 const uint32_t t3 = y3 & y6;
120 const uint32_t t4 = t3 ^ t2;
121 const uint32_t t5 = y4 & U7;
122 const uint32_t t6 = t5 ^ t2;
123 const uint32_t t7 = y13 & y16;
124 const uint32_t t8 = y5 & y1;
125 const uint32_t t9 = t8 ^ t7;
126 const uint32_t t10 = y2 & y7;
127 const uint32_t t11 = t10 ^ t7;
128 const uint32_t t12 = y9 & y11;
129 const uint32_t t13 = y14 & y17;
130 const uint32_t t14 = t13 ^ t12;
131 const uint32_t t15 = y8 & y10;
132 const uint32_t t16 = t15 ^ t12;
133 const uint32_t t17 = t4 ^ y20;
134 const uint32_t t18 = t6 ^ t16;
135 const uint32_t t19 = t9 ^ t14;
136 const uint32_t t20 = t11 ^ t16;
137 const uint32_t t21 = t17 ^ t14;
138 const uint32_t t22 = t18 ^ y19;
139 const uint32_t t23 = t19 ^ y21;
140 const uint32_t t24 = t20 ^ y18;
141 const uint32_t t25 = t21 ^ t22;
142 const uint32_t t26 = t21 & t23;
143 const uint32_t t27 = t24 ^ t26;
144 const uint32_t t28 = t25 & t27;
145 const uint32_t t29 = t28 ^ t22;
146 const uint32_t t30 = t23 ^ t24;
147 const uint32_t t31 = t22 ^ t26;
148 const uint32_t t32 = t31 & t30;
149 const uint32_t t33 = t32 ^ t24;
150 const uint32_t t34 = t23 ^ t33;
151 const uint32_t t35 = t27 ^ t33;
152 const uint32_t t36 = t24 & t35;
153 const uint32_t t37 = t36 ^ t34;
154 const uint32_t t38 = t27 ^ t36;
155 const uint32_t t39 = t29 & t38;
156 const uint32_t t40 = t25 ^ t39;
157 const uint32_t t41 = t40 ^ t37;
158 const uint32_t t42 = t29 ^ t33;
159 const uint32_t t43 = t29 ^ t40;
160 const uint32_t t44 = t33 ^ t37;
161 const uint32_t t45 = t42 ^ t41;
162 const uint32_t z0 = t44 & y15;
163 const uint32_t z1 = t37 & y6;
164 const uint32_t z2 = t33 & U7;
165 const uint32_t z3 = t43 & y16;
166 const uint32_t z4 = t40 & y1;
167 const uint32_t z5 = t29 & y7;
168 const uint32_t z6 = t42 & y11;
169 const uint32_t z7 = t45 & y17;
170 const uint32_t z8 = t41 & y10;
171 const uint32_t z9 = t44 & y12;
172 const uint32_t z10 = t37 & y3;
173 const uint32_t z11 = t33 & y4;
174 const uint32_t z12 = t43 & y13;
175 const uint32_t z13 = t40 & y5;
176 const uint32_t z14 = t29 & y2;
177 const uint32_t z15 = t42 & y9;
178 const uint32_t z16 = t45 & y14;
179 const uint32_t z17 = t41 & y8;
180 const uint32_t tc1 = z15 ^ z16;
181 const uint32_t tc2 = z10 ^ tc1;
182 const uint32_t tc3 = z9 ^ tc2;
183 const uint32_t tc4 = z0 ^ z2;
184 const uint32_t tc5 = z1 ^ z0;
185 const uint32_t tc6 = z3 ^ z4;
186 const uint32_t tc7 = z12 ^ tc4;
187 const uint32_t tc8 = z7 ^ tc6;
188 const uint32_t tc9 = z8 ^ tc7;
189 const uint32_t tc10 = tc8 ^ tc9;
190 const uint32_t tc11 = tc6 ^ tc5;
191 const uint32_t tc12 = z3 ^ z5;
192 const uint32_t tc13 = z13 ^ tc1;
193 const uint32_t tc14 = tc4 ^ tc12;
194 const uint32_t S3 = tc3 ^ tc11;
195 const uint32_t tc16 = z6 ^ tc8;
196 const uint32_t tc17 = z14 ^ tc10;
197 const uint32_t tc18 = ~tc13 ^ tc14;
198 const uint32_t S7 = z12 ^ tc18;
199 const uint32_t tc20 = z15 ^ tc16;
200 const uint32_t tc21 = tc2 ^ z11;
201 const uint32_t S0 = tc3 ^ tc16;
202 const uint32_t S6 = tc10 ^ tc18;
203 const uint32_t S4 = tc14 ^ S3;
204 const uint32_t S1 = ~(S3 ^ tc16);
205 const uint32_t tc26 = tc17 ^ tc20;
206 const uint32_t S2 = ~(tc26 ^ z17);
207 const uint32_t S5 = tc21 ^ tc17;
224void AES_INV_SBOX(uint32_t V[8]) {
225 const uint32_t U0 = V[0];
226 const uint32_t U1 = V[1];
227 const uint32_t U2 = V[2];
228 const uint32_t U3 = V[3];
229 const uint32_t U4 = V[4];
230 const uint32_t U5 = V[5];
231 const uint32_t U6 = V[6];
232 const uint32_t U7 = V[7];
234 const uint32_t Y0 = U0 ^ U3;
235 const uint32_t Y2 = ~(U1 ^ U3);
236 const uint32_t Y4 = U0 ^ Y2;
237 const uint32_t RTL0 = U6 ^ U7;
238 const uint32_t Y1 = Y2 ^ RTL0;
239 const uint32_t Y7 = ~(U2 ^ Y1);
240 const uint32_t RTL1 = U3 ^ U4;
241 const uint32_t Y6 = ~(U7 ^ RTL1);
242 const uint32_t Y3 = Y1 ^ RTL1;
243 const uint32_t RTL2 = ~(U0 ^ U2);
244 const uint32_t Y5 = U5 ^ RTL2;
245 const uint32_t sa1 = Y0 ^ Y2;
246 const uint32_t sa0 = Y1 ^ Y3;
247 const uint32_t sb1 = Y4 ^ Y6;
248 const uint32_t sb0 = Y5 ^ Y7;
249 const uint32_t ah = Y0 ^ Y1;
250 const uint32_t al = Y2 ^ Y3;
251 const uint32_t aa = sa0 ^ sa1;
252 const uint32_t bh = Y4 ^ Y5;
253 const uint32_t bl = Y6 ^ Y7;
254 const uint32_t bb = sb0 ^ sb1;
255 const uint32_t ab20 = sa0 ^ sb0;
256 const uint32_t ab22 = al ^ bl;
257 const uint32_t ab23 = Y3 ^ Y7;
258 const uint32_t ab21 = sa1 ^ sb1;
259 const uint32_t abcd1 = ah & bh;
260 const uint32_t rr1 = Y0 & Y4;
261 const uint32_t ph11 = ab20 ^ abcd1;
262 const uint32_t t01 = Y1 & Y5;
263 const uint32_t ph01 = t01 ^ abcd1;
264 const uint32_t abcd2 = al & bl;
265 const uint32_t r1 = Y2 & Y6;
266 const uint32_t pl11 = ab22 ^ abcd2;
267 const uint32_t r2 = Y3 & Y7;
268 const uint32_t pl01 = r2 ^ abcd2;
269 const uint32_t r3 = sa0 & sb0;
270 const uint32_t vr1 = aa & bb;
271 const uint32_t pr1 = vr1 ^ r3;
272 const uint32_t wr1 = sa1 & sb1;
273 const uint32_t qr1 = wr1 ^ r3;
274 const uint32_t ab0 = ph11 ^ rr1;
275 const uint32_t ab1 = ph01 ^ ab21;
276 const uint32_t ab2 = pl11 ^ r1;
277 const uint32_t ab3 = pl01 ^ qr1;
278 const uint32_t cp1 = ab0 ^ pr1;
279 const uint32_t cp2 = ab1 ^ qr1;
280 const uint32_t cp3 = ab2 ^ pr1;
281 const uint32_t cp4 = ab3 ^ ab23;
282 const uint32_t tinv1 = cp3 ^ cp4;
283 const uint32_t tinv2 = cp3 & cp1;
284 const uint32_t tinv3 = cp2 ^ tinv2;
285 const uint32_t tinv4 = cp1 ^ cp2;
286 const uint32_t tinv5 = cp4 ^ tinv2;
287 const uint32_t tinv6 = tinv5 & tinv4;
288 const uint32_t tinv7 = tinv3 & tinv1;
289 const uint32_t d2 = cp4 ^ tinv7;
290 const uint32_t d0 = cp2 ^ tinv6;
291 const uint32_t tinv8 = cp1 & cp4;
292 const uint32_t tinv9 = tinv4 & tinv8;
293 const uint32_t tinv10 = tinv4 ^ tinv2;
294 const uint32_t d1 = tinv9 ^ tinv10;
295 const uint32_t tinv11 = cp2 & cp3;
296 const uint32_t tinv12 = tinv1 & tinv11;
297 const uint32_t tinv13 = tinv1 ^ tinv2;
298 const uint32_t d3 = tinv12 ^ tinv13;
299 const uint32_t sd1 = d1 ^ d3;
300 const uint32_t sd0 = d0 ^ d2;
301 const uint32_t dl = d0 ^ d1;
302 const uint32_t dh = d2 ^ d3;
303 const uint32_t dd = sd0 ^ sd1;
304 const uint32_t abcd3 = dh & bh;
305 const uint32_t rr2 = d3 & Y4;
306 const uint32_t t02 = d2 & Y5;
307 const uint32_t abcd4 = dl & bl;
308 const uint32_t r4 = d1 & Y6;
309 const uint32_t r5 = d0 & Y7;
310 const uint32_t r6 = sd0 & sb0;
311 const uint32_t vr2 = dd & bb;
312 const uint32_t wr2 = sd1 & sb1;
313 const uint32_t abcd5 = dh & ah;
314 const uint32_t r7 = d3 & Y0;
315 const uint32_t r8 = d2 & Y1;
316 const uint32_t abcd6 = dl & al;
317 const uint32_t r9 = d1 & Y2;
318 const uint32_t r10 = d0 & Y3;
319 const uint32_t r11 = sd0 & sa0;
320 const uint32_t vr3 = dd & aa;
321 const uint32_t wr3 = sd1 & sa1;
322 const uint32_t ph12 = rr2 ^ abcd3;
323 const uint32_t ph02 = t02 ^ abcd3;
324 const uint32_t pl12 = r4 ^ abcd4;
325 const uint32_t pl02 = r5 ^ abcd4;
326 const uint32_t pr2 = vr2 ^ r6;
327 const uint32_t qr2 = wr2 ^ r6;
328 const uint32_t p0 = ph12 ^ pr2;
329 const uint32_t p1 = ph02 ^ qr2;
330 const uint32_t p2 = pl12 ^ pr2;
331 const uint32_t p3 = pl02 ^ qr2;
332 const uint32_t ph13 = r7 ^ abcd5;
333 const uint32_t ph03 = r8 ^ abcd5;
334 const uint32_t pl13 = r9 ^ abcd6;
335 const uint32_t pl03 = r10 ^ abcd6;
336 const uint32_t pr3 = vr3 ^ r11;
337 const uint32_t qr3 = wr3 ^ r11;
338 const uint32_t p4 = ph13 ^ pr3;
339 const uint32_t S7 = ph03 ^ qr3;
340 const uint32_t p6 = pl13 ^ pr3;
341 const uint32_t p7 = pl03 ^ qr3;
342 const uint32_t S3 = p1 ^ p6;
343 const uint32_t S6 = p2 ^ p6;
344 const uint32_t S0 = p3 ^ p6;
345 const uint32_t X11 = p0 ^ p2;
346 const uint32_t S5 = S0 ^ X11;
347 const uint32_t X13 = p4 ^ p7;
348 const uint32_t X14 = X11 ^ X13;
349 const uint32_t S1 = S3 ^ X14;
350 const uint32_t X16 = p1 ^ S7;
351 const uint32_t S2 = X14 ^ X16;
352 const uint32_t X18 = p0 ^ p4;
353 const uint32_t X19 = S5 ^ X16;
354 const uint32_t S4 = X18 ^ X19;
366inline void bit_transpose(uint32_t B[8]) {
383inline void ks_expand(uint32_t B[8],
const uint32_t K[],
size_t r) {
388 for(
size_t i = 0; i != 4; ++i) {
409inline void shift_rows(uint32_t B[8]) {
411#if defined(BOTAN_TARGET_CPU_HAS_NATIVE_64BIT)
412 for(
size_t i = 0; i != 8; i += 2) {
413 uint64_t x = (
static_cast<uint64_t
>(B[i]) << 32) | B[i + 1];
416 B[i] =
static_cast<uint32_t
>(x >> 32);
417 B[i + 1] =
static_cast<uint32_t
>(x);
420 for(
size_t i = 0; i != 8; ++i) {
429inline void inv_shift_rows(uint32_t B[8]) {
432#if defined(BOTAN_TARGET_CPU_HAS_NATIVE_64BIT)
433 for(
size_t i = 0; i != 8; i += 2) {
434 uint64_t x = (
static_cast<uint64_t
>(B[i]) << 32) | B[i + 1];
437 B[i] =
static_cast<uint32_t
>(x >> 32);
438 B[i + 1] =
static_cast<uint32_t
>(x);
441 for(
size_t i = 0; i != 8; ++i) {
450inline void mix_columns(uint32_t B[8]) {
452 const uint32_t X2[8] = {
463 for(
size_t i = 0; i != 8; i++) {
464 const uint32_t X3 = B[i] ^ X2[i];
469void inv_mix_columns(uint32_t B[8]) {
483 const uint32_t X4[8] = {
494 for(
size_t i = 0; i != 8; i++) {
495 const uint32_t X5 = X4[i] ^ B[i];
506 BOTAN_ASSERT(EK.size() == 44 || EK.size() == 52 || EK.size() == 60,
"Key was set");
508 const size_t rounds = (EK.size() - 4) / 4;
510 uint32_t KS[13 * 8] = {0};
511 for(
size_t i = 0; i < rounds - 1; i += 1) {
512 ks_expand(&KS[8 * i], EK.data(), 4 * i + 4);
515 const size_t BLOCK_SIZE = 16;
516 const size_t BITSLICED_BLOCKS = 8 *
sizeof(uint32_t) / BLOCK_SIZE;
519 const size_t this_loop = std::min(blocks, BITSLICED_BLOCKS);
527 for(
size_t i = 0; i != 8; ++i) {
533 for(
size_t r = 0; r != rounds - 1; ++r) {
538 for(
size_t i = 0; i != 8; ++i) {
539 B[i] ^= KS[8 * r + i];
548 for(
size_t i = 0; i != 8; ++i) {
549 B[i] ^= EK[4 * rounds + i % 4];
554 copy_out_be(std::span(out, this_loop * 4 *
sizeof(uint32_t)), B);
556 in += this_loop * BLOCK_SIZE;
557 out += this_loop * BLOCK_SIZE;
566 BOTAN_ASSERT(DK.size() == 44 || DK.size() == 52 || DK.size() == 60,
"Key was set");
568 const size_t rounds = (DK.size() - 4) / 4;
570 uint32_t KS[13 * 8] = {0};
571 for(
size_t i = 0; i < rounds - 1; i += 1) {
572 ks_expand(&KS[8 * i], DK.data(), 4 * i + 4);
575 const size_t BLOCK_SIZE = 16;
576 const size_t BITSLICED_BLOCKS = 8 *
sizeof(uint32_t) / BLOCK_SIZE;
579 const size_t this_loop = std::min(blocks, BITSLICED_BLOCKS);
587 for(
size_t i = 0; i != 8; ++i) {
593 for(
size_t r = 0; r != rounds - 1; ++r) {
598 for(
size_t i = 0; i != 8; ++i) {
599 B[i] ^= KS[8 * r + i];
608 for(
size_t i = 0; i != 8; ++i) {
609 B[i] ^= DK[4 * rounds + i % 4];
614 copy_out_be(std::span(out, this_loop * 4 *
sizeof(uint32_t)), B);
616 in += this_loop * BLOCK_SIZE;
617 out += this_loop * BLOCK_SIZE;
622inline uint32_t xtime32(uint32_t s) {
623 const uint32_t lo_bit = 0x01010101;
624 const uint32_t mask = 0x7F7F7F7F;
625 const uint32_t poly = 0x1B;
627 return ((s & mask) << 1) ^ (((s >> 7) & lo_bit) * poly);
630inline uint32_t InvMixColumn(uint32_t s1) {
631 const uint32_t s2 = xtime32(s1);
632 const uint32_t s4 = xtime32(s2);
633 const uint32_t s8 = xtime32(s4);
634 const uint32_t s9 = s8 ^ s1;
635 const uint32_t s11 = s9 ^ s2;
636 const uint32_t s13 = s9 ^ s4;
637 const uint32_t s14 = s8 ^ s4 ^ s2;
642void InvMixColumn_x4(uint32_t x[4]) {
643 x[0] = InvMixColumn(x[0]);
644 x[1] = InvMixColumn(x[1]);
645 x[2] = InvMixColumn(x[2]);
646 x[3] = InvMixColumn(x[3]);
649uint32_t SE_word(uint32_t x) {
652 for(
size_t i = 0; i != 8; ++i) {
653 I[i] = (x >> (7 - i)) & 0x01010101;
660 for(
size_t i = 0; i != 8; ++i) {
661 x |= ((I[i] & 0x01010101) << (7 - i));
667void aes_key_schedule(
const uint8_t key[],
671 bool bswap_keys =
false) {
672 static const uint32_t RC[10] = {0x01000000,
683 const size_t X = length / 4;
688 const size_t rounds = (length / 4) + 6;
695 EK.resize(length + 28);
696 DK.resize(length + 28);
698 for(
size_t i = 0; i !=
X; ++i) {
702 for(
size_t i =
X; i < 4 * (rounds + 1); i +=
X) {
703 EK[i] = EK[i -
X] ^ RC[(i -
X) /
X] ^
rotl<8>(SE_word(EK[i - 1]));
705 for(
size_t j = 1; j !=
X && (i + j) < EK.size(); ++j) {
706 EK[i + j] = EK[i + j -
X];
708 if(
X == 8 && j == 4) {
709 EK[i + j] ^= SE_word(EK[i + j - 1]);
711 EK[i + j] ^= EK[i + j - 1];
716 for(
size_t i = 0; i != 4 * (rounds + 1); i += 4) {
717 DK[i] = EK[4 * rounds - i];
718 DK[i + 1] = EK[4 * rounds - i + 1];
719 DK[i + 2] = EK[4 * rounds - i + 2];
720 DK[i + 3] = EK[4 * rounds - i + 3];
723 for(
size_t i = 4; i != 4 * rounds; i += 4) {
724 InvMixColumn_x4(&DK[i]);
729 for(
size_t i = 0; i != EK.size(); ++i) {
732 for(
size_t i = 0; i != DK.size(); ++i) {
742size_t aes_parallelism() {
743#if defined(BOTAN_HAS_AES_VAES)
744 if(CPUID::has_avx2_vaes()) {
749#if defined(BOTAN_HAS_HW_AES_SUPPORT)
755#if defined(BOTAN_HAS_AES_VPERM)
765const char* aes_provider() {
766#if defined(BOTAN_HAS_AES_VAES)
767 if(CPUID::has_avx2_vaes()) {
772#if defined(BOTAN_HAS_HW_AES_SUPPORT)
778#if defined(BOTAN_HAS_AES_VPERM)
790 return aes_provider();
794 return aes_provider();
798 return aes_provider();
802 return aes_parallelism();
806 return aes_parallelism();
810 return aes_parallelism();
814 return !m_EK.empty();
818 return !m_EK.empty();
822 return !m_EK.empty();
828#if defined(BOTAN_HAS_AES_VAES)
829 if(CPUID::has_avx2_vaes()) {
830 return x86_vaes_encrypt_n(in, out, blocks);
834#if defined(BOTAN_HAS_HW_AES_SUPPORT)
836 return hw_aes_encrypt_n(in, out, blocks);
840#if defined(BOTAN_HAS_AES_VPERM)
842 return vperm_encrypt_n(in, out, blocks);
846 aes_encrypt_n(in, out, blocks, m_EK);
852#if defined(BOTAN_HAS_AES_VAES)
853 if(CPUID::has_avx2_vaes()) {
854 return x86_vaes_decrypt_n(in, out, blocks);
858#if defined(BOTAN_HAS_HW_AES_SUPPORT)
860 return hw_aes_decrypt_n(in, out, blocks);
864#if defined(BOTAN_HAS_AES_VPERM)
866 return vperm_decrypt_n(in, out, blocks);
870 aes_decrypt_n(in, out, blocks, m_DK);
873void AES_128::key_schedule(std::span<const uint8_t> key) {
874#if defined(BOTAN_HAS_AES_NI)
875 if(CPUID::has_aes_ni()) {
876 return aesni_key_schedule(key.data(), key.size());
880#if defined(BOTAN_HAS_AES_VAES)
881 if(CPUID::has_avx2_vaes()) {
886#if defined(BOTAN_HAS_HW_AES_SUPPORT)
892#if defined(BOTAN_HAS_AES_VPERM)
894 return vperm_key_schedule(key.data(), key.size());
898 aes_key_schedule(key.data(), key.size(), m_EK, m_DK);
909#if defined(BOTAN_HAS_AES_VAES)
910 if(CPUID::has_avx2_vaes()) {
911 return x86_vaes_encrypt_n(in, out, blocks);
915#if defined(BOTAN_HAS_HW_AES_SUPPORT)
917 return hw_aes_encrypt_n(in, out, blocks);
921#if defined(BOTAN_HAS_AES_VPERM)
923 return vperm_encrypt_n(in, out, blocks);
927 aes_encrypt_n(in, out, blocks, m_EK);
933#if defined(BOTAN_HAS_AES_VAES)
934 if(CPUID::has_avx2_vaes()) {
935 return x86_vaes_decrypt_n(in, out, blocks);
939#if defined(BOTAN_HAS_HW_AES_SUPPORT)
941 return hw_aes_decrypt_n(in, out, blocks);
945#if defined(BOTAN_HAS_AES_VPERM)
947 return vperm_decrypt_n(in, out, blocks);
951 aes_decrypt_n(in, out, blocks, m_DK);
954void AES_192::key_schedule(std::span<const uint8_t> key) {
955#if defined(BOTAN_HAS_AES_NI)
956 if(CPUID::has_aes_ni()) {
957 return aesni_key_schedule(key.data(), key.size());
961#if defined(BOTAN_HAS_AES_VAES)
962 if(CPUID::has_avx2_vaes()) {
967#if defined(BOTAN_HAS_HW_AES_SUPPORT)
973#if defined(BOTAN_HAS_AES_VPERM)
975 return vperm_key_schedule(key.data(), key.size());
979 aes_key_schedule(key.data(), key.size(), m_EK, m_DK);
990#if defined(BOTAN_HAS_AES_VAES)
991 if(CPUID::has_avx2_vaes()) {
992 return x86_vaes_encrypt_n(in, out, blocks);
996#if defined(BOTAN_HAS_HW_AES_SUPPORT)
998 return hw_aes_encrypt_n(in, out, blocks);
1002#if defined(BOTAN_HAS_AES_VPERM)
1004 return vperm_encrypt_n(in, out, blocks);
1008 aes_encrypt_n(in, out, blocks, m_EK);
1014#if defined(BOTAN_HAS_AES_VAES)
1015 if(CPUID::has_avx2_vaes()) {
1016 return x86_vaes_decrypt_n(in, out, blocks);
1020#if defined(BOTAN_HAS_HW_AES_SUPPORT)
1022 return hw_aes_decrypt_n(in, out, blocks);
1026#if defined(BOTAN_HAS_AES_VPERM)
1028 return vperm_decrypt_n(in, out, blocks);
1032 aes_decrypt_n(in, out, blocks, m_DK);
1035void AES_256::key_schedule(std::span<const uint8_t> key) {
1036#if defined(BOTAN_HAS_AES_NI)
1037 if(CPUID::has_aes_ni()) {
1038 return aesni_key_schedule(key.data(), key.size());
1042#if defined(BOTAN_HAS_AES_VAES)
1043 if(CPUID::has_avx2_vaes()) {
1048#if defined(BOTAN_HAS_HW_AES_SUPPORT)
1054#if defined(BOTAN_HAS_AES_VPERM)
1056 return vperm_key_schedule(key.data(), key.size());
1060 aes_key_schedule(key.data(), key.size(), m_EK, m_DK);
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_ASSERT(expr, assertion_made)
void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
std::string provider() const override
size_t parallelism() const override
bool has_keying_material() const override
void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
bool has_keying_material() const override
void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
std::string provider() const override
size_t parallelism() const override
void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
bool has_keying_material() const override
void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
std::string provider() const override
size_t parallelism() const override
static bool is_little_endian()
void assert_key_material_set() const
constexpr void unpoison(const T *p, size_t n)
constexpr void poison(const T *p, size_t n)
void copy_out_be(std::span< uint8_t > out, InR &&in)
void zap(std::vector< T, Alloc > &vec)
constexpr T rotl(T input)
constexpr T rotr(T input)
constexpr void swap_bits(T &x, T &y, T mask, size_t shift)
constexpr T reverse_bytes(T x)
std::vector< T, secure_allocator< T > > secure_vector
constexpr auto load_be(ParamTs &&... params)
constexpr T bit_permute_step(T x, T mask, size_t shift)