Botan 3.6.1
Crypto and TLS for C&
Botan::Serpent_F Namespace Reference

Classes

class  Key_Inserter
 

Functions

template<typename T >
BOTAN_FORCE_INLINE void i_transform (T &B0, T &B1, T &B2, T &B3)
 
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)
 
template<size_t S>
BOTAN_FORCE_INLINE uint32_t shl (uint32_t v)
 
template<typename T >
BOTAN_FORCE_INLINE void transform (T &B0, T &B1, T &B2, T &B3)
 

Function Documentation

◆ i_transform()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::i_transform ( T & B0,
T & B1,
T & B2,
T & B3 )

Definition at line 41 of file serpent_fn.h.

41 {
42 B2 = rotr<22>(B2);
43 B0 = rotr<5>(B0);
44 B2 ^= B3 ^ shl<7>(B1);
45 B0 ^= B1 ^ B3;
46 B3 = rotr<7>(B3);
47 B1 = rotr<1>(B1);
48 B3 ^= B2 ^ shl<3>(B0);
49 B1 ^= B0 ^ B2;
50 B2 = rotr<3>(B2);
51 B0 = rotr<13>(B0);
52}

References Botan::rotr(), and shl().

◆ SBoxD0()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxD0 ( T & a,
T & b,
T & c,
T & d )

Definition at line 224 of file serpent_sbox.h.

224 {
225 c = ~c;
226 T t0 = b;
227 b |= a;
228 t0 = ~t0;
229 b ^= c;
230 c |= t0;
231 b ^= d;
232 a ^= t0;
233 c ^= a;
234 a &= d;
235 t0 ^= a;
236 a |= b;
237 a ^= c;
238 d ^= t0;
239 c ^= b;
240 d ^= a;
241 d ^= b;
242 c &= d;
243 t0 ^= c;
244 c = b;
245 b = t0;
246}
FE_25519 T
Definition ge.cpp:34
const SIMD_8x32 & b

References Botan::b, and T.

◆ SBoxD1()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxD1 ( T & a,
T & b,
T & c,
T & d )

Definition at line 249 of file serpent_sbox.h.

249 {
250 T t0 = b;
251 b ^= d;
252 d &= b;
253 t0 ^= c;
254 d ^= a;
255 a |= b;
256 c ^= d;
257 a ^= t0;
258 a |= c;
259 b ^= d;
260 a ^= b;
261 b |= d;
262 b ^= a;
263 t0 = ~t0;
264 t0 ^= b;
265 b |= a;
266 b ^= a;
267 b |= t0;
268 d ^= b;
269 b = a;
270 a = t0;
271 t0 = c;
272 c = d;
273 d = t0;
274}

References Botan::b, and T.

◆ SBoxD2()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxD2 ( T & a,
T & b,
T & c,
T & d )

Definition at line 277 of file serpent_sbox.h.

277 {
278 c ^= d;
279 d ^= a;
280 T t0 = d;
281 d &= c;
282 d ^= b;
283 b |= c;
284 b ^= t0;
285 t0 &= d;
286 c ^= d;
287 t0 &= a;
288 t0 ^= c;
289 c &= b;
290 c |= a;
291 d = ~d;
292 c ^= d;
293 a ^= d;
294 a &= b;
295 d ^= t0;
296 d ^= a;
297 a = b;
298 b = t0;
299}

References Botan::b, and T.

◆ SBoxD3()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxD3 ( T & a,
T & b,
T & c,
T & d )

Definition at line 302 of file serpent_sbox.h.

302 {
303 T t0 = c;
304 c ^= b;
305 a ^= c;
306 t0 &= c;
307 t0 ^= a;
308 a &= b;
309 b ^= d;
310 d |= t0;
311 c ^= d;
312 a ^= d;
313 b ^= t0;
314 d &= c;
315 d ^= b;
316 b ^= a;
317 b |= c;
318 a ^= d;
319 b ^= t0;
320 a ^= b;
321 t0 = a;
322 a = c;
323 c = d;
324 d = t0;
325}

References Botan::b, and T.

◆ SBoxD4()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxD4 ( T & a,
T & b,
T & c,
T & d )

Definition at line 328 of file serpent_sbox.h.

