Botan 3.9.0
Crypto and TLS for C&
serpent_avx512.cpp
Go to the documentation of this file.
1/*
2* (C) 2023 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/internal/serpent.h>
8
9#include <botan/internal/serpent_sbox.h>
10#include <botan/internal/simd_avx512.h>
11
12namespace Botan {
13
14namespace {
15
17 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0xb9>(b, d, c);
18 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0xe2>(a, b, d);
19 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0x36>(a, b, d);
20 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x26>(t0, d, b);
21 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t3);
22 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0x96>(t1, c, o0);
23 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0xa9>(o0, o1, t2);
24 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x3c>(t2, c, t0);
25 a = o0;
26 b = o1;
27 c = o2;
28 d = o3;
29}
30
32 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0xe5>(d, b, c);
33 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x26>(c, d, b);
34 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0xa6>(a, b, c);
35 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x2b>(a, b, d);
36 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
37 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0x83>(t2, d, t0);
38 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x69>(t3, c, o1);
39 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0x65>(o3, o1, t2);
40 a = o0;
41 b = o1;
42 c = o2;
43 d = o3;
44}
45
47 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0x96>(c, b, d);
48 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0xda>(a, b, c);
49 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0x66>(d, t0, c);
50 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x94>(a, b, t0);
51 const SIMD_16x32 t4 = SIMD_16x32::ternary_fn<0xa1>(a, d, t0);
52 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t2);
53 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0xd2>(t3, d, o0);
54 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0x2d>(t4, b, c);
55 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x2d>(t1, d, t2);
56 a = o0;
57 b = o1;
58 c = o2;
59 d = o3;
60}
61
63 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0x92>(d, c, b);
64 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x3b>(d, b, c);
65 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0xbc>(a, c, t0);
66 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0x68>(t2, d, t1);
67 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x6e>(a, c, o2);
68 const SIMD_16x32 t4 = SIMD_16x32::ternary_fn<0xb9>(a, d, t3);
69 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
70 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0x6d>(t4, b, t2);
71 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x38>(t3, b, t0);
72 a = o0;
73 b = o1;
74 c = o2;
75 d = o3;
76}
77
79 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0xc2>(c, b, d);
80 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x79>(b, c, d);
81 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0x71>(a, b, d);
82 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x6b>(a, b, d);
83 const SIMD_16x32 t4 = SIMD_16x32::ternary_fn<0xc2>(a, t0, t3);
84 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
85 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0x3c>(t2, c, t0);
86 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x49>(t3, c, t0);
87 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0xd6>(t4, b, t1);
88 a = o0;
89 b = o1;
90 c = o2;
91 d = o3;
92}
93
95 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0xa9>(b, d, c);
96 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x93>(b, c, d);
97 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0xc3>(a, b, c);
98 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x27>(a, b, d);
99 const SIMD_16x32 t4 = SIMD_16x32::ternary_fn<0x85>(a, c, t1);
100 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
101 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0x2d>(t2, d, o0);
102 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0x7a>(t4, b, t0);
103 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x87>(t3, t0, o0);
104 a = o0;
105 b = o1;
106 c = o2;
107 d = o3;
108}
109
111 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0x61>(d, c, b);
112 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x9c>(b, d, t0);
113 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0x93>(a, b, d);
114 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0xb5>(a, b, c);
115 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
116 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0x3c>(t2, c, t0);
117 const SIMD_16x32 t4 = SIMD_16x32::ternary_fn<0x7c>(a, b, o1);
118 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0x1e>(t4, d, t0);
119 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x29>(t3, t0, t1);
120 a = o0;
121 b = o1;
122 c = o2;
123 d = o3;
124}
125
127 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0x9b>(b, c, d);
128 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x61>(c, b, d);
129 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0xe3>(a, d, t1);
130 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x83>(b, c, d);
131 const SIMD_16x32 t4 = SIMD_16x32::ternary_fn<0x49>(a, b, c);
132 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
133 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0xe1>(t2, b, c);
134 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0xd1>(t3, a, t1);
135 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x87>(t4, d, t2);
136 a = o0;
137 b = o1;
138 c = o2;
139 d = o3;
140}
141
143 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0x67>(c, d, b);
144 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x49>(b, d, c);
145 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
146 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0xa9>(a, b, c);
147 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0x3c>(t2, d, t0);
148 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x4d>(a, b, d);
149 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x69>(t3, c, o0);
150 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0x56>(o3, o0, t2);
151 a = o0;
152 b = o1;
153 c = o2;
154 d = o3;
155}
156
158 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0x73>(d, b, c);
159 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x68>(c, d, b);
160 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0xc5>(a, b, d);
161 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x2d>(a, b, d);
162 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
163 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0x96>(t2, c, o0);
164 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0xd2>(t3, o0, o1);
165 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x99>(o0, t3, c);
166 a = o0;
167 b = o1;
168 c = o2;
169 d = o3;
170}
171
173 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0xc6>(d, b, c);
174 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x9c>(d, c, b);
175 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0xe1>(a, b, c);
176 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0x87>(t2, d, t0);
177 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
178 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0xd1>(t0, a, t1);
179 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x9b>(a, c, o2);
180 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x5b>(t3, b, d);
181 a = o0;
182 b = o1;
183 c = o2;
184 d = o3;
185}
186
188 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0x94>(c, d, b);
189 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x99>(b, d, t0);
190 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
191 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0x97>(a, b, d);
192 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0x4b>(t2, c, o0);
193 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x94>(c, d, t2);
194 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0x0e>(t3, b, t0);
195 const SIMD_16x32 t4 = SIMD_16x32::ternary_fn<0x1c>(a, b, t0);
196 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0xb4>(t4, c, d);
197 a = o0;
198 b = o1;
199 c = o2;
200 d = o3;
201}
202
204 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0xa9>(d, c, b);
205 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0xa6>(d, b, c);
206 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0xb5>(a, b, d);
207 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x5e>(a, b, d);
208 const SIMD_16x32 t4 = SIMD_16x32::ternary_fn<0x50>(a, b, t0);
209 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
210 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0x96>(t4, c, d);
211 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0x4b>(t3, c, t4);
212 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x5a>(t2, c, t0);
213 a = o0;
214 b = o1;
215 c = o2;
216 d = o3;
217}
218
220 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0xc9>(a, b, c);
221 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x65>(a, b, c);
222 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0x25>(a, b, d);
223 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x63>(c, d, t0);
224 const SIMD_16x32 t4 = SIMD_16x32::ternary_fn<0x86>(a, b, t3);
225 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0x87>(t2, c, t0);
226 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0xc3>(t4, c, d);
227 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0x47>(t1, d, t0);
228 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0xac>(a, t0, t3);
229 a = o0;
230 b = o1;
231 c = o2;
232 d = o3;
233}
234
236 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0x07>(d, b, c);
237 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x9e>(c, d, b);
238 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0xc6>(a, b, c);
239 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x34>(a, b, d);
240 const SIMD_16x32 t4 = SIMD_16x32::ternary_fn<0x2b>(a, c, d);
241 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t1);
242 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0xcb>(t2, d, t0);
243 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0x4b>(t3, c, t0);
244 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x69>(t4, b, o0);
245 a = o0;
246 b = o1;
247 c = o2;
248 d = o3;
249}
250
252 const SIMD_16x32 t0 = SIMD_16x32::ternary_fn<0x67>(b, d, c);
253 const SIMD_16x32 t1 = SIMD_16x32::ternary_fn<0x3e>(a, c, d);
254 const SIMD_16x32 t2 = SIMD_16x32::ternary_fn<0x1c>(a, b, d);
255 const SIMD_16x32 t3 = SIMD_16x32::ternary_fn<0x87>(t0, d, b);
256 const SIMD_16x32 t4 = SIMD_16x32::ternary_fn<0x7d>(a, b, t1);
257 const SIMD_16x32 o0 = SIMD_16x32::ternary_fn<0xac>(a, t0, t3);
258 const SIMD_16x32 o1 = SIMD_16x32::ternary_fn<0x96>(t1, b, t0);
259 const SIMD_16x32 o2 = SIMD_16x32::ternary_fn<0xd2>(t2, c, t1);
260 const SIMD_16x32 o3 = SIMD_16x32::ternary_fn<0x6d>(t4, c, d);
261 a = o0;
262 b = o1;
263 c = o2;
264 d = o3;
265}
266
267} // namespace
268
269void BOTAN_FN_ISA_AVX512 Serpent::avx512_encrypt_16(const uint8_t in[16 * 16], uint8_t out[16 * 16]) const {
270 using namespace Botan::Serpent_F;
271
272 SIMD_16x32 B0 = SIMD_16x32::load_le(in);
273 SIMD_16x32 B1 = SIMD_16x32::load_le(in + 64);
274 SIMD_16x32 B2 = SIMD_16x32::load_le(in + 128);
275 SIMD_16x32 B3 = SIMD_16x32::load_le(in + 192);
276
277 SIMD_16x32::transpose(B0, B1, B2, B3);
278
279 const Key_Inserter key_xor(m_round_key.data());
280
281 key_xor(0, B0, B1, B2, B3);
282 SBoxE0(B0, B1, B2, B3);
283 transform(B0, B1, B2, B3);
284 key_xor(1, B0, B1, B2, B3);
285 SBoxE1(B0, B1, B2, B3);
286 transform(B0, B1, B2, B3);
287 key_xor(2, B0, B1, B2, B3);
288 SBoxE2(B0, B1, B2, B3);
289 transform(B0, B1, B2, B3);
290 key_xor(3, B0, B1, B2, B3);
291 SBoxE3(B0, B1, B2, B3);
292 transform(B0, B1, B2, B3);
293 key_xor(4, B0, B1, B2, B3);
294 SBoxE4(B0, B1, B2, B3);
295 transform(B0, B1, B2, B3);
296 key_xor(5, B0, B1, B2, B3);
297 SBoxE5(B0, B1, B2, B3);
298 transform(B0, B1, B2, B3);
299 key_xor(6, B0, B1, B2, B3);
300 SBoxE6(B0, B1, B2, B3);
301 transform(B0, B1, B2, B3);
302 key_xor(7, B0, B1, B2, B3);
303 SBoxE7(B0, B1, B2, B3);
304 transform(B0, B1, B2, B3);
305
306 key_xor(8, B0, B1, B2, B3);
307 SBoxE0(B0, B1, B2, B3);
308 transform(B0, B1, B2, B3);
309 key_xor(9, B0, B1, B2, B3);
310 SBoxE1(B0, B1, B2, B3);
311 transform(B0, B1, B2, B3);
312 key_xor(10, B0, B1, B2, B3);
313 SBoxE2(B0, B1, B2, B3);
314 transform(B0, B1, B2, B3);
315 key_xor(11, B0, B1, B2, B3);
316 SBoxE3(B0, B1, B2, B3);
317 transform(B0, B1, B2, B3);
318 key_xor(12, B0, B1, B2, B3);
319 SBoxE4(B0, B1, B2, B3);
320 transform(B0, B1, B2, B3);
321 key_xor(13, B0, B1, B2, B3);
322 SBoxE5(B0, B1, B2, B3);
323 transform(B0, B1, B2, B3);
324 key_xor(14, B0, B1, B2, B3);
325 SBoxE6(B0, B1, B2, B3);
326 transform(B0, B1, B2, B3);
327 key_xor(15, B0, B1, B2, B3);
328 SBoxE7(B0, B1, B2, B3);
329 transform(B0, B1, B2, B3);
330
331 key_xor(16, B0, B1, B2, B3);
332 SBoxE0(B0, B1, B2, B3);
333 transform(B0, B1, B2, B3);
334 key_xor(17, B0, B1, B2, B3);
335 SBoxE1(B0, B1, B2, B3);
336 transform(B0, B1, B2, B3);
337 key_xor(18, B0, B1, B2, B3);
338 SBoxE2(B0, B1, B2, B3);
339 transform(B0, B1, B2, B3);
340 key_xor(19, B0, B1, B2, B3);
341 SBoxE3(B0, B1, B2, B3);
342 transform(B0, B1, B2, B3);
343 key_xor(20, B0, B1, B2, B3);
344 SBoxE4(B0, B1, B2, B3);
345 transform(B0, B1, B2, B3);
346 key_xor(21, B0, B1, B2, B3);
347 SBoxE5(B0, B1, B2, B3);
348 transform(B0, B1, B2, B3);
349 key_xor(22, B0, B1, B2, B3);
350 SBoxE6(B0, B1, B2, B3);
351 transform(B0, B1, B2, B3);
352 key_xor(23, B0, B1, B2, B3);
353 SBoxE7(B0, B1, B2, B3);
354 transform(B0, B1, B2, B3);
355
356 key_xor(24, B0, B1, B2, B3);
357 SBoxE0(B0, B1, B2, B3);
358 transform(B0, B1, B2, B3);
359 key_xor(25, B0, B1, B2, B3);
360 SBoxE1(B0, B1, B2, B3);
361 transform(B0, B1, B2, B3);
362 key_xor(26, B0, B1, B2, B3);
363 SBoxE2(B0, B1, B2, B3);
364 transform(B0, B1, B2, B3);
365 key_xor(27, B0, B1, B2, B3);
366 SBoxE3(B0, B1, B2, B3);
367 transform(B0, B1, B2, B3);
368 key_xor(28, B0, B1, B2, B3);
369 SBoxE4(B0, B1, B2, B3);
370 transform(B0, B1, B2, B3);
371 key_xor(29, B0, B1, B2, B3);
372 SBoxE5(B0, B1, B2, B3);
373 transform(B0, B1, B2, B3);
374 key_xor(30, B0, B1, B2, B3);
375 SBoxE6(B0, B1, B2, B3);
376 transform(B0, B1, B2, B3);
377 key_xor(31, B0, B1, B2, B3);
378 SBoxE7(B0, B1, B2, B3);
379 key_xor(32, B0, B1, B2, B3);
380
381 SIMD_16x32::transpose(B0, B1, B2, B3);
382 B0.store_le(out);
383 B1.store_le(out + 64);
384 B2.store_le(out + 128);
385 B3.store_le(out + 192);
386
388}
389
390void BOTAN_FN_ISA_AVX512 Serpent::avx512_decrypt_16(const uint8_t in[16 * 16], uint8_t out[16 * 16]) const {
391 using namespace Botan::Serpent_F;
392
393 SIMD_16x32 B0 = SIMD_16x32::load_le(in);
394 SIMD_16x32 B1 = SIMD_16x32::load_le(in + 64);
395 SIMD_16x32 B2 = SIMD_16x32::load_le(in + 128);
396 SIMD_16x32 B3 = SIMD_16x32::load_le(in + 192);
397
398 SIMD_16x32::transpose(B0, B1, B2, B3);
399
400 const Key_Inserter key_xor(m_round_key.data());
401
402 key_xor(32, B0, B1, B2, B3);
403 SBoxD7(B0, B1, B2, B3);
404 key_xor(31, B0, B1, B2, B3);
405 i_transform(B0, B1, B2, B3);
406 SBoxD6(B0, B1, B2, B3);
407 key_xor(30, B0, B1, B2, B3);
408 i_transform(B0, B1, B2, B3);
409 SBoxD5(B0, B1, B2, B3);
410 key_xor(29, B0, B1, B2, B3);
411 i_transform(B0, B1, B2, B3);
412 SBoxD4(B0, B1, B2, B3);
413 key_xor(28, B0, B1, B2, B3);
414 i_transform(B0, B1, B2, B3);
415 SBoxD3(B0, B1, B2, B3);
416 key_xor(27, B0, B1, B2, B3);
417 i_transform(B0, B1, B2, B3);
418 SBoxD2(B0, B1, B2, B3);
419 key_xor(26, B0, B1, B2, B3);
420 i_transform(B0, B1, B2, B3);
421 SBoxD1(B0, B1, B2, B3);
422 key_xor(25, B0, B1, B2, B3);
423 i_transform(B0, B1, B2, B3);
424 SBoxD0(B0, B1, B2, B3);
425 key_xor(24, B0, B1, B2, B3);
426
427 i_transform(B0, B1, B2, B3);
428 SBoxD7(B0, B1, B2, B3);
429 key_xor(23, B0, B1, B2, B3);
430 i_transform(B0, B1, B2, B3);
431 SBoxD6(B0, B1, B2, B3);
432 key_xor(22, B0, B1, B2, B3);
433 i_transform(B0, B1, B2, B3);
434 SBoxD5(B0, B1, B2, B3);
435 key_xor(21, B0, B1, B2, B3);
436 i_transform(B0, B1, B2, B3);
437 SBoxD4(B0, B1, B2, B3);
438 key_xor(20, B0, B1, B2, B3);
439 i_transform(B0, B1, B2, B3);
440 SBoxD3(B0, B1, B2, B3);
441 key_xor(19, B0, B1, B2, B3);
442 i_transform(B0, B1, B2, B3);
443 SBoxD2(B0, B1, B2, B3);
444 key_xor(18, B0, B1, B2, B3);
445 i_transform(B0, B1, B2, B3);
446 SBoxD1(B0, B1, B2, B3);
447 key_xor(17, B0, B1, B2, B3);
448 i_transform(B0, B1, B2, B3);
449 SBoxD0(B0, B1, B2, B3);
450 key_xor(16, B0, B1, B2, B3);
451
452 i_transform(B0, B1, B2, B3);
453 SBoxD7(B0, B1, B2, B3);
454 key_xor(15, B0, B1, B2, B3);
455 i_transform(B0, B1, B2, B3);
456 SBoxD6(B0, B1, B2, B3);
457 key_xor(14, B0, B1, B2, B3);
458 i_transform(B0, B1, B2, B3);
459 SBoxD5(B0, B1, B2, B3);
460 key_xor(13, B0, B1, B2, B3);
461 i_transform(B0, B1, B2, B3);
462 SBoxD4(B0, B1, B2, B3);
463 key_xor(12, B0, B1, B2, B3);
464 i_transform(B0, B1, B2, B3);
465 SBoxD3(B0, B1, B2, B3);
466 key_xor(11, B0, B1, B2, B3);
467 i_transform(B0, B1, B2, B3);
468 SBoxD2(B0, B1, B2, B3);
469 key_xor(10, B0, B1, B2, B3);
470 i_transform(B0, B1, B2, B3);
471 SBoxD1(B0, B1, B2, B3);
472 key_xor(9, B0, B1, B2, B3);
473 i_transform(B0, B1, B2, B3);
474 SBoxD0(B0, B1, B2, B3);
475 key_xor(8, B0, B1, B2, B3);
476
477 i_transform(B0, B1, B2, B3);
478 SBoxD7(B0, B1, B2, B3);
479 key_xor(7, B0, B1, B2, B3);
480 i_transform(B0, B1, B2, B3);
481 SBoxD6(B0, B1, B2, B3);
482 key_xor(6, B0, B1, B2, B3);
483 i_transform(B0, B1, B2, B3);
484 SBoxD5(B0, B1, B2, B3);
485 key_xor(5, B0, B1, B2, B3);
486 i_transform(B0, B1, B2, B3);
487 SBoxD4(B0, B1, B2, B3);
488 key_xor(4, B0, B1, B2, B3);
489 i_transform(B0, B1, B2, B3);
490 SBoxD3(B0, B1, B2, B3);
491 key_xor(3, B0, B1, B2, B3);
492 i_transform(B0, B1, B2, B3);
493 SBoxD2(B0, B1, B2, B3);
494 key_xor(2, B0, B1, B2, B3);
495 i_transform(B0, B1, B2, B3);
496 SBoxD1(B0, B1, B2, B3);
497 key_xor(1, B0, B1, B2, B3);
498 i_transform(B0, B1, B2, B3);
499 SBoxD0(B0, B1, B2, B3);
500 key_xor(0, B0, B1, B2, B3);
501
502 SIMD_16x32::transpose(B0, B1, B2, B3);
503
504 B0.store_le(out);
505 B1.store_le(out + 64);
506 B2.store_le(out + 128);
507 B3.store_le(out + 192);
508
510}
511
512} // namespace Botan
static BOTAN_FN_ISA_AVX512 void transpose(SIMD_16x32 &B0, SIMD_16x32 &B1, SIMD_16x32 &B2, SIMD_16x32 &B3)
BOTAN_FN_ISA_AVX512 void store_le(uint8_t out[]) const
Definition simd_avx512.h:71
static BOTAN_FN_ISA_AVX512 SIMD_16x32 ternary_fn(const SIMD_16x32 &a, const SIMD_16x32 &b, const SIMD_16x32 &c)
static BOTAN_FN_ISA_AVX512 SIMD_16x32 load_le(const uint8_t *in)
Definition simd_avx512.h:63
static BOTAN_FN_ISA_AVX512 void zero_registers()
#define BOTAN_FORCE_INLINE
Definition compiler.h:87
BOTAN_FORCE_INLINE void transform(T &B0, T &B1, T &B2, T &B3)
Definition serpent_fn.h:35
BOTAN_FORCE_INLINE void SBoxD5(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxD4(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxE0(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxE1(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxE3(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxD0(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxE5(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxD6(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxD3(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void i_transform(T &B0, T &B1, T &B2, T &B3)
Definition serpent_fn.h:52
BOTAN_FORCE_INLINE void SBoxD2(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxE6(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxE2(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxE4(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxD1(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxE7(T &a, T &b, T &c, T &d)
BOTAN_FORCE_INLINE void SBoxD7(T &a, T &b, T &c, T &d)