[Title] Add packaging/nettle.spec to build nettle on OBS system
[external/nettle.git] / serpent_sboxes.h
1 /* serpentsboxes.h
2  *
3  * $Id: serpent_sboxes.h,v 1.1 2007/04/05 14:20:35 nisse Exp $
4  *
5  * For more details on this algorithm, see the Serpent website at
6  * http://www.cl.cam.ac.uk/~rja14/serpent.html
7  */
8
9 /* Copyright (C) 1998 Ross Anderson, Eli Biham, Lars Knudsen
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License as
13  * published by the Free Software Foundation; either version 2 of the
14  * License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25
26 /* I've modified this code a bit so that it interoperates with lsh
27  * properly. 2000-9-5, Rafael R. Sevilla <dido@pacific.net.ph>
28  */
29
30 /* NOTE: The copyright notice for the original version of this code
31  * said "All rights reserved. This code is freely distributed for AES
32  * selection process. No other use is allowed." However, the authors
33  * later decided to GPL the code. /nisse */
34  
35 #ifndef SERPENT_SBOXES_H_INCLUDED
36 #define SERPENT_SBOXES_H_INCLUDED
37
38 #include "serpent.h"
39
40 /* S0:   3  8 15  1 10  6  5 11 14 13  4  2  7  0  9 12 */
41
42 /* depth = 5,7,4,2, Total gates=18 */
43 #define RND00(a,b,c,d,w,x,y,z) \
44         { register uint32_t t02, t03, t05, t06, t07, t08, t09, t11, t12, t13, t14, t15, t17, t01;\
45         t01 = b   ^ c  ; \
46         t02 = a   | d  ; \
47         t03 = a   ^ b  ; \
48         z   = t02 ^ t01; \
49         t05 = c   | z  ; \
50         t06 = a   ^ d  ; \
51         t07 = b   | c  ; \
52         t08 = d   & t05; \
53         t09 = t03 & t07; \
54         y   = t09 ^ t08; \
55         t11 = t09 & y  ; \
56         t12 = c   ^ d  ; \
57         t13 = t07 ^ t11; \
58         t14 = b   & t06; \
59         t15 = t06 ^ t13; \
60         w   =     ~ t15; \
61         t17 = w   ^ t14; \
62         x   = t12 ^ t17; }
63
64 /* InvS0:  13  3 11  0 10  6  5 12  1 14  4  7 15  9  8  2 */
65
66 /* depth = 8,4,3,6, Total gates=19 */
67 #define InvRND00(a,b,c,d,w,x,y,z) \
68         { register uint32_t t02, t03, t04, t05, t06, t08, t09, t10, t12, t13, t14, t15, t17, t18, t01;\
69         t01 = c   ^ d  ; \
70         t02 = a   | b  ; \
71         t03 = b   | c  ; \
72         t04 = c   & t01; \
73         t05 = t02 ^ t01; \
74         t06 = a   | t04; \
75         y   =     ~ t05; \
76         t08 = b   ^ d  ; \
77         t09 = t03 & t08; \
78         t10 = d   | y  ; \
79         x   = t09 ^ t06; \
80         t12 = a   | t05; \
81         t13 = x   ^ t12; \
82         t14 = t03 ^ t10; \
83         t15 = a   ^ c  ; \
84         z   = t14 ^ t13; \
85         t17 = t05 & t13; \
86         t18 = t14 | t17; \
87         w   = t15 ^ t18; }
88
89 /* S1:  15 12  2  7  9  0  5 10  1 11 14  8  6 13  3  4 */
90
91 /* depth = 10,7,3,5, Total gates=18 */
92 #define RND01(a,b,c,d,w,x,y,z) \
93         { register uint32_t t02, t03, t04, t05, t06, t07, t08, t10, t11, t12, t13, t16, t17, t01;\
94         t01 = a   | d  ; \
95         t02 = c   ^ d  ; \
96         t03 =     ~ b  ; \
97         t04 = a   ^ c  ; \
98         t05 = a   | t03; \
99         t06 = d   & t04; \
100         t07 = t01 & t02; \
101         t08 = b   | t06; \
102         y   = t02 ^ t05; \
103         t10 = t07 ^ t08; \
104         t11 = t01 ^ t10; \
105         t12 = y   ^ t11; \
106         t13 = b   & d  ; \
107         z   =     ~ t10; \
108         x   = t13 ^ t12; \
109         t16 = t10 | x  ; \
110         t17 = t05 & t16; \
111         w   = c   ^ t17; }
112
113 /* InvS1:   5  8  2 14 15  6 12  3 11  4  7  9  1 13 10  0 */
114
115 /* depth = 7,4,5,3, Total gates=18 */
116 #define InvRND01(a,b,c,d,w,x,y,z) \
117         { register uint32_t t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t14, t15, t17, t01;\
118         t01 = a   ^ b  ; \
119         t02 = b   | d  ; \
120         t03 = a   & c  ; \
121         t04 = c   ^ t02; \
122         t05 = a   | t04; \
123         t06 = t01 & t05; \
124         t07 = d   | t03; \
125         t08 = b   ^ t06; \
126         t09 = t07 ^ t06; \
127         t10 = t04 | t03; \
128         t11 = d   & t08; \
129         y   =     ~ t09; \
130         x   = t10 ^ t11; \
131         t14 = a   | y  ; \
132         t15 = t06 ^ x  ; \
133         z   = t01 ^ t04; \
134         t17 = c   ^ t15; \
135         w   = t14 ^ t17; }
136
137 /* S2:   8  6  7  9  3 12 10 15 13  1 14  4  0 11  5  2 */
138
139 /* depth = 3,8,11,7, Total gates=16 */
140 #define RND02(a,b,c,d,w,x,y,z) \
141         { register uint32_t t02, t03, t05, t06, t07, t08, t09, t10, t12, t13, t14, t01;\
142         t01 = a   | c  ; \
143         t02 = a   ^ b  ; \
144         t03 = d   ^ t01; \
145         w   = t02 ^ t03; \
146         t05 = c   ^ w  ; \
147         t06 = b   ^ t05; \
148         t07 = b   | t05; \
149         t08 = t01 & t06; \
150         t09 = t03 ^ t07; \
151         t10 = t02 | t09; \
152         x   = t10 ^ t08; \
153         t12 = a   | d  ; \
154         t13 = t09 ^ x  ; \
155         t14 = b   ^ t13; \
156         z   =     ~ t09; \
157         y   = t12 ^ t14; }
158
159 /* InvS2:  12  9 15  4 11 14  1  2  0  3  6 13  5  8 10  7 */
160
161 /* depth = 3,6,8,3, Total gates=18 */
162 #define InvRND02(a,b,c,d,w,x,y,z) \
163         { register uint32_t t02, t03, t04, t06, t07, t08, t09, t10, t11, t12, t15, t16, t17, t01;\
164         t01 = a   ^ d  ; \
165         t02 = c   ^ d  ; \
166         t03 = a   & c  ; \
167         t04 = b   | t02; \
168         w   = t01 ^ t04; \
169         t06 = a   | c  ; \
170         t07 = d   | w  ; \
171         t08 =     ~ d  ; \
172         t09 = b   & t06; \
173         t10 = t08 | t03; \
174         t11 = b   & t07; \
175         t12 = t06 & t02; \
176         z   = t09 ^ t10; \
177         x   = t12 ^ t11; \
178         t15 = c   & z  ; \
179         t16 = w   ^ x  ; \
180         t17 = t10 ^ t15; \
181         y   = t16 ^ t17; }
182
183 /* S3:   0 15 11  8 12  9  6  3 13  1  2  4 10  7  5 14 */
184
185 /* depth = 8,3,5,5, Total gates=18 */
186 #define RND03(a,b,c,d,w,x,y,z) \
187         { register uint32_t t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t13, t14, t15, t01;\
188         t01 = a   ^ c  ; \
189         t02 = a   | d  ; \
190         t03 = a   & d  ; \
191         t04 = t01 & t02; \
192         t05 = b   | t03; \
193         t06 = a   & b  ; \
194         t07 = d   ^ t04; \
195         t08 = c   | t06; \
196         t09 = b   ^ t07; \
197         t10 = d   & t05; \
198         t11 = t02 ^ t10; \
199         z   = t08 ^ t09; \
200         t13 = d   | z  ; \
201         t14 = a   | t07; \
202         t15 = b   & t13; \
203         y   = t08 ^ t11; \
204         w   = t14 ^ t15; \
205         x   = t05 ^ t04; }
206
207 /* InvS3:   0  9 10  7 11 14  6 13  3  5 12  2  4  8 15  1 */
208
209 /* depth = 3,6,4,4, Total gates=17 */
210 #define InvRND03(a,b,c,d,w,x,y,z) \
211         { register uint32_t t02, t03, t04, t05, t06, t07, t09, t11, t12, t13, t14, t16, t01;\
212         t01 = c   | d  ; \
213         t02 = a   | d  ; \
214         t03 = c   ^ t02; \
215         t04 = b   ^ t02; \
216         t05 = a   ^ d  ; \
217         t06 = t04 & t03; \
218         t07 = b   & t01; \
219         y   = t05 ^ t06; \
220         t09 = a   ^ t03; \
221         w   = t07 ^ t03; \
222         t11 = w   | t05; \
223         t12 = t09 & t11; \
224         t13 = a   & y  ; \
225         t14 = t01 ^ t05; \
226         x   = b   ^ t12; \
227         t16 = b   | t13; \
228         z   = t14 ^ t16; }
229
230 /* S4:   1 15  8  3 12  0 11  6  2  5  4 10  9 14  7 13 */
231
232 /* depth = 6,7,5,3, Total gates=19 */
233 #define RND04(a,b,c,d,w,x,y,z) \
234         { register uint32_t t02, t03, t04, t05, t06, t08, t09, t10, t11, t12, t13, t14, t15, t16, t01;\
235         t01 = a   | b  ; \
236         t02 = b   | c  ; \
237         t03 = a   ^ t02; \
238         t04 = b   ^ d  ; \
239         t05 = d   | t03; \
240         t06 = d   & t01; \
241         z   = t03 ^ t06; \
242         t08 = z   & t04; \
243         t09 = t04 & t05; \
244         t10 = c   ^ t06; \
245         t11 = b   & c  ; \
246         t12 = t04 ^ t08; \
247         t13 = t11 | t03; \
248         t14 = t10 ^ t09; \
249         t15 = a   & t05; \
250         t16 = t11 | t12; \
251         y   = t13 ^ t08; \
252         x   = t15 ^ t16; \
253         w   =     ~ t14; }
254
255 /* InvS4:   5  0  8  3 10  9  7 14  2 12 11  6  4 15 13  1 */
256
257 /* depth = 6,4,7,3, Total gates=17 */
258 #define InvRND04(a,b,c,d,w,x,y,z) \
259         { register uint32_t t02, t03, t04, t05, t06, t07, t09, t10, t11, t12, t13, t15, t01;\
260         t01 = b   | d  ; \
261         t02 = c   | d  ; \
262         t03 = a   & t01; \
263         t04 = b   ^ t02; \
264         t05 = c   ^ d  ; \
265         t06 =     ~ t03; \
266         t07 = a   & t04; \
267         x   = t05 ^ t07; \
268         t09 = x   | t06; \
269         t10 = a   ^ t07; \
270         t11 = t01 ^ t09; \
271         t12 = d   ^ t04; \
272         t13 = c   | t10; \
273         z   = t03 ^ t12; \
274         t15 = a   ^ t04; \
275         y   = t11 ^ t13; \
276         w   = t15 ^ t09; }
277
278 /* S5:  15  5  2 11  4 10  9 12  0  3 14  8 13  6  7  1 */
279
280 /* depth = 4,6,8,6, Total gates=17 */
281 #define RND05(a,b,c,d,w,x,y,z) \
282         { register uint32_t t02, t03, t04, t05, t07, t08, t09, t10, t11, t12, t13, t14, t01;\
283         t01 = b   ^ d  ; \
284         t02 = b   | d  ; \
285         t03 = a   & t01; \
286         t04 = c   ^ t02; \
287         t05 = t03 ^ t04; \
288         w   =     ~ t05; \
289         t07 = a   ^ t01; \
290         t08 = d   | w  ; \
291         t09 = b   | t05; \
292         t10 = d   ^ t08; \
293         t11 = b   | t07; \
294         t12 = t03 | w  ; \
295         t13 = t07 | t10; \
296         t14 = t01 ^ t11; \
297         y   = t09 ^ t13; \
298         x   = t07 ^ t08; \
299         z   = t12 ^ t14; }
300
301 /* InvS5:   8 15  2  9  4  1 13 14 11  6  5  3  7 12 10  0 */
302
303 /* depth = 4,6,9,7, Total gates=17 */
304 #define InvRND05(a,b,c,d,w,x,y,z) \
305         { register uint32_t t02, t03, t04, t05, t07, t08, t09, t10, t12, t13, t15, t16, t01;\
306         t01 = a   & d  ; \
307         t02 = c   ^ t01; \
308         t03 = a   ^ d  ; \
309         t04 = b   & t02; \
310         t05 = a   & c  ; \
311         w   = t03 ^ t04; \
312         t07 = a   & w  ; \
313         t08 = t01 ^ w  ; \
314         t09 = b   | t05; \
315         t10 =     ~ b  ; \
316         x   = t08 ^ t09; \
317         t12 = t10 | t07; \
318         t13 = w   | x  ; \
319         z   = t02 ^ t12; \
320         t15 = t02 ^ t13; \
321         t16 = b   ^ d  ; \
322         y   = t16 ^ t15; }
323
324 /* S6:   7  2 12  5  8  4  6 11 14  9  1 15 13  3 10  0 */
325
326 /* depth = 8,3,6,3, Total gates=19 */
327 #define RND06(a,b,c,d,w,x,y,z) \
328         { register uint32_t t02, t03, t04, t05, t07, t08, t09, t10, t11, t12, t13, t15, t17, t18, t01;\
329         t01 = a   & d  ; \
330         t02 = b   ^ c  ; \
331         t03 = a   ^ d  ; \
332         t04 = t01 ^ t02; \
333         t05 = b   | c  ; \
334         x   =     ~ t04; \
335         t07 = t03 & t05; \
336         t08 = b   & x  ; \
337         t09 = a   | c  ; \
338         t10 = t07 ^ t08; \
339         t11 = b   | d  ; \
340         t12 = c   ^ t11; \
341         t13 = t09 ^ t10; \
342         y   =     ~ t13; \
343         t15 = x   & t03; \
344         z   = t12 ^ t07; \
345         t17 = a   ^ b  ; \
346         t18 = y   ^ t15; \
347         w   = t17 ^ t18; }
348
349 /* InvS6:  15 10  1 13  5  3  6  0  4  9 14  7  2 12  8 11 */
350
351 /* depth = 5,3,8,6, Total gates=19 */
352 #define InvRND06(a,b,c,d,w,x,y,z) \
353         { register uint32_t t02, t03, t04, t05, t06, t07, t08, t09, t12, t13, t14, t15, t16, t17, t01;\
354         t01 = a   ^ c  ; \
355         t02 =     ~ c  ; \
356         t03 = b   & t01; \
357         t04 = b   | t02; \
358         t05 = d   | t03; \
359         t06 = b   ^ d  ; \
360         t07 = a   & t04; \
361         t08 = a   | t02; \
362         t09 = t07 ^ t05; \
363         x   = t06 ^ t08; \
364         w   =     ~ t09; \
365         t12 = b   & w  ; \
366         t13 = t01 & t05; \
367         t14 = t01 ^ t12; \
368         t15 = t07 ^ t13; \
369         t16 = d   | t02; \
370         t17 = a   ^ x  ; \
371         z   = t17 ^ t15; \
372         y   = t16 ^ t14; }
373
374 /* S7:   1 13 15  0 14  8  2 11  7  4 12 10  9  3  5  6 */
375
376 /* depth = 10,7,10,4, Total gates=19 */
377 #define RND07(a,b,c,d,w,x,y,z) \
378         { register uint32_t t02, t03, t04, t05, t06, t08, t09, t10, t11, t13, t14, t15, t16, t17, t01;\
379         t01 = a   & c  ; \
380         t02 =     ~ d  ; \
381         t03 = a   & t02; \
382         t04 = b   | t01; \
383         t05 = a   & b  ; \
384         t06 = c   ^ t04; \
385         z   = t03 ^ t06; \
386         t08 = c   | z  ; \
387         t09 = d   | t05; \
388         t10 = a   ^ t08; \
389         t11 = t04 & z  ; \
390         x   = t09 ^ t10; \
391         t13 = b   ^ x  ; \
392         t14 = t01 ^ x  ; \
393         t15 = c   ^ t05; \
394         t16 = t11 | t13; \
395         t17 = t02 | t14; \
396         w   = t15 ^ t17; \
397         y   = a   ^ t16; }
398
399 /* InvS7:   3  0  6 13  9 14 15  8  5 12 11  7 10  1  4  2 */
400
401 /* depth = 9,7,3,3, Total gates=18 */
402 #define InvRND07(a,b,c,d,w,x,y,z) \
403         { register uint32_t t02, t03, t04, t06, t07, t08, t09, t10, t11, t13, t14, t15, t16, t01;\
404         t01 = a   & b  ; \
405         t02 = a   | b  ; \
406         t03 = c   | t01; \
407         t04 = d   & t02; \
408         z   = t03 ^ t04; \
409         t06 = b   ^ t04; \
410         t07 = d   ^ z  ; \
411         t08 =     ~ t07; \
412         t09 = t06 | t08; \
413         t10 = b   ^ d  ; \
414         t11 = a   | d  ; \
415         x   = a   ^ t09; \
416         t13 = c   ^ t06; \
417         t14 = c   & t11; \
418         t15 = d   | x  ; \
419         t16 = t01 | t10; \
420         w   = t13 ^ t15; \
421         y   = t14 ^ t16; }
422
423 #define RND08(a,b,c,d,e,f,g,h) RND00(a,b,c,d,e,f,g,h)
424 #define RND09(a,b,c,d,e,f,g,h) RND01(a,b,c,d,e,f,g,h)
425 #define RND10(a,b,c,d,e,f,g,h) RND02(a,b,c,d,e,f,g,h)
426 #define RND11(a,b,c,d,e,f,g,h) RND03(a,b,c,d,e,f,g,h)
427 #define RND12(a,b,c,d,e,f,g,h) RND04(a,b,c,d,e,f,g,h)
428 #define RND13(a,b,c,d,e,f,g,h) RND05(a,b,c,d,e,f,g,h)
429 #define RND14(a,b,c,d,e,f,g,h) RND06(a,b,c,d,e,f,g,h)
430 #define RND15(a,b,c,d,e,f,g,h) RND07(a,b,c,d,e,f,g,h)
431 #define RND16(a,b,c,d,e,f,g,h) RND00(a,b,c,d,e,f,g,h)
432 #define RND17(a,b,c,d,e,f,g,h) RND01(a,b,c,d,e,f,g,h)
433 #define RND18(a,b,c,d,e,f,g,h) RND02(a,b,c,d,e,f,g,h)
434 #define RND19(a,b,c,d,e,f,g,h) RND03(a,b,c,d,e,f,g,h)
435 #define RND20(a,b,c,d,e,f,g,h) RND04(a,b,c,d,e,f,g,h)
436 #define RND21(a,b,c,d,e,f,g,h) RND05(a,b,c,d,e,f,g,h)
437 #define RND22(a,b,c,d,e,f,g,h) RND06(a,b,c,d,e,f,g,h)
438 #define RND23(a,b,c,d,e,f,g,h) RND07(a,b,c,d,e,f,g,h)
439 #define RND24(a,b,c,d,e,f,g,h) RND00(a,b,c,d,e,f,g,h)
440 #define RND25(a,b,c,d,e,f,g,h) RND01(a,b,c,d,e,f,g,h)
441 #define RND26(a,b,c,d,e,f,g,h) RND02(a,b,c,d,e,f,g,h)
442 #define RND27(a,b,c,d,e,f,g,h) RND03(a,b,c,d,e,f,g,h)
443 #define RND28(a,b,c,d,e,f,g,h) RND04(a,b,c,d,e,f,g,h)
444 #define RND29(a,b,c,d,e,f,g,h) RND05(a,b,c,d,e,f,g,h)
445 #define RND30(a,b,c,d,e,f,g,h) RND06(a,b,c,d,e,f,g,h)
446 #define RND31(a,b,c,d,e,f,g,h) RND07(a,b,c,d,e,f,g,h)
447
448 #define InvRND08(a,b,c,d,e,f,g,h) InvRND00(a,b,c,d,e,f,g,h)
449 #define InvRND09(a,b,c,d,e,f,g,h) InvRND01(a,b,c,d,e,f,g,h)
450 #define InvRND10(a,b,c,d,e,f,g,h) InvRND02(a,b,c,d,e,f,g,h)
451 #define InvRND11(a,b,c,d,e,f,g,h) InvRND03(a,b,c,d,e,f,g,h)
452 #define InvRND12(a,b,c,d,e,f,g,h) InvRND04(a,b,c,d,e,f,g,h)
453 #define InvRND13(a,b,c,d,e,f,g,h) InvRND05(a,b,c,d,e,f,g,h)
454 #define InvRND14(a,b,c,d,e,f,g,h) InvRND06(a,b,c,d,e,f,g,h)
455 #define InvRND15(a,b,c,d,e,f,g,h) InvRND07(a,b,c,d,e,f,g,h)
456 #define InvRND16(a,b,c,d,e,f,g,h) InvRND00(a,b,c,d,e,f,g,h)
457 #define InvRND17(a,b,c,d,e,f,g,h) InvRND01(a,b,c,d,e,f,g,h)
458 #define InvRND18(a,b,c,d,e,f,g,h) InvRND02(a,b,c,d,e,f,g,h)
459 #define InvRND19(a,b,c,d,e,f,g,h) InvRND03(a,b,c,d,e,f,g,h)
460 #define InvRND20(a,b,c,d,e,f,g,h) InvRND04(a,b,c,d,e,f,g,h)
461 #define InvRND21(a,b,c,d,e,f,g,h) InvRND05(a,b,c,d,e,f,g,h)
462 #define InvRND22(a,b,c,d,e,f,g,h) InvRND06(a,b,c,d,e,f,g,h)
463 #define InvRND23(a,b,c,d,e,f,g,h) InvRND07(a,b,c,d,e,f,g,h)
464 #define InvRND24(a,b,c,d,e,f,g,h) InvRND00(a,b,c,d,e,f,g,h)
465 #define InvRND25(a,b,c,d,e,f,g,h) InvRND01(a,b,c,d,e,f,g,h)
466 #define InvRND26(a,b,c,d,e,f,g,h) InvRND02(a,b,c,d,e,f,g,h)
467 #define InvRND27(a,b,c,d,e,f,g,h) InvRND03(a,b,c,d,e,f,g,h)
468 #define InvRND28(a,b,c,d,e,f,g,h) InvRND04(a,b,c,d,e,f,g,h)
469 #define InvRND29(a,b,c,d,e,f,g,h) InvRND05(a,b,c,d,e,f,g,h)
470 #define InvRND30(a,b,c,d,e,f,g,h) InvRND06(a,b,c,d,e,f,g,h)
471 #define InvRND31(a,b,c,d,e,f,g,h) InvRND07(a,b,c,d,e,f,g,h)
472
473 /* Linear transformations and key mixing: */
474
475 #define ROL(x,n) ((((uint32_t)(x))<<(n))| \
476                   (((uint32_t)(x))>>(32-(n))))
477 #define ROR(x,n) ((((uint32_t)(x))<<(32-(n)))| \
478                   (((uint32_t)(x))>>(n)))
479
480 #define transform(x0, x1, x2, x3, y0, y1, y2, y3) \
481       y0 = ROL(x0, 13); \
482       y2 = ROL(x2, 3); \
483       y1 = x1 ^ y0 ^ y2; \
484       y3 = x3 ^ y2 ^ ((uint32_t)y0)<<3; \
485       y1 = ROL(y1, 1); \
486       y3 = ROL(y3, 7); \
487       y0 = y0 ^ y1 ^ y3; \
488       y2 = y2 ^ y3 ^ ((uint32_t)y1<<7); \
489       y0 = ROL(y0, 5); \
490       y2 = ROL(y2, 22)
491
492 #define inv_transform(x0, x1, x2, x3, y0, y1, y2, y3) \
493       y2 = ROR(x2, 22);\
494       y0 = ROR(x0, 5); \
495       y2 = y2 ^ x3 ^ ((uint32_t)x1<<7); \
496       y0 = y0 ^ x1 ^ x3; \
497       y3 = ROR(x3, 7); \
498       y1 = ROR(x1, 1); \
499       y3 = y3 ^ y2 ^ ((uint32_t)y0)<<3; \
500       y1 = y1 ^ y0 ^ y2; \
501       y2 = ROR(y2, 3); \
502       y0 = ROR(y0, 13)
503
504 #define keying(x0, x1, x2, x3, subkey) \
505                          x0^=subkey[0];x1^=subkey[1]; \
506                          x2^=subkey[2];x3^=subkey[3]
507
508 /* PHI: Constant used in the key schedule */
509 #define PHI 0x9e3779b9L
510
511 #endif /* SERPENT_SBOXES_H_INCLUDED */