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