Coverage Report

Created: 2020-10-17 06:46

/src/botan/build/include/botan/internal/serpent_sbox.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* Serpent SBox Expressions
3
* (C) 1999-2007,2013 Jack Lloyd
4
*
5
* The sbox expressions used here were discovered by Dag Arne Osvik and
6
* are described in his paper "Speeding Up Serpent".
7
*
8
* Botan is released under the Simplified BSD License (see license.txt)
9
*/
10
11
#ifndef BOTAN_SERPENT_SBOX_H_
12
#define BOTAN_SERPENT_SBOX_H_
13
14
#include <botan/build.h>
15
16
template<typename T>
17
BOTAN_FORCE_INLINE void SBoxE0(T& a, T& b, T& c, T& d)
18
0
   {
19
0
   d ^= a;
20
0
   T t0 = b;
21
0
   b &= d;
22
0
   t0 ^= c;
23
0
   b ^= a;
24
0
   a |= d;
25
0
   a ^= t0;
26
0
   t0 ^= d;
27
0
   d ^= c;
28
0
   c |= b;
29
0
   c ^= t0;
30
0
   t0 = ~t0;
31
0
   t0 |= b;
32
0
   b ^= d;
33
0
   b ^= t0;
34
0
   d |= a;
35
0
   b ^= d;
36
0
   t0 ^= d;
37
0
   d = a;
38
0
   a = b;
39
0
   b = t0;
40
0
   }
Unexecuted instantiation: void SBoxE0<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxE0<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxE0<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
41
42
template<typename T>
43
BOTAN_FORCE_INLINE void SBoxE1(T& a, T& b, T& c, T& d)
44
0
   {
45
0
   a = ~a;
46
0
   c = ~c;
47
0
   T t0 = a;
48
0
   a &= b;
49
0
   c ^= a;
50
0
   a |= d;
51
0
   d ^= c;
52
0
   b ^= a;
53
0
   a ^= t0;
54
0
   t0 |= b;
55
0
   b ^= d;
56
0
   c |= a;
57
0
   c &= t0;
58
0
   a ^= b;
59
0
   b &= c;
60
0
   b ^= a;
61
0
   a &= c;
62
0
   t0 ^= a;
63
0
   a = c;
64
0
   c = d;
65
0
   d = b;
66
0
   b = t0;
67
0
   }
Unexecuted instantiation: void SBoxE1<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxE1<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxE1<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
68
69
template<typename T>
70
BOTAN_FORCE_INLINE void SBoxE2(T& a, T& b, T& c, T& d)
71
0
   {
72
0
   T t0 = a;
73
0
   a &= c;
74
0
   a ^= d;
75
0
   c ^= b;
76
0
   c ^= a;
77
0
   d |= t0;
78
0
   d ^= b;
79
0
   t0 ^= c;
80
0
   b = d;
81
0
   d |= t0;
82
0
   d ^= a;
83
0
   a &= b;
84
0
   t0 ^= a;
85
0
   b ^= d;
86
0
   b ^= t0;
87
0
   a = c;
88
0
   c = b;
89
0
   b = d;
90
0
   d = ~t0;
91
0
   }
Unexecuted instantiation: void SBoxE2<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxE2<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxE2<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
92
93
template<typename T>
94
BOTAN_FORCE_INLINE void SBoxE3(T& a, T& b, T& c, T& d)
95
0
   {
96
0
   T t0 = a;
97
0
   a |= d;
98
0
   d ^= b;
99
0
   b &= t0;
100
0
   t0 ^= c;
101
0
   c ^= d;
102
0
   d &= a;
103
0
   t0 |= b;
104
0
   d ^= t0;
105
0
   a ^= b;
106
0
   t0 &= a;
107
0
   b ^= d;
108
0
   t0 ^= c;
109
0
   b |= a;
110
0
   b ^= c;
111
0
   a ^= d;
112
0
   c = b;
113
0
   b |= d;
114
0
   a ^= b;
115
0
   b = c;
116
0
   c = d;
117
0
   d = t0;
118
0
   }
Unexecuted instantiation: void SBoxE3<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxE3<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxE3<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
119
120
template<typename T>
121
BOTAN_FORCE_INLINE void SBoxE4(T& a, T& b, T& c, T& d)
122
0
   {
123
0
   b ^= d;
124
0
   d = ~d;
125
0
   c ^= d;
126
0
   d ^= a;
127
0
   T t0 = b;
128
0
   b &= d;
129
0
   b ^= c;
130
0
   t0 ^= d;
131
0
   a ^= t0;
132
0
   c &= t0;
133
0
   c ^= a;
134
0
   a &= b;
135
0
   d ^= a;
136
0
   t0 |= b;
137
0
   t0 ^= a;
138
0
   a |= d;
139
0
   a ^= c;
140
0
   c &= d;
141
0
   a = ~a;
142
0
   t0 ^= c;
143
0
   c = a;
144
0
   a = b;
145
0
   b = t0;
146
0
   }