328 {
329 T t0 = c;
330 c &= d;
331 c ^= b;
332 b |= d;
333 b &= a;
334 t0 ^= c;
335 t0 ^= b;
336 b &= c;
337 a = ~a;
338 d ^= t0;
339 b ^= d;
340 d &= a;
341 d ^= c;
342 a ^= b;
343 c &= a;
344 d ^= a;
345 c ^= t0;
346 c |= d;
347 d ^= a;
348 c ^= b;
349 b = d;
350 d = t0;
351}

References Botan::b, and T.

◆ SBoxD5()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxD5 ( T & a,
T & b,
T & c,
T & d )

Definition at line 354 of file serpent_sbox.h.

354 {
355 b = ~b;
356 T t0 = d;
357 c ^= b;
358 d |= a;
359 d ^= c;
360 c |= b;
361 c &= a;
362 t0 ^= d;
363 c ^= t0;
364 t0 |= a;
365 t0 ^= b;
366 b &= c;
367 b ^= d;
368 t0 ^= c;
369 d &= t0;
370 t0 ^= b;
371 d ^= t0;
372 t0 = ~t0;
373 d ^= a;
374 a = b;
375 b = t0;
376 t0 = d;
377 d = c;
378 c = t0;
379}

References Botan::b, and T.

◆ SBoxD6()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxD6 ( T & a,
T & b,
T & c,
T & d )

Definition at line 382 of file serpent_sbox.h.

382 {
383 a ^= c;
384 T t0 = c;
385 c &= a;
386 t0 ^= d;
387 c = ~c;
388 d ^= b;
389 c ^= d;
390 t0 |= a;
391 a ^= c;
392 d ^= t0;
393 t0 ^= b;
394 b &= d;
395 b ^= a;
396 a ^= d;
397 a |= c;
398 d ^= b;
399 t0 ^= a;
400 a = b;
401 b = c;
402 c = t0;
403}

References Botan::b, and T.

◆ SBoxD7()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxD7 ( T & a,
T & b,
T & c,
T & d )

Definition at line 406 of file serpent_sbox.h.

406 {
407 T t0 = c;
408 c ^= a;
409 a &= d;
410 t0 |= d;
411 c = ~c;
412 d ^= b;
413 b |= a;
414 a ^= c;
415 c &= t0;
416 d &= t0;
417 b ^= c;
418 c ^= a;
419 a |= c;
420 t0 ^= b;
421 a ^= d;
422 d ^= t0;
423 t0 |= a;
424 d ^= c;
425 t0 ^= c;
426 c = b;
427 b = a;
428 a = d;
429 d = t0;
430}

References Botan::b, and T.

◆ SBoxE0()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxE0 ( T & a,
T & b,
T & c,
T & d )

Definition at line 19 of file serpent_sbox.h.

19 {
20 d ^= a;
21 T t0 = b;
22 b &= d;
23 t0 ^= c;
24 b ^= a;
25 a |= d;
26 a ^= t0;
27 t0 ^= d;
28 d ^= c;
29 c |= b;
30 c ^= t0;
31 t0 = ~t0;
32 t0 |= b;
33 b ^= d;
34 b ^= t0;
35 d |= a;
36 b ^= d;
37 t0 ^= d;
38 d = a;
39 a = b;
40 b = t0;
41}

References Botan::b, and T.

◆ SBoxE1()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxE1 ( T & a,
T & b,
T & c,
T & d )

Definition at line 44 of file serpent_sbox.h.

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}

References Botan::b, and T.

◆ SBoxE2()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxE2 ( T & a,
T & b,
T & c,
T & d )

Definition at line 70 of file serpent_sbox.h.

70 {
71 T t0 = a;
72 a &= c;
73 a ^= d;
74 c ^= b;
75 c ^= a;
76 d |= t0;
77 d ^= b;
78 t0 ^= c;
79 b = d;
80 d |= t0;
81 d ^= a;
82 a &= b;
83 t0 ^= a;
84 b ^= d;
85 b ^= t0;
86 a = c;
87 c = b;
88 b = d;
89 d = ~t0;
90}

References Botan::b, and T.

◆ SBoxE3()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxE3 ( T & a,
T & b,
T & c,
T & d )

Definition at line 93 of file serpent_sbox.h.

