Coverage Report

Created: 2023-06-07 07:00

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