Unexecuted instantiation: void SBoxE4<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxE4<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxE4<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
147
148
template<typename T>
149
BOTAN_FORCE_INLINE void SBoxE5(T& a, T& b, T& c, T& d)
150
0
   {
151
0
   a ^= b;
152
0
   b ^= d;
153
0
   d = ~d;
154
0
   T t0 = b;
155
0
   b &= a;
156
0
   c ^= d;
157
0
   b ^= c;
158
0
   c |= t0;
159
0
   t0 ^= d;
160
0
   d &= b;
161
0
   d ^= a;
162
0
   t0 ^= b;
163
0
   t0 ^= c;
164
0
   c ^= a;
165
0
   a &= d;
166
0
   c = ~c;
167
0
   a ^= t0;
168
0
   t0 |= d;
169
0
   t0 ^= c;
170
0
   c = a;
171
0
   a = b;
172
0
   b = d;
173
0
   d = t0;
174
0
   }
Unexecuted instantiation: void SBoxE5<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxE5<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxE5<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
175
176
template<typename T>
177
BOTAN_FORCE_INLINE void SBoxE6(T& a, T& b, T& c, T& d)
178
0
   {
179
0
   c = ~c;
180
0
   T t0 = d;
181
0
   d &= a;
182
0
   a ^= t0;
183
0
   d ^= c;
184
0
   c |= t0;
185
0
   b ^= d;
186
0
   c ^= a;
187
0
   a |= b;
188
0
   c ^= b;
189
0
   t0 ^= a;
190
0
   a |= d;
191
0
   a ^= c;
192
0
   t0 ^= d;
193
0
   t0 ^= a;
194
0
   d = ~d;
195
0
   c &= t0;
196
0
   d ^= c;
197
0
   c = t0;
198
0
   }
Unexecuted instantiation: void SBoxE6<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxE6<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxE6<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
199
200
template<typename T>
201
BOTAN_FORCE_INLINE void SBoxE7(T& a, T& b, T& c, T& d)
202
0
   {
203
0
   T t0 = b;
204
0
   b |= c;
205
0
   b ^= d;
206
0
   t0 ^= c;
207
0
   c ^= b;
208
0
   d |= t0;
209
0
   d &= a;
210
0
   t0 ^= c;
211
0
   d ^= b;
212
0
   b |= t0;
213
0
   b ^= a;
214
0
   a |= t0;
215
0
   a ^= c;
216
0
   b ^= t0;
217
0
   c ^= b;
218
0
   b &= a;
219
0
   b ^= t0;
220
0
   c = ~c;
221
0
   c |= a;
222
0
   t0 ^= c;
223
0
   c = b;
224
0
   b = d;
225
0
   d = a;
226
0
   a = t0;
227
0
   }
Unexecuted instantiation: void SBoxE7<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxE7<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxE7<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
228
229
template<typename T>
230
BOTAN_FORCE_INLINE void SBoxD0(T& a, T& b, T& c, T& d)
231
0
   {
232
0
   c = ~c;
233
0
   T t0 = b;
234
0
   b |= a;
235
0
   t0 = ~t0;
236
0
   b ^= c;
237
0
   c |= t0;
238
0
   b ^= d;
239
0
   a ^= t0;
240
0
   c ^= a;
241
0
   a &= d;
242
0
   t0 ^= a;
243
0
   a |= b;
244
0
   a ^= c;
245
0
   d ^= t0;
246
0
   c ^= b;
247
0
   d ^= a;
248
0
   d ^= b;
249
0
   c &= d;
250
0
   t0 ^= c;
251
0
   c = b;
252
0
   b = t0;
253
0
   }
Unexecuted instantiation: void SBoxD0<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxD0<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxD0<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
254
255
template<typename T>
256
BOTAN_FORCE_INLINE void SBoxD1(T& a, T& b, T& c, T& d)
257
0
   {
258
0
   T t0 = b;
259
0
   b ^= d;
260
0
   d &= b;
261
0
   t0 ^= c;
262
0
   d ^= a;
263
0
   a |= b;
264
0
   c ^= d;
265
0
   a ^= t0;
266
0
   a |= c;
267
0
   b ^= d;
268
0
   a ^= b;
269
0
   b |= d;
270
0
   b ^= a;
271
0
   t0 = ~t0;
272
0
   t0 ^= b;
273
0
   b |= a;
274
0
   b ^= a;
275
0
   b |= t0;
276
0
   d ^= b;
277
0
   b = a;
278
0
   a = t0;
279
0
   t0 = c;
280
0
   c = d;
281
0
   d = t0;
282
0
   }
Unexecuted instantiation: void SBoxD1<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxD1<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxD1<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
283
284
template<typename T>
285
BOTAN_FORCE_INLINE void SBoxD2(T& a, T& b, T& c, T& d)
286
0
   {
287
0
   c ^= d;
288
0
   d ^= a;
289
0
   T t0 = d;
290
0
   d &= c;
291
0
   d ^= b;
292
0
   b |= c;
293
0
   b ^= t0;
294
0
   t0 &= d;
295
0
   c ^= d;
296
0
   t0 &= a;
297
0
   t0 ^= c;
298
0
   c &= b;
299
0
   c |= a;
300
0
   d = ~d;
301
0
   c ^= d;
302
0
   a ^= d;
303
0
   a &= b;
304
0
   d ^= t0;
305
0
   d ^= a;
306
0
   a = b;
307
0
   b = t0;
308
0
   }