93 {
94 T t0 = a;
95 a |= d;
96 d ^= b;
97 b &= t0;
98 t0 ^= c;
99 c ^= d;
100 d &= a;
101 t0 |= b;
102 d ^= t0;
103 a ^= b;
104 t0 &= a;
105 b ^= d;
106 t0 ^= c;
107 b |= a;
108 b ^= c;
109 a ^= d;
110 c = b;
111 b |= d;
112 a ^= b;
113 b = c;
114 c = d;
115 d = t0;
116}

References Botan::b, and T.

◆ SBoxE4()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxE4 ( T & a,
T & b,
T & c,
T & d )

Definition at line 119 of file serpent_sbox.h.

119 {
120 b ^= d;
121 d = ~d;
122 c ^= d;
123 d ^= a;
124 T t0 = b;
125 b &= d;
126 b ^= c;
127 t0 ^= d;
128 a ^= t0;
129 c &= t0;
130 c ^= a;
131 a &= b;
132 d ^= a;
133 t0 |= b;
134 t0 ^= a;
135 a |= d;
136 a ^= c;
137 c &= d;
138 a = ~a;
139 t0 ^= c;
140 c = a;
141 a = b;
142 b = t0;
143}

References Botan::b, and T.

◆ SBoxE5()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxE5 ( T & a,
T & b,
T & c,
T & d )

Definition at line 146 of file serpent_sbox.h.

146 {
147 a ^= b;
148 b ^= d;
149 d = ~d;
150 T t0 = b;
151 b &= a;
152 c ^= d;
153 b ^= c;
154 c |= t0;
155 t0 ^= d;
156 d &= b;
157 d ^= a;
158 t0 ^= b;
159 t0 ^= c;
160 c ^= a;
161 a &= d;
162 c = ~c;
163 a ^= t0;
164 t0 |= d;
165 t0 ^= c;
166 c = a;
167 a = b;
168 b = d;
169 d = t0;
170}

References Botan::b, and T.

◆ SBoxE6()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxE6 ( T & a,
T & b,
T & c,
T & d )

Definition at line 173 of file serpent_sbox.h.

173 {
174 c = ~c;
175 T t0 = d;
176 d &= a;
177 a ^= t0;
178 d ^= c;
179 c |= t0;
180 b ^= d;
181 c ^= a;
182 a |= b;
183 c ^= b;
184 t0 ^= a;
185 a |= d;
186 a ^= c;
187 t0 ^= d;
188 t0 ^= a;
189 d = ~d;
190 c &= t0;
191 d ^= c;
192 c = t0;
193}

References Botan::b, and T.

◆ SBoxE7()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::SBoxE7 ( T & a,
T & b,
T & c,
T & d )

Definition at line 196 of file serpent_sbox.h.

196 {
197 T t0 = b;
198 b |= c;
199 b ^= d;
200 t0 ^= c;
201 c ^= b;
202 d |= t0;
203 d &= a;
204 t0 ^= c;
205 d ^= b;
206 b |= t0;
207 b ^= a;
208 a |= t0;
209 a ^= c;
210 b ^= t0;
211 c ^= b;
212 b &= a;
213 b ^= t0;
214 c = ~c;
215 c |= a;
216 t0 ^= c;
217 c = b;
218 b = d;
219 d = a;
220 a = t0;
221}

References Botan::b, and T.

◆ shl()

template<size_t S>
BOTAN_FORCE_INLINE uint32_t Botan::Serpent_F::shl ( uint32_t v)

Definition at line 16 of file serpent_fn.h.

16 {
17 return v << S;
18}

Referenced by i_transform(), and transform().

◆ transform()

template<typename T >
BOTAN_FORCE_INLINE void Botan::Serpent_F::transform ( T & B0,
T & B1,
T & B2,
T & B3 )

Definition at line 24 of file serpent_fn.h.

24 {
25 B0 = rotl<13>(B0);
26 B2 = rotl<3>(B2);
27 B1 ^= B0 ^ B2;
28 B3 ^= B2 ^ shl<3>(B0);
29 B1 = rotl<1>(B1);
30 B3 = rotl<7>(B3);
31 B0 ^= B1 ^ B3;
32 B2 ^= B3 ^ shl<7>(B1);
33 B0 = rotl<5>(B0);
34 B2 = rotl<22>(B2);
35}

References Botan::rotl(), and shl().