Botan  2.19.1
Crypto and TLS for C++11
Functions
serpent_sbox.h File Reference
#include <botan/build.h>

Go to the source code of this file.

Functions

template<typename T >
BOTAN_FORCE_INLINE void SBoxD0 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxD1 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxD2 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxD3 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxD4 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxD5 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxD6 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxD7 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxE0 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxE1 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxE2 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxE3 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxE4 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxE5 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxE6 (T &a, T &b, T &c, T &d)
 
template<typename T >
BOTAN_FORCE_INLINE void SBoxE7 (T &a, T &b, T &c, T &d)
 

Function Documentation

template<typename T >
BOTAN_FORCE_INLINE void SBoxD0 ( T a,
T b,
T c,
T d 
)

Definition at line 230 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::decrypt_n().

231  {
232  c = ~c;
233  T t0 = b;
234  b |= a;
235  t0 = ~t0;
236  b ^= c;
237  c |= t0;
238  b ^= d;
239  a ^= t0;
240  c ^= a;
241  a &= d;
242  t0 ^= a;
243  a |= b;
244  a ^= c;
245  d ^= t0;
246  c ^= b;
247  d ^= a;
248  d ^= b;
249  c &= d;
250  t0 ^= c;
251  c = b;
252  b = t0;
253  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxD1 ( T a,
T b,
T c,
T d 
)

Definition at line 256 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::decrypt_n().

257  {
258  T t0 = b;
259  b ^= d;
260  d &= b;
261  t0 ^= c;
262  d ^= a;
263  a |= b;
264  c ^= d;
265  a ^= t0;
266  a |= c;
267  b ^= d;
268  a ^= b;
269  b |= d;
270  b ^= a;
271  t0 = ~t0;
272  t0 ^= b;
273  b |= a;
274  b ^= a;
275  b |= t0;
276  d ^= b;
277  b = a;
278  a = t0;
279  t0 = c;
280  c = d;
281  d = t0;
282  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxD2 ( T a,
T b,
T c,
T d 
)

Definition at line 285 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::decrypt_n().

286  {
287  c ^= d;
288  d ^= a;
289  T t0 = d;
290  d &= c;
291  d ^= b;
292  b |= c;
293  b ^= t0;
294  t0 &= d;
295  c ^= d;
296  t0 &= a;
297  t0 ^= c;
298  c &= b;
299  c |= a;
300  d = ~d;
301  c ^= d;
302  a ^= d;
303  a &= b;
304  d ^= t0;
305  d ^= a;
306  a = b;
307  b = t0;
308  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxD3 ( T a,
T b,
T c,
T d 
)

Definition at line 311 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::decrypt_n().

312  {
313  T t0 = c;
314  c ^= b;
315  a ^= c;
316  t0 &= c;
317  t0 ^= a;
318  a &= b;
319  b ^= d;
320  d |= t0;
321  c ^= d;
322  a ^= d;
323  b ^= t0;
324  d &= c;
325  d ^= b;
326  b ^= a;
327  b |= c;
328  a ^= d;
329  b ^= t0;
330  a ^= b;
331  t0 = a;
332  a = c;
333  c = d;
334  d = t0;
335  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxD4 ( T a,
T b,
T c,
T d 
)

Definition at line 338 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::decrypt_n().

339  {
340  T t0 = c;
341  c &= d;
342  c ^= b;
343  b |= d;
344  b &= a;
345  t0 ^= c;
346  t0 ^= b;
347  b &= c;
348  a = ~a;
349  d ^= t0;
350  b ^= d;
351  d &= a;
352  d ^= c;
353  a ^= b;
354  c &= a;
355  d ^= a;
356  c ^= t0;
357  c |= d;
358  d ^= a;
359  c ^= b;
360  b = d;
361  d = t0;
362  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxD5 ( T a,
T b,
T c,
T d 
)

Definition at line 365 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::decrypt_n().

366  {
367  b = ~b;
368  T t0 = d;
369  c ^= b;
370  d |= a;
371  d ^= c;
372  c |= b;
373  c &= a;
374  t0 ^= d;
375  c ^= t0;
376  t0 |= a;
377  t0 ^= b;
378  b &= c;
379  b ^= d;
380  t0 ^= c;
381  d &= t0;
382  t0 ^= b;
383  d ^= t0;
384  t0 = ~t0;
385  d ^= a;
386  a = b;
387  b = t0;
388  t0 = d;
389  d = c;
390  c = t0;
391  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxD6 ( T a,
T b,
T c,
T d 
)

Definition at line 394 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::decrypt_n().

395  {
396  a ^= c;
397  T t0 = c;
398  c &= a;
399  t0 ^= d;
400  c = ~c;
401  d ^= b;
402  c ^= d;
403  t0 |= a;
404  a ^= c;
405  d ^= t0;
406  t0 ^= b;
407  b &= d;
408  b ^= a;
409  a ^= d;
410  a |= c;
411  d ^= b;
412  t0 ^= a;
413  a = b;
414  b = c;
415  c = t0;
416  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxD7 ( T a,
T b,
T c,
T d 
)

Definition at line 419 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::decrypt_n().

420  {
421  T t0 = c;
422  c ^= a;
423  a &= d;
424  t0 |= d;
425  c = ~c;
426  d ^= b;
427  b |= a;
428  a ^= c;
429  c &= t0;
430  d &= t0;
431  b ^= c;
432  c ^= a;
433  a |= c;
434  t0 ^= b;
435  a ^= d;
436  d ^= t0;
437  t0 |= a;
438  d ^= c;
439  t0 ^= c;
440  c = b;
441  b = a;
442  a = d;
443  d = t0;
444  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxE0 ( T a,
T b,
T c,
T d 
)

Definition at line 17 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::encrypt_n().

18  {
19  d ^= a;
20  T t0 = b;
21  b &= d;
22  t0 ^= c;
23  b ^= a;
24  a |= d;
25  a ^= t0;
26  t0 ^= d;
27  d ^= c;
28  c |= b;
29  c ^= t0;
30  t0 = ~t0;
31  t0 |= b;
32  b ^= d;
33  b ^= t0;
34  d |= a;
35  b ^= d;
36  t0 ^= d;
37  d = a;
38  a = b;
39  b = t0;
40  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxE1 ( T a,
T b,
T c,
T d 
)

Definition at line 43 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::encrypt_n().

44  {
45  a = ~a;
46  c = ~c;
47  T t0 = a;
48  a &= b;
49  c ^= a;
50  a |= d;
51  d ^= c;
52  b ^= a;
53  a ^= t0;
54  t0 |= b;
55  b ^= d;
56  c |= a;
57  c &= t0;
58  a ^= b;
59  b &= c;
60  b ^= a;
61  a &= c;
62  t0 ^= a;
63  a = c;
64  c = d;
65  d = b;
66  b = t0;
67  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxE2 ( T a,
T b,
T c,
T d 
)

Definition at line 70 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::encrypt_n().

71  {
72  T t0 = a;
73  a &= c;
74  a ^= d;
75  c ^= b;
76  c ^= a;
77  d |= t0;
78  d ^= b;
79  t0 ^= c;
80  b = d;
81  d |= t0;
82  d ^= a;
83  a &= b;
84  t0 ^= a;
85  b ^= d;
86  b ^= t0;
87  a = c;
88  c = b;
89  b = d;
90  d = ~t0;
91  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxE3 ( T a,
T b,
T c,
T d 
)

Definition at line 94 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::encrypt_n().

95  {
96  T t0 = a;
97  a |= d;
98  d ^= b;
99  b &= t0;
100  t0 ^= c;
101  c ^= d;
102  d &= a;
103  t0 |= b;
104  d ^= t0;
105  a ^= b;
106  t0 &= a;
107  b ^= d;
108  t0 ^= c;
109  b |= a;
110  b ^= c;
111  a ^= d;
112  c = b;
113  b |= d;
114  a ^= b;
115  b = c;
116  c = d;
117  d = t0;
118  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxE4 ( T a,
T b,
T c,
T d 
)

Definition at line 121 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::encrypt_n().

122  {
123  b ^= d;
124  d = ~d;
125  c ^= d;
126  d ^= a;
127  T t0 = b;
128  b &= d;
129  b ^= c;
130  t0 ^= d;
131  a ^= t0;
132  c &= t0;
133  c ^= a;
134  a &= b;
135  d ^= a;
136  t0 |= b;
137  t0 ^= a;
138  a |= d;
139  a ^= c;
140  c &= d;
141  a = ~a;
142  t0 ^= c;
143  c = a;
144  a = b;
145  b = t0;
146  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxE5 ( T a,
T b,
T c,
T d 
)

Definition at line 149 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::encrypt_n().

150  {
151  a ^= b;
152  b ^= d;
153  d = ~d;
154  T t0 = b;
155  b &= a;
156  c ^= d;
157  b ^= c;
158  c |= t0;
159  t0 ^= d;
160  d &= b;
161  d ^= a;
162  t0 ^= b;
163  t0 ^= c;
164  c ^= a;
165  a &= d;
166  c = ~c;
167  a ^= t0;
168  t0 |= d;
169  t0 ^= c;
170  c = a;
171  a = b;
172  b = d;
173  d = t0;
174  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxE6 ( T a,
T b,
T c,
T d 
)

Definition at line 177 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::encrypt_n().

178  {
179  c = ~c;
180  T t0 = d;
181  d &= a;
182  a ^= t0;
183  d ^= c;
184  c |= t0;
185  b ^= d;
186  c ^= a;
187  a |= b;
188  c ^= b;
189  t0 ^= a;
190  a |= d;
191  a ^= c;
192  t0 ^= d;
193  t0 ^= a;
194  d = ~d;
195  c &= t0;
196  d ^= c;
197  c = t0;
198  }
fe T
Definition: ge.cpp:37
template<typename T >
BOTAN_FORCE_INLINE void SBoxE7 ( T a,
T b,
T c,
T d 
)

Definition at line 201 of file serpent_sbox.h.

References T.

Referenced by Botan::Serpent::encrypt_n().

202  {
203  T t0 = b;
204  b |= c;
205  b ^= d;
206  t0 ^= c;
207  c ^= b;
208  d |= t0;
209  d &= a;
210  t0 ^= c;
211  d ^= b;
212  b |= t0;
213  b ^= a;
214  a |= t0;
215  a ^= c;
216  b ^= t0;
217  c ^= b;
218  b &= a;
219  b ^= t0;
220  c = ~c;
221  c |= a;
222  t0 ^= c;
223  c = b;
224  b = d;
225  d = a;
226  a = t0;
227  }
fe T
Definition: ge.cpp:37