Unexecuted instantiation: void SBoxD2<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxD2<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxD2<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
309
310
template<typename T>
311
BOTAN_FORCE_INLINE void SBoxD3(T& a, T& b, T& c, T& d)
312
0
   {
313
0
   T t0 = c;
314
0
   c ^= b;
315
0
   a ^= c;
316
0
   t0 &= c;
317
0
   t0 ^= a;
318
0
   a &= b;
319
0
   b ^= d;
320
0
   d |= t0;
321
0
   c ^= d;
322
0
   a ^= d;
323
0
   b ^= t0;
324
0
   d &= c;
325
0
   d ^= b;
326
0
   b ^= a;
327
0
   b |= c;
328
0
   a ^= d;
329
0
   b ^= t0;
330
0
   a ^= b;
331
0
   t0 = a;
332
0
   a = c;
333
0
   c = d;
334
0
   d = t0;
335
0
   }
Unexecuted instantiation: void SBoxD3<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxD3<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxD3<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
336
337
template<typename T>
338
BOTAN_FORCE_INLINE void SBoxD4(T& a, T& b, T& c, T& d)
339
0
   {
340
0
   T t0 = c;
341
0
   c &= d;
342
0
   c ^= b;
343
0
   b |= d;
344
0
   b &= a;
345
0
   t0 ^= c;
346
0
   t0 ^= b;
347
0
   b &= c;
348
0
   a = ~a;
349
0
   d ^= t0;
350
0
   b ^= d;
351
0
   d &= a;
352
0
   d ^= c;
353
0
   a ^= b;
354
0
   c &= a;
355
0
   d ^= a;
356
0
   c ^= t0;
357
0
   c |= d;
358
0
   d ^= a;
359
0
   c ^= b;
360
0
   b = d;
361
0
   d = t0;
362
0
   }
Unexecuted instantiation: void SBoxD4<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxD4<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxD4<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
363
364
template<typename T>
365
BOTAN_FORCE_INLINE void SBoxD5(T& a, T& b, T& c, T& d)
366
0
   {
367
0
   b = ~b;
368
0
   T t0 = d;
369
0
   c ^= b;
370
0
   d |= a;
371
0
   d ^= c;
372
0
   c |= b;
373
0
   c &= a;
374
0
   t0 ^= d;
375
0
   c ^= t0;
376
0
   t0 |= a;
377
0
   t0 ^= b;
378
0
   b &= c;
379
0
   b ^= d;
380
0
   t0 ^= c;
381
0
   d &= t0;
382
0
   t0 ^= b;
383
0
   d ^= t0;
384
0
   t0 = ~t0;
385
0
   d ^= a;
386
0
   a = b;
387
0
   b = t0;
388
0
   t0 = d;
389
0
   d = c;
390
0
   c = t0;
391
0
   }
Unexecuted instantiation: void SBoxD5<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxD5<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxD5<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
392
393
template<typename T>
394
BOTAN_FORCE_INLINE void SBoxD6(T& a, T& b, T& c, T& d)
395
0
   {
396
0
   a ^= c;
397
0
   T t0 = c;
398
0
   c &= a;
399
0
   t0 ^= d;
400
0
   c = ~c;
401
0
   d ^= b;
402
0
   c ^= d;
403
0
   t0 |= a;
404
0
   a ^= c;
405
0
   d ^= t0;
406
0
   t0 ^= b;
407
0
   b &= d;
408
0
   b ^= a;
409
0
   a ^= d;
410
0
   a |= c;
411
0
   d ^= b;
412
0
   t0 ^= a;
413
0
   a = b;
414
0
   b = c;
415
0
   c = t0;
416
0
   }
Unexecuted instantiation: void SBoxD6<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxD6<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxD6<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
417
418
template<typename T>
419
BOTAN_FORCE_INLINE void SBoxD7(T& a, T& b, T& c, T& d)
420
0
   {
421
0
   T t0 = c;
422
0
   c ^= a;
423
0
   a &= d;
424
0
   t0 |= d;
425
0
   c = ~c;
426
0
   d ^= b;
427
0
   b |= a;
428
0
   a ^= c;
429
0
   c &= t0;
430
0
   d &= t0;
431
0
   b ^= c;
432
0
   c ^= a;
433
0
   a |= c;
434
0
   t0 ^= b;
435
0
   a ^= d;
436
0
   d ^= t0;
437
0
   t0 |= a;
438
0
   d ^= c;
439
0
   t0 ^= c;
440
0
   c = b;
441
0
   b = a;
442
0
   a = d;
443
0
   d = t0;
444
0
   }
Unexecuted instantiation: void SBoxD7<unsigned int>(unsigned int&, unsigned int&, unsigned int&, unsigned int&)
Unexecuted instantiation: void SBoxD7<Botan::SIMD_8x32>(Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&, Botan::SIMD_8x32&)
Unexecuted instantiation: void SBoxD7<Botan::SIMD_4x32>(Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&, Botan::SIMD_4x32&)
445
446
#endif