20 #include <linux/module.h>
21 #include <linux/errno.h>
22 #include <asm/byteorder.h>
24 #include <linux/types.h>
31 #define PHI 0x9e3779b9UL
33 #define keyiter(a, b, c, d, i, j) \
34 ({ b ^= d; b ^= c; b ^= a; b ^= PHI ^ i; b = rol32(b, 11); k[j] = b; })
36 #define loadkeys(x0, x1, x2, x3, i) \
37 ({ x0 = k[i]; x1 = k[i+1]; x2 = k[i+2]; x3 = k[i+3]; })
39 #define storekeys(x0, x1, x2, x3, i) \
40 ({ k[i] = x0; k[i+1] = x1; k[i+2] = x2; k[i+3] = x3; })
42 #define store_and_load_keys(x0, x1, x2, x3, s, l) \
43 ({ storekeys(x0, x1, x2, x3, s); loadkeys(x0, x1, x2, x3, l); })
45 #define K(x0, x1, x2, x3, i) ({ \
46 x3 ^= k[4*(i)+3]; x2 ^= k[4*(i)+2]; \
47 x1 ^= k[4*(i)+1]; x0 ^= k[4*(i)+0]; \
50 #define LK(x0, x1, x2, x3, x4, i) ({ \
52 x2 = rol32(x2, 3); x1 ^= x0; x4 = x0 << 3; \
54 x1 = rol32(x1, 1); x3 ^= x4; \
55 x3 = rol32(x3, 7); x4 = x1; \
56 x0 ^= x1; x4 <<= 7; x2 ^= x3; \
57 x0 ^= x3; x2 ^= x4; x3 ^= k[4*i+3]; \
58 x1 ^= k[4*i+1]; x0 = rol32(x0, 5); x2 = rol32(x2, 22);\
59 x0 ^= k[4*i+0]; x2 ^= k[4*i+2]; \
62 #define KL(x0, x1, x2, x3, x4, i) ({ \
63 x0 ^= k[4*i+0]; x1 ^= k[4*i+1]; x2 ^= k[4*i+2]; \
64 x3 ^= k[4*i+3]; x0 = ror32(x0, 5); x2 = ror32(x2, 22);\
65 x4 = x1; x2 ^= x3; x0 ^= x3; \
66 x4 <<= 7; x0 ^= x1; x1 = ror32(x1, 1); \
67 x2 ^= x4; x3 = ror32(x3, 7); x4 = x0 << 3; \
68 x1 ^= x0; x3 ^= x4; x0 = ror32(x0, 13);\
69 x1 ^= x2; x3 ^= x2; x2 = ror32(x2, 3); \
72 #define S0(x0, x1, x2, x3, x4) ({ \
74 x3 |= x0; x0 ^= x4; x4 ^= x2; \
75 x4 = ~x4; x3 ^= x1; x1 &= x0; \
76 x1 ^= x4; x2 ^= x0; x0 ^= x3; \
77 x4 |= x0; x0 ^= x2; x2 &= x1; \
78 x3 ^= x2; x1 = ~x1; x2 ^= x4; \
82 #define S1(x0, x1, x2, x3, x4) ({ \
84 x1 ^= x0; x0 ^= x3; x3 = ~x3; \
85 x4 &= x1; x0 |= x1; x3 ^= x2; \
86 x0 ^= x3; x1 ^= x3; x3 ^= x4; \
87 x1 |= x4; x4 ^= x2; x2 &= x0; \
88 x2 ^= x1; x1 |= x0; x0 = ~x0; \
92 #define S2(x0, x1, x2, x3, x4) ({ \
94 x1 ^= x0; x4 = x0; x0 &= x2; \
95 x0 ^= x3; x3 |= x4; x2 ^= x1; \
96 x3 ^= x1; x1 &= x0; x0 ^= x2; \
97 x2 &= x3; x3 |= x1; x0 = ~x0; \
98 x3 ^= x0; x4 ^= x0; x0 ^= x2; \
102 #define S3(x0, x1, x2, x3, x4) ({ \
104 x1 ^= x3; x3 |= x0; x4 &= x0; \
105 x0 ^= x2; x2 ^= x1; x1 &= x3; \
106 x2 ^= x3; x0 |= x4; x4 ^= x3; \
107 x1 ^= x0; x0 &= x3; x3 &= x4; \
108 x3 ^= x2; x4 |= x1; x2 &= x1; \
109 x4 ^= x3; x0 ^= x3; x3 ^= x2; \
112 #define S4(x0, x1, x2, x3, x4) ({ \
114 x3 &= x0; x0 ^= x4; \
115 x3 ^= x2; x2 |= x4; x0 ^= x1; \
116 x4 ^= x3; x2 |= x0; \
117 x2 ^= x1; x1 &= x0; \
118 x1 ^= x4; x4 &= x2; x2 ^= x3; \
119 x4 ^= x0; x3 |= x1; x1 = ~x1; \
123 #define S5(x0, x1, x2, x3, x4) ({ \
125 x2 ^= x1; x3 = ~x3; x4 ^= x0; \
126 x0 ^= x2; x1 &= x4; x4 |= x3; \
127 x4 ^= x0; x0 &= x3; x1 ^= x3; \
128 x3 ^= x2; x0 ^= x1; x2 &= x4; \
129 x1 ^= x2; x2 &= x0; \
133 #define S6(x0, x1, x2, x3, x4) ({ \
135 x3 ^= x0; x1 ^= x2; x2 ^= x0; \
136 x0 &= x3; x1 |= x3; x4 = ~x4; \
137 x0 ^= x1; x1 ^= x2; \
138 x3 ^= x4; x4 ^= x0; x2 &= x0; \
139 x4 ^= x1; x2 ^= x3; x3 &= x1; \
140 x3 ^= x0; x1 ^= x2; \
143 #define S7(x0, x1, x2, x3, x4) ({ \
145 x4 = x1; x0 = ~x0; x1 &= x2; \
146 x1 ^= x3; x3 |= x4; x4 ^= x2; \
147 x2 ^= x3; x3 ^= x0; x0 |= x1; \
148 x2 &= x0; x0 ^= x4; x4 ^= x3; \
149 x3 &= x0; x4 ^= x1; \
150 x2 ^= x4; x3 ^= x1; x4 |= x0; \
154 #define SI0(x0, x1, x2, x3, x4) ({ \
156 x3 |= x1; x4 ^= x1; x0 = ~x0; \
157 x2 ^= x3; x3 ^= x0; x0 &= x1; \
158 x0 ^= x2; x2 &= x3; x3 ^= x4; \
159 x2 ^= x3; x1 ^= x3; x3 &= x0; \
160 x1 ^= x0; x0 ^= x2; x4 ^= x3; \
163 #define SI1(x0, x1, x2, x3, x4) ({ \
165 x0 ^= x2; x2 = ~x2; x4 |= x1; \
166 x4 ^= x3; x3 &= x1; x1 ^= x2; \
167 x2 &= x4; x4 ^= x1; x1 |= x3; \
168 x3 ^= x0; x2 ^= x0; x0 |= x4; \
169 x2 ^= x4; x1 ^= x0; \
173 #define SI2(x0, x1, x2, x3, x4) ({ \
174 x2 ^= x1; x4 = x3; x3 = ~x3; \
175 x3 |= x2; x2 ^= x4; x4 ^= x0; \
176 x3 ^= x1; x1 |= x2; x2 ^= x0; \
177 x1 ^= x4; x4 |= x3; x2 ^= x3; \
178 x4 ^= x2; x2 &= x1; \
179 x2 ^= x3; x3 ^= x4; x4 ^= x0; \
182 #define SI3(x0, x1, x2, x3, x4) ({ \
185 x1 ^= x0; x0 |= x4; x4 ^= x3; \
186 x0 ^= x3; x3 |= x1; x1 ^= x2; \
187 x1 ^= x3; x0 ^= x2; x2 ^= x3; \
188 x3 &= x1; x1 ^= x0; x0 &= x2; \
189 x4 ^= x3; x3 ^= x0; x0 ^= x1; \
192 #define SI4(x0, x1, x2, x3, x4) ({ \
193 x2 ^= x3; x4 = x0; x0 &= x1; \
194 x0 ^= x2; x2 |= x3; x4 = ~x4; \
195 x1 ^= x0; x0 ^= x2; x2 &= x4; \
196 x2 ^= x0; x0 |= x4; \
197 x0 ^= x3; x3 &= x2; \
198 x4 ^= x3; x3 ^= x1; x1 &= x0; \
199 x4 ^= x1; x0 ^= x3; \
202 #define SI5(x0, x1, x2, x3, x4) ({ \
204 x2 ^= x4; x1 ^= x3; x3 &= x4; \
205 x2 ^= x3; x3 |= x0; x0 = ~x0; \
206 x3 ^= x2; x2 |= x0; x4 ^= x1; \
207 x2 ^= x4; x4 &= x0; x0 ^= x1; \
208 x1 ^= x3; x0 &= x2; x2 ^= x3; \
209 x0 ^= x2; x2 ^= x4; x4 ^= x3; \
212 #define SI6(x0, x1, x2, x3, x4) ({ \
214 x4 = x0; x0 &= x3; x2 ^= x3; \
215 x0 ^= x2; x3 ^= x1; x2 |= x4; \
216 x2 ^= x3; x3 &= x0; x0 = ~x0; \
217 x3 ^= x1; x1 &= x2; x4 ^= x0; \
218 x3 ^= x4; x4 ^= x2; x0 ^= x1; \
222 #define SI7(x0, x1, x2, x3, x4) ({ \
223 x4 = x3; x3 &= x0; x0 ^= x2; \
224 x2 |= x4; x4 ^= x1; x0 = ~x0; \
225 x1 |= x3; x4 ^= x0; x0 &= x2; \
226 x0 ^= x1; x1 &= x2; x3 ^= x2; \
227 x4 ^= x3; x2 &= x3; x3 |= x0; \
228 x1 ^= x4; x3 ^= x4; x4 &= x0; \
242 for (i = 0; i < keylen; ++
i)
266 keyiter(k[0], r3, r2, r0, 8, 8);
267 keyiter(k[1], r4, r3, r1, 9, 9);
268 keyiter(k[2], r0, r4, r2, 10, 10);
269 keyiter(k[3], r1, r0, r3, 11, 11);
270 keyiter(k[4], r2, r1, r4, 12, 12);
271 keyiter(k[5], r3, r2, r0, 13, 13);
272 keyiter(k[6], r4, r3, r1, 14, 14);
273 keyiter(k[7], r0, r4, r2, 15, 15);
274 keyiter(k[8], r1, r0, r3, 16, 16);
275 keyiter(k[9], r2, r1, r4, 17, 17);
276 keyiter(k[10], r3, r2, r0, 18, 18);
277 keyiter(k[11], r4, r3, r1, 19, 19);
278 keyiter(k[12], r0, r4, r2, 20, 20);
279 keyiter(k[13], r1, r0, r3, 21, 21);
280 keyiter(k[14], r2, r1, r4, 22, 22);
281 keyiter(k[15], r3, r2, r0, 23, 23);
282 keyiter(k[16], r4, r3, r1, 24, 24);
283 keyiter(k[17], r0, r4, r2, 25, 25);
284 keyiter(k[18], r1, r0, r3, 26, 26);
285 keyiter(k[19], r2, r1, r4, 27, 27);
286 keyiter(k[20], r3, r2, r0, 28, 28);
287 keyiter(k[21], r4, r3, r1, 29, 29);
288 keyiter(k[22], r0, r4, r2, 30, 30);
289 keyiter(k[23], r1, r0, r3, 31, 31);
293 keyiter(k[-26], r2, r1, r4, 32, -18);
294 keyiter(k[-25], r3, r2, r0, 33, -17);
295 keyiter(k[-24], r4, r3, r1, 34, -16);
296 keyiter(k[-23], r0, r4, r2, 35, -15);
297 keyiter(k[-22], r1, r0, r3, 36, -14);
298 keyiter(k[-21], r2, r1, r4, 37, -13);
299 keyiter(k[-20], r3, r2, r0, 38, -12);
300 keyiter(k[-19], r4, r3, r1, 39, -11);
301 keyiter(k[-18], r0, r4, r2, 40, -10);
302 keyiter(k[-17], r1, r0, r3, 41, -9);
303 keyiter(k[-16], r2, r1, r4, 42, -8);
304 keyiter(k[-15], r3, r2, r0, 43, -7);
305 keyiter(k[-14], r4, r3, r1, 44, -6);
306 keyiter(k[-13], r0, r4, r2, 45, -5);
307 keyiter(k[-12], r1, r0, r3, 46, -4);
308 keyiter(k[-11], r2, r1, r4, 47, -3);
309 keyiter(k[-10], r3, r2, r0, 48, -2);
310 keyiter(k[-9], r4, r3, r1, 49, -1);
311 keyiter(k[-8], r0, r4, r2, 50, 0);
312 keyiter(k[-7], r1, r0, r3, 51, 1);
313 keyiter(k[-6], r2, r1, r4, 52, 2);
314 keyiter(k[-5], r3, r2, r0, 53, 3);
315 keyiter(k[-4], r4, r3, r1, 54, 4);
316 keyiter(k[-3], r0, r4, r2, 55, 5);
317 keyiter(k[-2], r1, r0, r3, 56, 6);
318 keyiter(k[-1], r2, r1, r4, 57, 7);
319 keyiter(k[0], r3, r2, r0, 58, 8);
320 keyiter(k[1], r4, r3, r1, 59, 9);
321 keyiter(k[2], r0, r4, r2, 60, 10);
322 keyiter(k[3], r1, r0, r3, 61, 11);
323 keyiter(k[4], r2, r1, r4, 62, 12);
324 keyiter(k[5], r3, r2, r0, 63, 13);
325 keyiter(k[6], r4, r3, r1, 64, 14);
326 keyiter(k[7], r0, r4, r2, 65, 15);
327 keyiter(k[8], r1, r0, r3, 66, 16);
328 keyiter(k[9], r2, r1, r4, 67, 17);
329 keyiter(k[10], r3, r2, r0, 68, 18);
330 keyiter(k[11], r4, r3, r1, 69, 19);
331 keyiter(k[12], r0, r4, r2, 70, 20);
332 keyiter(k[13], r1, r0, r3, 71, 21);
333 keyiter(k[14], r2, r1, r4, 72, 22);
334 keyiter(k[15], r3, r2, r0, 73, 23);
335 keyiter(k[16], r4, r3, r1, 74, 24);
336 keyiter(k[17], r0, r4, r2, 75, 25);
337 keyiter(k[18], r1, r0, r3, 76, 26);
338 keyiter(k[19], r2, r1, r4, 77, 27);
339 keyiter(k[20], r3, r2, r0, 78, 28);
340 keyiter(k[21], r4, r3, r1, 79, 29);
341 keyiter(k[22], r0, r4, r2, 80, 30);
342 keyiter(k[23], r1, r0, r3, 81, 31);
346 keyiter(k[-26], r2, r1, r4, 82, -18);
347 keyiter(k[-25], r3, r2, r0, 83, -17);
348 keyiter(k[-24], r4, r3, r1, 84, -16);
349 keyiter(k[-23], r0, r4, r2, 85, -15);
350 keyiter(k[-22], r1, r0, r3, 86, -14);
351 keyiter(k[-21], r2, r1, r4, 87, -13);
352 keyiter(k[-20], r3, r2, r0, 88, -12);
353 keyiter(k[-19], r4, r3, r1, 89, -11);
354 keyiter(k[-18], r0, r4, r2, 90, -10);
355 keyiter(k[-17], r1, r0, r3, 91, -9);
356 keyiter(k[-16], r2, r1, r4, 92, -8);
357 keyiter(k[-15], r3, r2, r0, 93, -7);
358 keyiter(k[-14], r4, r3, r1, 94, -6);
359 keyiter(k[-13], r0, r4, r2, 95, -5);
360 keyiter(k[-12], r1, r0, r3, 96, -4);
361 keyiter(k[-11], r2, r1, r4, 97, -3);
362 keyiter(k[-10], r3, r2, r0, 98, -2);
363 keyiter(k[-9], r4, r3, r1, 99, -1);
364 keyiter(k[-8], r0, r4, r2, 100, 0);
365 keyiter(k[-7], r1, r0, r3, 101, 1);
366 keyiter(k[-6], r2, r1, r4, 102, 2);
367 keyiter(k[-5], r3, r2, r0, 103, 3);
368 keyiter(k[-4], r4, r3, r1, 104, 4);
369 keyiter(k[-3], r0, r4, r2, 105, 5);
370 keyiter(k[-2], r1, r0, r3, 106, 6);
371 keyiter(k[-1], r2, r1, r4, 107, 7);
372 keyiter(k[0], r3, r2, r0, 108, 8);
373 keyiter(k[1], r4, r3, r1, 109, 9);
374 keyiter(k[2], r0, r4, r2, 110, 10);
375 keyiter(k[3], r1, r0, r3, 111, 11);
376 keyiter(k[4], r2, r1, r4, 112, 12);
377 keyiter(k[5], r3, r2, r0, 113, 13);
378 keyiter(k[6], r4, r3, r1, 114, 14);
379 keyiter(k[7], r0, r4, r2, 115, 15);
380 keyiter(k[8], r1, r0, r3, 116, 16);
381 keyiter(k[9], r2, r1, r4, 117, 17);
382 keyiter(k[10], r3, r2, r0, 118, 18);
383 keyiter(k[11], r4, r3, r1, 119, 19);
384 keyiter(k[12], r0, r4, r2, 120, 20);
385 keyiter(k[13], r1, r0, r3, 121, 21);
386 keyiter(k[14], r2, r1, r4, 122, 22);
387 keyiter(k[15], r3, r2, r0, 123, 23);
388 keyiter(k[16], r4, r3, r1, 124, 24);
389 keyiter(k[17], r0, r4, r2, 125, 25);
390 keyiter(k[18], r1, r0, r3, 126, 26);
391 keyiter(k[19], r2, r1, r4, 127, 27);
392 keyiter(k[20], r3, r2, r0, 128, 28);
393 keyiter(k[21], r4, r3, r1, 129, 29);
394 keyiter(k[22], r0, r4, r2, 130, 30);
395 keyiter(k[23], r1, r0, r3, 131, 31);
433 S3(r3, r4, r0, r1, r2);
storekeys(r1, r2, r4, r3, 0);
462 K(r0, r1, r2, r3, 0);
463 S0(r0, r1, r2, r3, r4);
LK(r2, r1, r3, r0, r4, 1);
464 S1(r2, r1, r3, r0, r4);
LK(r4, r3, r0, r2, r1, 2);
465 S2(r4, r3, r0, r2, r1);
LK(r1, r3, r4, r2, r0, 3);
466 S3(r1, r3, r4, r2, r0);
LK(r2, r0, r3, r1, r4, 4);
467 S4(r2, r0, r3, r1, r4);
LK(r0, r3, r1, r4, r2, 5);
468 S5(r0, r3, r1, r4, r2);
LK(r2, r0, r3, r4, r1, 6);
469 S6(r2, r0, r3, r4, r1);
LK(r3, r1, r0, r4, r2, 7);
470 S7(r3, r1, r0, r4, r2);
LK(r2, r0, r4, r3, r1, 8);
471 S0(r2, r0, r4, r3, r1);
LK(r4, r0, r3, r2, r1, 9);
472 S1(r4, r0, r3, r2, r1);
LK(r1, r3, r2, r4, r0, 10);
473 S2(r1, r3, r2, r4, r0);
LK(r0, r3, r1, r4, r2, 11);
474 S3(r0, r3, r1, r4, r2);
LK(r4, r2, r3, r0, r1, 12);
475 S4(r4, r2, r3, r0, r1);
LK(r2, r3, r0, r1, r4, 13);
476 S5(r2, r3, r0, r1, r4);
LK(r4, r2, r3, r1, r0, 14);
477 S6(r4, r2, r3, r1, r0);
LK(r3, r0, r2, r1, r4, 15);
478 S7(r3, r0, r2, r1, r4);
LK(r4, r2, r1, r3, r0, 16);
479 S0(r4, r2, r1, r3, r0);
LK(r1, r2, r3, r4, r0, 17);
480 S1(r1, r2, r3, r4, r0);
LK(r0, r3, r4, r1, r2, 18);
481 S2(r0, r3, r4, r1, r2);
LK(r2, r3, r0, r1, r4, 19);
482 S3(r2, r3, r0, r1, r4);
LK(r1, r4, r3, r2, r0, 20);
483 S4(r1, r4, r3, r2, r0);
LK(r4, r3, r2, r0, r1, 21);
484 S5(r4, r3, r2, r0, r1);
LK(r1, r4, r3, r0, r2, 22);
485 S6(r1, r4, r3, r0, r2);
LK(r3, r2, r4, r0, r1, 23);
486 S7(r3, r2, r4, r0, r1);
LK(r1, r4, r0, r3, r2, 24);
487 S0(r1, r4, r0, r3, r2);
LK(r0, r4, r3, r1, r2, 25);
488 S1(r0, r4, r3, r1, r2);
LK(r2, r3, r1, r0, r4, 26);
489 S2(r2, r3, r1, r0, r4);
LK(r4, r3, r2, r0, r1, 27);
490 S3(r4, r3, r2, r0, r1);
LK(r0, r1, r3, r4, r2, 28);
491 S4(r0, r1, r3, r4, r2);
LK(r1, r3, r4, r2, r0, 29);
492 S5(r1, r3, r4, r2, r0);
LK(r0, r1, r3, r2, r4, 30);
493 S6(r0, r1, r3, r2, r4);
LK(r3, r4, r1, r2, r0, 31);
494 S7(r3, r4, r1, r2, r0);
K(r0, r1, r2, r3, 32);
522 K(r0, r1, r2, r3, 32);
523 SI7(r0, r1, r2, r3, r4);
KL(r1, r3, r0, r4, r2, 31);
524 SI6(r1, r3, r0, r4, r2);
KL(r0, r2, r4, r1, r3, 30);
525 SI5(r0, r2, r4, r1, r3);
KL(r2, r3, r0, r4, r1, 29);
526 SI4(r2, r3, r0, r4, r1);
KL(r2, r0, r1, r4, r3, 28);
527 SI3(r2, r0, r1, r4, r3);
KL(r1, r2, r3, r4, r0, 27);
528 SI2(r1, r2, r3, r4, r0);
KL(r2, r0, r4, r3, r1, 26);
529 SI1(r2, r0, r4, r3, r1);
KL(r1, r0, r4, r3, r2, 25);
530 SI0(r1, r0, r4, r3, r2);
KL(r4, r2, r0, r1, r3, 24);
531 SI7(r4, r2, r0, r1, r3);
KL(r2, r1, r4, r3, r0, 23);
532 SI6(r2, r1, r4, r3, r0);
KL(r4, r0, r3, r2, r1, 22);
533 SI5(r4, r0, r3, r2, r1);
KL(r0, r1, r4, r3, r2, 21);
534 SI4(r0, r1, r4, r3, r2);
KL(r0, r4, r2, r3, r1, 20);
535 SI3(r0, r4, r2, r3, r1);
KL(r2, r0, r1, r3, r4, 19);
536 SI2(r2, r0, r1, r3, r4);
KL(r0, r4, r3, r1, r2, 18);
537 SI1(r0, r4, r3, r1, r2);
KL(r2, r4, r3, r1, r0, 17);
538 SI0(r2, r4, r3, r1, r0);
KL(r3, r0, r4, r2, r1, 16);
539 SI7(r3, r0, r4, r2, r1);
KL(r0, r2, r3, r1, r4, 15);
540 SI6(r0, r2, r3, r1, r4);
KL(r3, r4, r1, r0, r2, 14);
541 SI5(r3, r4, r1, r0, r2);
KL(r4, r2, r3, r1, r0, 13);
542 SI4(r4, r2, r3, r1, r0);
KL(r4, r3, r0, r1, r2, 12);
543 SI3(r4, r3, r0, r1, r2);
KL(r0, r4, r2, r1, r3, 11);
544 SI2(r0, r4, r2, r1, r3);
KL(r4, r3, r1, r2, r0, 10);
545 SI1(r4, r3, r1, r2, r0);
KL(r0, r3, r1, r2, r4, 9);
546 SI0(r0, r3, r1, r2, r4);
KL(r1, r4, r3, r0, r2, 8);
547 SI7(r1, r4, r3, r0, r2);
KL(r4, r0, r1, r2, r3, 7);
548 SI6(r4, r0, r1, r2, r3);
KL(r1, r3, r2, r4, r0, 6);
549 SI5(r1, r3, r2, r4, r0);
KL(r3, r0, r1, r2, r4, 5);
550 SI4(r3, r0, r1, r2, r4);
KL(r3, r1, r4, r2, r0, 4);
551 SI3(r3, r1, r4, r2, r0);
KL(r4, r3, r0, r2, r1, 3);
552 SI2(r4, r3, r0, r2, r1);
KL(r3, r1, r2, r0, r4, 2);
553 SI1(r3, r1, r2, r0, r4);
KL(r4, r1, r2, r0, r3, 1);
554 SI0(r4, r1, r2, r0, r3);
K(r2, r3, r1, r4, 0);
576 for (i = 0; i < keylen; ++
i)
577 rev_key[keylen - i - 1] = key[i];
584 const u32 *
const s = (
const u32 *
const)src;
585 u32 *
const d = (
u32 *
const)dst;
594 serpent_encrypt(tfm, (
u8 *)rd, (
u8 *)rs);
602 static void tnepres_decrypt(
struct crypto_tfm *tfm,
u8 *dst,
const u8 *src)
604 const u32 *
const s = (
const u32 *
const)src;
605 u32 *
const d = (
u32 *
const)dst;
614 serpent_decrypt(tfm, (
u8 *)rd, (
u8 *)rs);
623 .cra_name =
"serpent",
624 .cra_driver_name =
"serpent-generic",
631 .cra_u = { .cipher = {
635 .cia_encrypt = serpent_encrypt,
636 .cia_decrypt = serpent_decrypt } }
638 .cra_name =
"tnepres",
644 .cra_u = { .cipher = {
647 .cia_setkey = tnepres_setkey,
648 .cia_encrypt = tnepres_encrypt,
649 .cia_decrypt = tnepres_decrypt } }
652 static int __init serpent_mod_init(
void)
657 static void __exit serpent_mod_fini(
void)
666 MODULE_DESCRIPTION(
"Serpent and tnepres (kerneli compatible serpent reversed) Cipher Algorithm");