diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2011-11-23 05:21:00 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2011-11-30 03:12:43 -0500 |
commit | 7f4e3e3fa5ba9fb54b280e959bc2a88c42eec76a (patch) | |
tree | 6a7ac54a668829355f75d7499c45817d1e7e28cd /crypto | |
parent | 8b4d43a4e774c02dee359c7931e47b119143f367 (diff) |
crypto: serpent - cleanup checkpatch errors and warnings
Do checkpatch fixes before rename to keep rename patch simple and clean.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/serpent.c | 603 |
1 files changed, 344 insertions, 259 deletions
diff --git a/crypto/serpent.c b/crypto/serpent.c index 7cc2caeb88a5..8f32cf35e5ce 100644 --- a/crypto/serpent.c +++ b/crypto/serpent.c | |||
@@ -6,8 +6,9 @@ | |||
6 | * Copyright (C) 2002 Dag Arne Osvik <osvik@ii.uib.no> | 6 | * Copyright (C) 2002 Dag Arne Osvik <osvik@ii.uib.no> |
7 | * 2003 Herbert Valerio Riedel <hvr@gnu.org> | 7 | * 2003 Herbert Valerio Riedel <hvr@gnu.org> |
8 | * | 8 | * |
9 | * Added tnepres support: Ruben Jesus Garcia Hernandez <ruben@ugr.es>, 18.10.2004 | 9 | * Added tnepres support: |
10 | * Based on code by hvr | 10 | * Ruben Jesus Garcia Hernandez <ruben@ugr.es>, 18.10.2004 |
11 | * Based on code by hvr | ||
11 | * | 12 | * |
12 | * This program is free software; you can redistribute it and/or modify | 13 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by | 14 | * it under the terms of the GNU General Public License as published by |
@@ -29,189 +30,211 @@ | |||
29 | 30 | ||
30 | #define PHI 0x9e3779b9UL | 31 | #define PHI 0x9e3779b9UL |
31 | 32 | ||
32 | #define keyiter(a,b,c,d,i,j) \ | 33 | #define keyiter(a, b, c, d, i, j) \ |
33 | b ^= d; b ^= c; b ^= a; b ^= PHI ^ i; b = rol32(b,11); k[j] = b; | 34 | ({ b ^= d; b ^= c; b ^= a; b ^= PHI ^ i; b = rol32(b, 11); k[j] = b; }) |
34 | 35 | ||
35 | #define loadkeys(x0,x1,x2,x3,i) \ | 36 | #define loadkeys(x0, x1, x2, x3, i) \ |
36 | x0=k[i]; x1=k[i+1]; x2=k[i+2]; x3=k[i+3]; | 37 | ({ x0 = k[i]; x1 = k[i+1]; x2 = k[i+2]; x3 = k[i+3]; }) |
37 | 38 | ||
38 | #define storekeys(x0,x1,x2,x3,i) \ | 39 | #define storekeys(x0, x1, x2, x3, i) \ |
39 | k[i]=x0; k[i+1]=x1; k[i+2]=x2; k[i+3]=x3; | 40 | ({ k[i] = x0; k[i+1] = x1; k[i+2] = x2; k[i+3] = x3; }) |
40 | 41 | ||
41 | #define K(x0,x1,x2,x3,i) \ | 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); }) | ||
44 | |||
45 | #define K(x0, x1, x2, x3, i) ({ \ | ||
42 | x3 ^= k[4*(i)+3]; x2 ^= k[4*(i)+2]; \ | 46 | x3 ^= k[4*(i)+3]; x2 ^= k[4*(i)+2]; \ |
43 | x1 ^= k[4*(i)+1]; x0 ^= k[4*(i)+0]; | 47 | x1 ^= k[4*(i)+1]; x0 ^= k[4*(i)+0]; \ |
44 | 48 | }) | |
45 | #define LK(x0,x1,x2,x3,x4,i) \ | 49 | |
46 | x0=rol32(x0,13);\ | 50 | #define LK(x0, x1, x2, x3, x4, i) ({ \ |
47 | x2=rol32(x2,3); x1 ^= x0; x4 = x0 << 3; \ | 51 | x0 = rol32(x0, 13);\ |
48 | x3 ^= x2; x1 ^= x2; \ | 52 | x2 = rol32(x2, 3); x1 ^= x0; x4 = x0 << 3; \ |
49 | x1=rol32(x1,1); x3 ^= x4; \ | 53 | x3 ^= x2; x1 ^= x2; \ |
50 | x3=rol32(x3,7); x4 = x1; \ | 54 | x1 = rol32(x1, 1); x3 ^= x4; \ |
51 | x0 ^= x1; x4 <<= 7; x2 ^= x3; \ | 55 | x3 = rol32(x3, 7); x4 = x1; \ |
52 | x0 ^= x3; x2 ^= x4; x3 ^= k[4*i+3]; \ | 56 | x0 ^= x1; x4 <<= 7; x2 ^= x3; \ |
53 | x1 ^= k[4*i+1]; x0=rol32(x0,5); x2=rol32(x2,22);\ | 57 | x0 ^= x3; x2 ^= x4; x3 ^= k[4*i+3]; \ |
54 | x0 ^= k[4*i+0]; x2 ^= k[4*i+2]; | 58 | x1 ^= k[4*i+1]; x0 = rol32(x0, 5); x2 = rol32(x2, 22);\ |
55 | 59 | x0 ^= k[4*i+0]; x2 ^= k[4*i+2]; \ | |
56 | #define KL(x0,x1,x2,x3,x4,i) \ | 60 | }) |
57 | x0 ^= k[4*i+0]; x1 ^= k[4*i+1]; x2 ^= k[4*i+2]; \ | 61 | |
58 | x3 ^= k[4*i+3]; x0=ror32(x0,5); x2=ror32(x2,22);\ | 62 | #define KL(x0, x1, x2, x3, x4, i) ({ \ |
59 | x4 = x1; x2 ^= x3; x0 ^= x3; \ | 63 | x0 ^= k[4*i+0]; x1 ^= k[4*i+1]; x2 ^= k[4*i+2]; \ |
60 | x4 <<= 7; x0 ^= x1; x1=ror32(x1,1); \ | 64 | x3 ^= k[4*i+3]; x0 = ror32(x0, 5); x2 = ror32(x2, 22);\ |
61 | x2 ^= x4; x3=ror32(x3,7); x4 = x0 << 3; \ | 65 | x4 = x1; x2 ^= x3; x0 ^= x3; \ |
62 | x1 ^= x0; x3 ^= x4; x0=ror32(x0,13);\ | 66 | x4 <<= 7; x0 ^= x1; x1 = ror32(x1, 1); \ |
63 | x1 ^= x2; x3 ^= x2; x2=ror32(x2,3); | 67 | x2 ^= x4; x3 = ror32(x3, 7); x4 = x0 << 3; \ |
64 | 68 | x1 ^= x0; x3 ^= x4; x0 = ror32(x0, 13);\ | |
65 | #define S0(x0,x1,x2,x3,x4) \ | 69 | x1 ^= x2; x3 ^= x2; x2 = ror32(x2, 3); \ |
70 | }) | ||
71 | |||
72 | #define S0(x0, x1, x2, x3, x4) ({ \ | ||
66 | x4 = x3; \ | 73 | x4 = x3; \ |
67 | x3 |= x0; x0 ^= x4; x4 ^= x2; \ | 74 | x3 |= x0; x0 ^= x4; x4 ^= x2; \ |
68 | x4 =~ x4; x3 ^= x1; x1 &= x0; \ | 75 | x4 = ~x4; x3 ^= x1; x1 &= x0; \ |
69 | x1 ^= x4; x2 ^= x0; x0 ^= x3; \ | 76 | x1 ^= x4; x2 ^= x0; x0 ^= x3; \ |
70 | x4 |= x0; x0 ^= x2; x2 &= x1; \ | 77 | x4 |= x0; x0 ^= x2; x2 &= x1; \ |
71 | x3 ^= x2; x1 =~ x1; x2 ^= x4; \ | 78 | x3 ^= x2; x1 = ~x1; x2 ^= x4; \ |
72 | x1 ^= x2; | 79 | x1 ^= x2; \ |
80 | }) | ||
73 | 81 | ||
74 | #define S1(x0,x1,x2,x3,x4) \ | 82 | #define S1(x0, x1, x2, x3, x4) ({ \ |
75 | x4 = x1; \ | 83 | x4 = x1; \ |
76 | x1 ^= x0; x0 ^= x3; x3 =~ x3; \ | 84 | x1 ^= x0; x0 ^= x3; x3 = ~x3; \ |
77 | x4 &= x1; x0 |= x1; x3 ^= x2; \ | 85 | x4 &= x1; x0 |= x1; x3 ^= x2; \ |
78 | x0 ^= x3; x1 ^= x3; x3 ^= x4; \ | 86 | x0 ^= x3; x1 ^= x3; x3 ^= x4; \ |
79 | x1 |= x4; x4 ^= x2; x2 &= x0; \ | 87 | x1 |= x4; x4 ^= x2; x2 &= x0; \ |
80 | x2 ^= x1; x1 |= x0; x0 =~ x0; \ | 88 | x2 ^= x1; x1 |= x0; x0 = ~x0; \ |
81 | x0 ^= x2; x4 ^= x1; | 89 | x0 ^= x2; x4 ^= x1; \ |
90 | }) | ||
82 | 91 | ||
83 | #define S2(x0,x1,x2,x3,x4) \ | 92 | #define S2(x0, x1, x2, x3, x4) ({ \ |
84 | x3 =~ x3; \ | 93 | x3 = ~x3; \ |
85 | x1 ^= x0; x4 = x0; x0 &= x2; \ | 94 | x1 ^= x0; x4 = x0; x0 &= x2; \ |
86 | x0 ^= x3; x3 |= x4; x2 ^= x1; \ | 95 | x0 ^= x3; x3 |= x4; x2 ^= x1; \ |
87 | x3 ^= x1; x1 &= x0; x0 ^= x2; \ | 96 | x3 ^= x1; x1 &= x0; x0 ^= x2; \ |
88 | x2 &= x3; x3 |= x1; x0 =~ x0; \ | 97 | x2 &= x3; x3 |= x1; x0 = ~x0; \ |
89 | x3 ^= x0; x4 ^= x0; x0 ^= x2; \ | 98 | x3 ^= x0; x4 ^= x0; x0 ^= x2; \ |
90 | x1 |= x2; | 99 | x1 |= x2; \ |
100 | }) | ||
91 | 101 | ||
92 | #define S3(x0,x1,x2,x3,x4) \ | 102 | #define S3(x0, x1, x2, x3, x4) ({ \ |
93 | x4 = x1; \ | 103 | x4 = x1; \ |
94 | x1 ^= x3; x3 |= x0; x4 &= x0; \ | 104 | x1 ^= x3; x3 |= x0; x4 &= x0; \ |
95 | x0 ^= x2; x2 ^= x1; x1 &= x3; \ | 105 | x0 ^= x2; x2 ^= x1; x1 &= x3; \ |
96 | x2 ^= x3; x0 |= x4; x4 ^= x3; \ | 106 | x2 ^= x3; x0 |= x4; x4 ^= x3; \ |
97 | x1 ^= x0; x0 &= x3; x3 &= x4; \ | 107 | x1 ^= x0; x0 &= x3; x3 &= x4; \ |
98 | x3 ^= x2; x4 |= x1; x2 &= x1; \ | 108 | x3 ^= x2; x4 |= x1; x2 &= x1; \ |
99 | x4 ^= x3; x0 ^= x3; x3 ^= x2; | 109 | x4 ^= x3; x0 ^= x3; x3 ^= x2; \ |
110 | }) | ||
100 | 111 | ||
101 | #define S4(x0,x1,x2,x3,x4) \ | 112 | #define S4(x0, x1, x2, x3, x4) ({ \ |
102 | x4 = x3; \ | 113 | x4 = x3; \ |
103 | x3 &= x0; x0 ^= x4; \ | 114 | x3 &= x0; x0 ^= x4; \ |
104 | x3 ^= x2; x2 |= x4; x0 ^= x1; \ | 115 | x3 ^= x2; x2 |= x4; x0 ^= x1; \ |
105 | x4 ^= x3; x2 |= x0; \ | 116 | x4 ^= x3; x2 |= x0; \ |
106 | x2 ^= x1; x1 &= x0; \ | 117 | x2 ^= x1; x1 &= x0; \ |
107 | x1 ^= x4; x4 &= x2; x2 ^= x3; \ | 118 | x1 ^= x4; x4 &= x2; x2 ^= x3; \ |
108 | x4 ^= x0; x3 |= x1; x1 =~ x1; \ | 119 | x4 ^= x0; x3 |= x1; x1 = ~x1; \ |
109 | x3 ^= x0; | 120 | x3 ^= x0; \ |
121 | }) | ||
110 | 122 | ||
111 | #define S5(x0,x1,x2,x3,x4) \ | 123 | #define S5(x0, x1, x2, x3, x4) ({ \ |
112 | x4 = x1; x1 |= x0; \ | 124 | x4 = x1; x1 |= x0; \ |
113 | x2 ^= x1; x3 =~ x3; x4 ^= x0; \ | 125 | x2 ^= x1; x3 = ~x3; x4 ^= x0; \ |
114 | x0 ^= x2; x1 &= x4; x4 |= x3; \ | 126 | x0 ^= x2; x1 &= x4; x4 |= x3; \ |
115 | x4 ^= x0; x0 &= x3; x1 ^= x3; \ | 127 | x4 ^= x0; x0 &= x3; x1 ^= x3; \ |
116 | x3 ^= x2; x0 ^= x1; x2 &= x4; \ | 128 | x3 ^= x2; x0 ^= x1; x2 &= x4; \ |
117 | x1 ^= x2; x2 &= x0; \ | 129 | x1 ^= x2; x2 &= x0; \ |
118 | x3 ^= x2; | 130 | x3 ^= x2; \ |
131 | }) | ||
119 | 132 | ||
120 | #define S6(x0,x1,x2,x3,x4) \ | 133 | #define S6(x0, x1, x2, x3, x4) ({ \ |
121 | x4 = x1; \ | 134 | x4 = x1; \ |
122 | x3 ^= x0; x1 ^= x2; x2 ^= x0; \ | 135 | x3 ^= x0; x1 ^= x2; x2 ^= x0; \ |
123 | x0 &= x3; x1 |= x3; x4 =~ x4; \ | 136 | x0 &= x3; x1 |= x3; x4 = ~x4; \ |
124 | x0 ^= x1; x1 ^= x2; \ | 137 | x0 ^= x1; x1 ^= x2; \ |
125 | x3 ^= x4; x4 ^= x0; x2 &= x0; \ | 138 | x3 ^= x4; x4 ^= x0; x2 &= x0; \ |
126 | x4 ^= x1; x2 ^= x3; x3 &= x1; \ | 139 | x4 ^= x1; x2 ^= x3; x3 &= x1; \ |
127 | x3 ^= x0; x1 ^= x2; | 140 | x3 ^= x0; x1 ^= x2; \ |
141 | }) | ||
128 | 142 | ||
129 | #define S7(x0,x1,x2,x3,x4) \ | 143 | #define S7(x0, x1, x2, x3, x4) ({ \ |
130 | x1 =~ x1; \ | 144 | x1 = ~x1; \ |
131 | x4 = x1; x0 =~ x0; x1 &= x2; \ | 145 | x4 = x1; x0 = ~x0; x1 &= x2; \ |
132 | x1 ^= x3; x3 |= x4; x4 ^= x2; \ | 146 | x1 ^= x3; x3 |= x4; x4 ^= x2; \ |
133 | x2 ^= x3; x3 ^= x0; x0 |= x1; \ | 147 | x2 ^= x3; x3 ^= x0; x0 |= x1; \ |
134 | x2 &= x0; x0 ^= x4; x4 ^= x3; \ | 148 | x2 &= x0; x0 ^= x4; x4 ^= x3; \ |
135 | x3 &= x0; x4 ^= x1; \ | 149 | x3 &= x0; x4 ^= x1; \ |
136 | x2 ^= x4; x3 ^= x1; x4 |= x0; \ | 150 | x2 ^= x4; x3 ^= x1; x4 |= x0; \ |
137 | x4 ^= x1; | 151 | x4 ^= x1; \ |
152 | }) | ||
138 | 153 | ||
139 | #define SI0(x0,x1,x2,x3,x4) \ | 154 | #define SI0(x0, x1, x2, x3, x4) ({ \ |
140 | x4 = x3; x1 ^= x0; \ | 155 | x4 = x3; x1 ^= x0; \ |
141 | x3 |= x1; x4 ^= x1; x0 =~ x0; \ | 156 | x3 |= x1; x4 ^= x1; x0 = ~x0; \ |
142 | x2 ^= x3; x3 ^= x0; x0 &= x1; \ | 157 | x2 ^= x3; x3 ^= x0; x0 &= x1; \ |
143 | x0 ^= x2; x2 &= x3; x3 ^= x4; \ | 158 | x0 ^= x2; x2 &= x3; x3 ^= x4; \ |
144 | x2 ^= x3; x1 ^= x3; x3 &= x0; \ | 159 | x2 ^= x3; x1 ^= x3; x3 &= x0; \ |
145 | x1 ^= x0; x0 ^= x2; x4 ^= x3; | 160 | x1 ^= x0; x0 ^= x2; x4 ^= x3; \ |
161 | }) | ||
146 | 162 | ||
147 | #define SI1(x0,x1,x2,x3,x4) \ | 163 | #define SI1(x0, x1, x2, x3, x4) ({ \ |
148 | x1 ^= x3; x4 = x0; \ | 164 | x1 ^= x3; x4 = x0; \ |
149 | x0 ^= x2; x2 =~ x2; x4 |= x1; \ | 165 | x0 ^= x2; x2 = ~x2; x4 |= x1; \ |
150 | x4 ^= x3; x3 &= x1; x1 ^= x2; \ | 166 | x4 ^= x3; x3 &= x1; x1 ^= x2; \ |
151 | x2 &= x4; x4 ^= x1; x1 |= x3; \ | 167 | x2 &= x4; x4 ^= x1; x1 |= x3; \ |
152 | x3 ^= x0; x2 ^= x0; x0 |= x4; \ | 168 | x3 ^= x0; x2 ^= x0; x0 |= x4; \ |
153 | x2 ^= x4; x1 ^= x0; \ | 169 | x2 ^= x4; x1 ^= x0; \ |
154 | x4 ^= x1; | 170 | x4 ^= x1; \ |
171 | }) | ||
155 | 172 | ||
156 | #define SI2(x0,x1,x2,x3,x4) \ | 173 | #define SI2(x0, x1, x2, x3, x4) ({ \ |
157 | x2 ^= x1; x4 = x3; x3 =~ x3; \ | 174 | x2 ^= x1; x4 = x3; x3 = ~x3; \ |
158 | x3 |= x2; x2 ^= x4; x4 ^= x0; \ | 175 | x3 |= x2; x2 ^= x4; x4 ^= x0; \ |
159 | x3 ^= x1; x1 |= x2; x2 ^= x0; \ | 176 | x3 ^= x1; x1 |= x2; x2 ^= x0; \ |
160 | x1 ^= x4; x4 |= x3; x2 ^= x3; \ | 177 | x1 ^= x4; x4 |= x3; x2 ^= x3; \ |
161 | x4 ^= x2; x2 &= x1; \ | 178 | x4 ^= x2; x2 &= x1; \ |
162 | x2 ^= x3; x3 ^= x4; x4 ^= x0; | 179 | x2 ^= x3; x3 ^= x4; x4 ^= x0; \ |
180 | }) | ||
163 | 181 | ||
164 | #define SI3(x0,x1,x2,x3,x4) \ | 182 | #define SI3(x0, x1, x2, x3, x4) ({ \ |
165 | x2 ^= x1; \ | 183 | x2 ^= x1; \ |
166 | x4 = x1; x1 &= x2; \ | 184 | x4 = x1; x1 &= x2; \ |
167 | x1 ^= x0; x0 |= x4; x4 ^= x3; \ | 185 | x1 ^= x0; x0 |= x4; x4 ^= x3; \ |
168 | x0 ^= x3; x3 |= x1; x1 ^= x2; \ | 186 | x0 ^= x3; x3 |= x1; x1 ^= x2; \ |
169 | x1 ^= x3; x0 ^= x2; x2 ^= x3; \ | 187 | x1 ^= x3; x0 ^= x2; x2 ^= x3; \ |
170 | x3 &= x1; x1 ^= x0; x0 &= x2; \ | 188 | x3 &= x1; x1 ^= x0; x0 &= x2; \ |
171 | x4 ^= x3; x3 ^= x0; x0 ^= x1; | 189 | x4 ^= x3; x3 ^= x0; x0 ^= x1; \ |
190 | }) | ||
172 | 191 | ||
173 | #define SI4(x0,x1,x2,x3,x4) \ | 192 | #define SI4(x0, x1, x2, x3, x4) ({ \ |
174 | x2 ^= x3; x4 = x0; x0 &= x1; \ | 193 | x2 ^= x3; x4 = x0; x0 &= x1; \ |
175 | x0 ^= x2; x2 |= x3; x4 =~ x4; \ | 194 | x0 ^= x2; x2 |= x3; x4 = ~x4; \ |
176 | x1 ^= x0; x0 ^= x2; x2 &= x4; \ | 195 | x1 ^= x0; x0 ^= x2; x2 &= x4; \ |
177 | x2 ^= x0; x0 |= x4; \ | 196 | x2 ^= x0; x0 |= x4; \ |
178 | x0 ^= x3; x3 &= x2; \ | 197 | x0 ^= x3; x3 &= x2; \ |
179 | x4 ^= x3; x3 ^= x1; x1 &= x0; \ | 198 | x4 ^= x3; x3 ^= x1; x1 &= x0; \ |
180 | x4 ^= x1; x0 ^= x3; | 199 | x4 ^= x1; x0 ^= x3; \ |
200 | }) | ||
181 | 201 | ||
182 | #define SI5(x0,x1,x2,x3,x4) \ | 202 | #define SI5(x0, x1, x2, x3, x4) ({ \ |
183 | x4 = x1; x1 |= x2; \ | 203 | x4 = x1; x1 |= x2; \ |
184 | x2 ^= x4; x1 ^= x3; x3 &= x4; \ | 204 | x2 ^= x4; x1 ^= x3; x3 &= x4; \ |
185 | x2 ^= x3; x3 |= x0; x0 =~ x0; \ | 205 | x2 ^= x3; x3 |= x0; x0 = ~x0; \ |
186 | x3 ^= x2; x2 |= x0; x4 ^= x1; \ | 206 | x3 ^= x2; x2 |= x0; x4 ^= x1; \ |
187 | x2 ^= x4; x4 &= x0; x0 ^= x1; \ | 207 | x2 ^= x4; x4 &= x0; x0 ^= x1; \ |
188 | x1 ^= x3; x0 &= x2; x2 ^= x3; \ | 208 | x1 ^= x3; x0 &= x2; x2 ^= x3; \ |
189 | x0 ^= x2; x2 ^= x4; x4 ^= x3; | 209 | x0 ^= x2; x2 ^= x4; x4 ^= x3; \ |
210 | }) | ||
190 | 211 | ||
191 | #define SI6(x0,x1,x2,x3,x4) \ | 212 | #define SI6(x0, x1, x2, x3, x4) ({ \ |
192 | x0 ^= x2; \ | 213 | x0 ^= x2; \ |
193 | x4 = x0; x0 &= x3; x2 ^= x3; \ | 214 | x4 = x0; x0 &= x3; x2 ^= x3; \ |
194 | x0 ^= x2; x3 ^= x1; x2 |= x4; \ | 215 | x0 ^= x2; x3 ^= x1; x2 |= x4; \ |
195 | x2 ^= x3; x3 &= x0; x0 =~ x0; \ | 216 | x2 ^= x3; x3 &= x0; x0 = ~x0; \ |
196 | x3 ^= x1; x1 &= x2; x4 ^= x0; \ | 217 | x3 ^= x1; x1 &= x2; x4 ^= x0; \ |
197 | x3 ^= x4; x4 ^= x2; x0 ^= x1; \ | 218 | x3 ^= x4; x4 ^= x2; x0 ^= x1; \ |
198 | x2 ^= x0; | 219 | x2 ^= x0; \ |
220 | }) | ||
199 | 221 | ||
200 | #define SI7(x0,x1,x2,x3,x4) \ | 222 | #define SI7(x0, x1, x2, x3, x4) ({ \ |
201 | x4 = x3; x3 &= x0; x0 ^= x2; \ | 223 | x4 = x3; x3 &= x0; x0 ^= x2; \ |
202 | x2 |= x4; x4 ^= x1; x0 =~ x0; \ | 224 | x2 |= x4; x4 ^= x1; x0 = ~x0; \ |
203 | x1 |= x3; x4 ^= x0; x0 &= x2; \ | 225 | x1 |= x3; x4 ^= x0; x0 &= x2; \ |
204 | x0 ^= x1; x1 &= x2; x3 ^= x2; \ | 226 | x0 ^= x1; x1 &= x2; x3 ^= x2; \ |
205 | x4 ^= x3; x2 &= x3; x3 |= x0; \ | 227 | x4 ^= x3; x2 &= x3; x3 |= x0; \ |
206 | x1 ^= x4; x3 ^= x4; x4 &= x0; \ | 228 | x1 ^= x4; x3 ^= x4; x4 &= x0; \ |
207 | x4 ^= x2; | 229 | x4 ^= x2; \ |
230 | }) | ||
208 | 231 | ||
209 | int __serpent_setkey(struct serpent_ctx *ctx, const u8 *key, | 232 | int __serpent_setkey(struct serpent_ctx *ctx, const u8 *key, |
210 | unsigned int keylen) | 233 | unsigned int keylen) |
211 | { | 234 | { |
212 | u32 *k = ctx->expkey; | 235 | u32 *k = ctx->expkey; |
213 | u8 *k8 = (u8 *)k; | 236 | u8 *k8 = (u8 *)k; |
214 | u32 r0,r1,r2,r3,r4; | 237 | u32 r0, r1, r2, r3, r4; |
215 | int i; | 238 | int i; |
216 | 239 | ||
217 | /* Copy key, add padding */ | 240 | /* Copy key, add padding */ |
@@ -231,121 +254,183 @@ int __serpent_setkey(struct serpent_ctx *ctx, const u8 *key, | |||
231 | r3 = le32_to_cpu(k[6]); | 254 | r3 = le32_to_cpu(k[6]); |
232 | r4 = le32_to_cpu(k[7]); | 255 | r4 = le32_to_cpu(k[7]); |
233 | 256 | ||
234 | keyiter(le32_to_cpu(k[0]),r0,r4,r2,0,0); | 257 | keyiter(le32_to_cpu(k[0]), r0, r4, r2, 0, 0); |
235 | keyiter(le32_to_cpu(k[1]),r1,r0,r3,1,1); | 258 | keyiter(le32_to_cpu(k[1]), r1, r0, r3, 1, 1); |
236 | keyiter(le32_to_cpu(k[2]),r2,r1,r4,2,2); | 259 | keyiter(le32_to_cpu(k[2]), r2, r1, r4, 2, 2); |
237 | keyiter(le32_to_cpu(k[3]),r3,r2,r0,3,3); | 260 | keyiter(le32_to_cpu(k[3]), r3, r2, r0, 3, 3); |
238 | keyiter(le32_to_cpu(k[4]),r4,r3,r1,4,4); | 261 | keyiter(le32_to_cpu(k[4]), r4, r3, r1, 4, 4); |
239 | keyiter(le32_to_cpu(k[5]),r0,r4,r2,5,5); | 262 | keyiter(le32_to_cpu(k[5]), r0, r4, r2, 5, 5); |
240 | keyiter(le32_to_cpu(k[6]),r1,r0,r3,6,6); | 263 | keyiter(le32_to_cpu(k[6]), r1, r0, r3, 6, 6); |
241 | keyiter(le32_to_cpu(k[7]),r2,r1,r4,7,7); | 264 | keyiter(le32_to_cpu(k[7]), r2, r1, r4, 7, 7); |
242 | 265 | ||
243 | keyiter(k[ 0],r3,r2,r0, 8, 8); keyiter(k[ 1],r4,r3,r1, 9, 9); | 266 | keyiter(k[0], r3, r2, r0, 8, 8); |
244 | keyiter(k[ 2],r0,r4,r2, 10, 10); keyiter(k[ 3],r1,r0,r3, 11, 11); | 267 | keyiter(k[1], r4, r3, r1, 9, 9); |
245 | keyiter(k[ 4],r2,r1,r4, 12, 12); keyiter(k[ 5],r3,r2,r0, 13, 13); | 268 | keyiter(k[2], r0, r4, r2, 10, 10); |
246 | keyiter(k[ 6],r4,r3,r1, 14, 14); keyiter(k[ 7],r0,r4,r2, 15, 15); | 269 | keyiter(k[3], r1, r0, r3, 11, 11); |
247 | keyiter(k[ 8],r1,r0,r3, 16, 16); keyiter(k[ 9],r2,r1,r4, 17, 17); | 270 | keyiter(k[4], r2, r1, r4, 12, 12); |
248 | keyiter(k[ 10],r3,r2,r0, 18, 18); keyiter(k[ 11],r4,r3,r1, 19, 19); | 271 | keyiter(k[5], r3, r2, r0, 13, 13); |
249 | keyiter(k[ 12],r0,r4,r2, 20, 20); keyiter(k[ 13],r1,r0,r3, 21, 21); | 272 | keyiter(k[6], r4, r3, r1, 14, 14); |
250 | keyiter(k[ 14],r2,r1,r4, 22, 22); keyiter(k[ 15],r3,r2,r0, 23, 23); | 273 | keyiter(k[7], r0, r4, r2, 15, 15); |
251 | keyiter(k[ 16],r4,r3,r1, 24, 24); keyiter(k[ 17],r0,r4,r2, 25, 25); | 274 | keyiter(k[8], r1, r0, r3, 16, 16); |
252 | keyiter(k[ 18],r1,r0,r3, 26, 26); keyiter(k[ 19],r2,r1,r4, 27, 27); | 275 | keyiter(k[9], r2, r1, r4, 17, 17); |
253 | keyiter(k[ 20],r3,r2,r0, 28, 28); keyiter(k[ 21],r4,r3,r1, 29, 29); | 276 | keyiter(k[10], r3, r2, r0, 18, 18); |
254 | keyiter(k[ 22],r0,r4,r2, 30, 30); keyiter(k[ 23],r1,r0,r3, 31, 31); | 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); | ||
255 | 290 | ||
256 | k += 50; | 291 | k += 50; |
257 | 292 | ||
258 | keyiter(k[-26],r2,r1,r4, 32,-18); keyiter(k[-25],r3,r2,r0, 33,-17); | 293 | keyiter(k[-26], r2, r1, r4, 32, -18); |
259 | keyiter(k[-24],r4,r3,r1, 34,-16); keyiter(k[-23],r0,r4,r2, 35,-15); | 294 | keyiter(k[-25], r3, r2, r0, 33, -17); |
260 | keyiter(k[-22],r1,r0,r3, 36,-14); keyiter(k[-21],r2,r1,r4, 37,-13); | 295 | keyiter(k[-24], r4, r3, r1, 34, -16); |
261 | keyiter(k[-20],r3,r2,r0, 38,-12); keyiter(k[-19],r4,r3,r1, 39,-11); | 296 | keyiter(k[-23], r0, r4, r2, 35, -15); |
262 | keyiter(k[-18],r0,r4,r2, 40,-10); keyiter(k[-17],r1,r0,r3, 41, -9); | 297 | keyiter(k[-22], r1, r0, r3, 36, -14); |
263 | keyiter(k[-16],r2,r1,r4, 42, -8); keyiter(k[-15],r3,r2,r0, 43, -7); | 298 | keyiter(k[-21], r2, r1, r4, 37, -13); |
264 | keyiter(k[-14],r4,r3,r1, 44, -6); keyiter(k[-13],r0,r4,r2, 45, -5); | 299 | keyiter(k[-20], r3, r2, r0, 38, -12); |
265 | keyiter(k[-12],r1,r0,r3, 46, -4); keyiter(k[-11],r2,r1,r4, 47, -3); | 300 | keyiter(k[-19], r4, r3, r1, 39, -11); |
266 | keyiter(k[-10],r3,r2,r0, 48, -2); keyiter(k[ -9],r4,r3,r1, 49, -1); | 301 | keyiter(k[-18], r0, r4, r2, 40, -10); |
267 | keyiter(k[ -8],r0,r4,r2, 50, 0); keyiter(k[ -7],r1,r0,r3, 51, 1); | 302 | keyiter(k[-17], r1, r0, r3, 41, -9); |
268 | keyiter(k[ -6],r2,r1,r4, 52, 2); keyiter(k[ -5],r3,r2,r0, 53, 3); | 303 | keyiter(k[-16], r2, r1, r4, 42, -8); |
269 | keyiter(k[ -4],r4,r3,r1, 54, 4); keyiter(k[ -3],r0,r4,r2, 55, 5); | 304 | keyiter(k[-15], r3, r2, r0, 43, -7); |
270 | keyiter(k[ -2],r1,r0,r3, 56, 6); keyiter(k[ -1],r2,r1,r4, 57, 7); | 305 | keyiter(k[-14], r4, r3, r1, 44, -6); |
271 | keyiter(k[ 0],r3,r2,r0, 58, 8); keyiter(k[ 1],r4,r3,r1, 59, 9); | 306 | keyiter(k[-13], r0, r4, r2, 45, -5); |
272 | keyiter(k[ 2],r0,r4,r2, 60, 10); keyiter(k[ 3],r1,r0,r3, 61, 11); | 307 | keyiter(k[-12], r1, r0, r3, 46, -4); |
273 | keyiter(k[ 4],r2,r1,r4, 62, 12); keyiter(k[ 5],r3,r2,r0, 63, 13); | 308 | keyiter(k[-11], r2, r1, r4, 47, -3); |
274 | keyiter(k[ 6],r4,r3,r1, 64, 14); keyiter(k[ 7],r0,r4,r2, 65, 15); | 309 | keyiter(k[-10], r3, r2, r0, 48, -2); |
275 | keyiter(k[ 8],r1,r0,r3, 66, 16); keyiter(k[ 9],r2,r1,r4, 67, 17); | 310 | keyiter(k[-9], r4, r3, r1, 49, -1); |
276 | keyiter(k[ 10],r3,r2,r0, 68, 18); keyiter(k[ 11],r4,r3,r1, 69, 19); | 311 | keyiter(k[-8], r0, r4, r2, 50, 0); |
277 | keyiter(k[ 12],r0,r4,r2, 70, 20); keyiter(k[ 13],r1,r0,r3, 71, 21); | 312 | keyiter(k[-7], r1, r0, r3, 51, 1); |
278 | keyiter(k[ 14],r2,r1,r4, 72, 22); keyiter(k[ 15],r3,r2,r0, 73, 23); | 313 | keyiter(k[-6], r2, r1, r4, 52, 2); |
279 | keyiter(k[ 16],r4,r3,r1, 74, 24); keyiter(k[ 17],r0,r4,r2, 75, 25); | 314 | keyiter(k[-5], r3, r2, r0, 53, 3); |
280 | keyiter(k[ 18],r1,r0,r3, 76, 26); keyiter(k[ 19],r2,r1,r4, 77, 27); | 315 | keyiter(k[-4], r4, r3, r1, 54, 4); |
281 | keyiter(k[ 20],r3,r2,r0, 78, 28); keyiter(k[ 21],r4,r3,r1, 79, 29); | 316 | keyiter(k[-3], r0, r4, r2, 55, 5); |
282 | keyiter(k[ 22],r0,r4,r2, 80, 30); keyiter(k[ 23],r1,r0,r3, 81, 31); | 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); | ||
283 | 343 | ||
284 | k += 50; | 344 | k += 50; |
285 | 345 | ||
286 | keyiter(k[-26],r2,r1,r4, 82,-18); keyiter(k[-25],r3,r2,r0, 83,-17); | 346 | keyiter(k[-26], r2, r1, r4, 82, -18); |
287 | keyiter(k[-24],r4,r3,r1, 84,-16); keyiter(k[-23],r0,r4,r2, 85,-15); | 347 | keyiter(k[-25], r3, r2, r0, 83, -17); |
288 | keyiter(k[-22],r1,r0,r3, 86,-14); keyiter(k[-21],r2,r1,r4, 87,-13); | 348 | keyiter(k[-24], r4, r3, r1, 84, -16); |
289 | keyiter(k[-20],r3,r2,r0, 88,-12); keyiter(k[-19],r4,r3,r1, 89,-11); | 349 | keyiter(k[-23], r0, r4, r2, 85, -15); |
290 | keyiter(k[-18],r0,r4,r2, 90,-10); keyiter(k[-17],r1,r0,r3, 91, -9); | 350 | keyiter(k[-22], r1, r0, r3, 86, -14); |
291 | keyiter(k[-16],r2,r1,r4, 92, -8); keyiter(k[-15],r3,r2,r0, 93, -7); | 351 | keyiter(k[-21], r2, r1, r4, 87, -13); |
292 | keyiter(k[-14],r4,r3,r1, 94, -6); keyiter(k[-13],r0,r4,r2, 95, -5); | 352 | keyiter(k[-20], r3, r2, r0, 88, -12); |
293 | keyiter(k[-12],r1,r0,r3, 96, -4); keyiter(k[-11],r2,r1,r4, 97, -3); | 353 | keyiter(k[-19], r4, r3, r1, 89, -11); |
294 | keyiter(k[-10],r3,r2,r0, 98, -2); keyiter(k[ -9],r4,r3,r1, 99, -1); | 354 | keyiter(k[-18], r0, r4, r2, 90, -10); |
295 | keyiter(k[ -8],r0,r4,r2,100, 0); keyiter(k[ -7],r1,r0,r3,101, 1); | 355 | keyiter(k[-17], r1, r0, r3, 91, -9); |
296 | keyiter(k[ -6],r2,r1,r4,102, 2); keyiter(k[ -5],r3,r2,r0,103, 3); | 356 | keyiter(k[-16], r2, r1, r4, 92, -8); |
297 | keyiter(k[ -4],r4,r3,r1,104, 4); keyiter(k[ -3],r0,r4,r2,105, 5); | 357 | keyiter(k[-15], r3, r2, r0, 93, -7); |
298 | keyiter(k[ -2],r1,r0,r3,106, 6); keyiter(k[ -1],r2,r1,r4,107, 7); | 358 | keyiter(k[-14], r4, r3, r1, 94, -6); |
299 | keyiter(k[ 0],r3,r2,r0,108, 8); keyiter(k[ 1],r4,r3,r1,109, 9); | 359 | keyiter(k[-13], r0, r4, r2, 95, -5); |
300 | keyiter(k[ 2],r0,r4,r2,110, 10); keyiter(k[ 3],r1,r0,r3,111, 11); | 360 | keyiter(k[-12], r1, r0, r3, 96, -4); |
301 | keyiter(k[ 4],r2,r1,r4,112, 12); keyiter(k[ 5],r3,r2,r0,113, 13); | 361 | keyiter(k[-11], r2, r1, r4, 97, -3); |
302 | keyiter(k[ 6],r4,r3,r1,114, 14); keyiter(k[ 7],r0,r4,r2,115, 15); | 362 | keyiter(k[-10], r3, r2, r0, 98, -2); |
303 | keyiter(k[ 8],r1,r0,r3,116, 16); keyiter(k[ 9],r2,r1,r4,117, 17); | 363 | keyiter(k[-9], r4, r3, r1, 99, -1); |
304 | keyiter(k[ 10],r3,r2,r0,118, 18); keyiter(k[ 11],r4,r3,r1,119, 19); | 364 | keyiter(k[-8], r0, r4, r2, 100, 0); |
305 | keyiter(k[ 12],r0,r4,r2,120, 20); keyiter(k[ 13],r1,r0,r3,121, 21); | 365 | keyiter(k[-7], r1, r0, r3, 101, 1); |
306 | keyiter(k[ 14],r2,r1,r4,122, 22); keyiter(k[ 15],r3,r2,r0,123, 23); | 366 | keyiter(k[-6], r2, r1, r4, 102, 2); |
307 | keyiter(k[ 16],r4,r3,r1,124, 24); keyiter(k[ 17],r0,r4,r2,125, 25); | 367 | keyiter(k[-5], r3, r2, r0, 103, 3); |
308 | keyiter(k[ 18],r1,r0,r3,126, 26); keyiter(k[ 19],r2,r1,r4,127, 27); | 368 | keyiter(k[-4], r4, r3, r1, 104, 4); |
309 | keyiter(k[ 20],r3,r2,r0,128, 28); keyiter(k[ 21],r4,r3,r1,129, 29); | 369 | keyiter(k[-3], r0, r4, r2, 105, 5); |
310 | keyiter(k[ 22],r0,r4,r2,130, 30); keyiter(k[ 23],r1,r0,r3,131, 31); | 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); | ||
311 | 396 | ||
312 | /* Apply S-boxes */ | 397 | /* Apply S-boxes */ |
313 | 398 | ||
314 | S3(r3,r4,r0,r1,r2); storekeys(r1,r2,r4,r3, 28); loadkeys(r1,r2,r4,r3, 24); | 399 | S3(r3, r4, r0, r1, r2); store_and_load_keys(r1, r2, r4, r3, 28, 24); |
315 | S4(r1,r2,r4,r3,r0); storekeys(r2,r4,r3,r0, 24); loadkeys(r2,r4,r3,r0, 20); | 400 | S4(r1, r2, r4, r3, r0); store_and_load_keys(r2, r4, r3, r0, 24, 20); |
316 | S5(r2,r4,r3,r0,r1); storekeys(r1,r2,r4,r0, 20); loadkeys(r1,r2,r4,r0, 16); | 401 | S5(r2, r4, r3, r0, r1); store_and_load_keys(r1, r2, r4, r0, 20, 16); |
317 | S6(r1,r2,r4,r0,r3); storekeys(r4,r3,r2,r0, 16); loadkeys(r4,r3,r2,r0, 12); | 402 | S6(r1, r2, r4, r0, r3); store_and_load_keys(r4, r3, r2, r0, 16, 12); |
318 | S7(r4,r3,r2,r0,r1); storekeys(r1,r2,r0,r4, 12); loadkeys(r1,r2,r0,r4, 8); | 403 | S7(r4, r3, r2, r0, r1); store_and_load_keys(r1, r2, r0, r4, 12, 8); |
319 | S0(r1,r2,r0,r4,r3); storekeys(r0,r2,r4,r1, 8); loadkeys(r0,r2,r4,r1, 4); | 404 | S0(r1, r2, r0, r4, r3); store_and_load_keys(r0, r2, r4, r1, 8, 4); |
320 | S1(r0,r2,r4,r1,r3); storekeys(r3,r4,r1,r0, 4); loadkeys(r3,r4,r1,r0, 0); | 405 | S1(r0, r2, r4, r1, r3); store_and_load_keys(r3, r4, r1, r0, 4, 0); |
321 | S2(r3,r4,r1,r0,r2); storekeys(r2,r4,r3,r0, 0); loadkeys(r2,r4,r3,r0, -4); | 406 | S2(r3, r4, r1, r0, r2); store_and_load_keys(r2, r4, r3, r0, 0, -4); |
322 | S3(r2,r4,r3,r0,r1); storekeys(r0,r1,r4,r2, -4); loadkeys(r0,r1,r4,r2, -8); | 407 | S3(r2, r4, r3, r0, r1); store_and_load_keys(r0, r1, r4, r2, -4, -8); |
323 | S4(r0,r1,r4,r2,r3); storekeys(r1,r4,r2,r3, -8); loadkeys(r1,r4,r2,r3,-12); | 408 | S4(r0, r1, r4, r2, r3); store_and_load_keys(r1, r4, r2, r3, -8, -12); |
324 | S5(r1,r4,r2,r3,r0); storekeys(r0,r1,r4,r3,-12); loadkeys(r0,r1,r4,r3,-16); | 409 | S5(r1, r4, r2, r3, r0); store_and_load_keys(r0, r1, r4, r3, -12, -16); |
325 | S6(r0,r1,r4,r3,r2); storekeys(r4,r2,r1,r3,-16); loadkeys(r4,r2,r1,r3,-20); | 410 | S6(r0, r1, r4, r3, r2); store_and_load_keys(r4, r2, r1, r3, -16, -20); |
326 | S7(r4,r2,r1,r3,r0); storekeys(r0,r1,r3,r4,-20); loadkeys(r0,r1,r3,r4,-24); | 411 | S7(r4, r2, r1, r3, r0); store_and_load_keys(r0, r1, r3, r4, -20, -24); |
327 | S0(r0,r1,r3,r4,r2); storekeys(r3,r1,r4,r0,-24); loadkeys(r3,r1,r4,r0,-28); | 412 | S0(r0, r1, r3, r4, r2); store_and_load_keys(r3, r1, r4, r0, -24, -28); |
328 | k -= 50; | 413 | k -= 50; |
329 | S1(r3,r1,r4,r0,r2); storekeys(r2,r4,r0,r3, 22); loadkeys(r2,r4,r0,r3, 18); | 414 | S1(r3, r1, r4, r0, r2); store_and_load_keys(r2, r4, r0, r3, 22, 18); |
330 | S2(r2,r4,r0,r3,r1); storekeys(r1,r4,r2,r3, 18); loadkeys(r1,r4,r2,r3, 14); | 415 | S2(r2, r4, r0, r3, r1); store_and_load_keys(r1, r4, r2, r3, 18, 14); |
331 | S3(r1,r4,r2,r3,r0); storekeys(r3,r0,r4,r1, 14); loadkeys(r3,r0,r4,r1, 10); | 416 | S3(r1, r4, r2, r3, r0); store_and_load_keys(r3, r0, r4, r1, 14, 10); |
332 | S4(r3,r0,r4,r1,r2); storekeys(r0,r4,r1,r2, 10); loadkeys(r0,r4,r1,r2, 6); | 417 | S4(r3, r0, r4, r1, r2); store_and_load_keys(r0, r4, r1, r2, 10, 6); |
333 | S5(r0,r4,r1,r2,r3); storekeys(r3,r0,r4,r2, 6); loadkeys(r3,r0,r4,r2, 2); | 418 | S5(r0, r4, r1, r2, r3); store_and_load_keys(r3, r0, r4, r2, 6, 2); |
334 | S6(r3,r0,r4,r2,r1); storekeys(r4,r1,r0,r2, 2); loadkeys(r4,r1,r0,r2, -2); | 419 | S6(r3, r0, r4, r2, r1); store_and_load_keys(r4, r1, r0, r2, 2, -2); |
335 | S7(r4,r1,r0,r2,r3); storekeys(r3,r0,r2,r4, -2); loadkeys(r3,r0,r2,r4, -6); | 420 | S7(r4, r1, r0, r2, r3); store_and_load_keys(r3, r0, r2, r4, -2, -6); |
336 | S0(r3,r0,r2,r4,r1); storekeys(r2,r0,r4,r3, -6); loadkeys(r2,r0,r4,r3,-10); | 421 | S0(r3, r0, r2, r4, r1); store_and_load_keys(r2, r0, r4, r3, -6, -10); |
337 | S1(r2,r0,r4,r3,r1); storekeys(r1,r4,r3,r2,-10); loadkeys(r1,r4,r3,r2,-14); | 422 | S1(r2, r0, r4, r3, r1); store_and_load_keys(r1, r4, r3, r2, -10, -14); |
338 | S2(r1,r4,r3,r2,r0); storekeys(r0,r4,r1,r2,-14); loadkeys(r0,r4,r1,r2,-18); | 423 | S2(r1, r4, r3, r2, r0); store_and_load_keys(r0, r4, r1, r2, -14, -18); |
339 | S3(r0,r4,r1,r2,r3); storekeys(r2,r3,r4,r0,-18); loadkeys(r2,r3,r4,r0,-22); | 424 | S3(r0, r4, r1, r2, r3); store_and_load_keys(r2, r3, r4, r0, -18, -22); |
340 | k -= 50; | 425 | k -= 50; |
341 | S4(r2,r3,r4,r0,r1); storekeys(r3,r4,r0,r1, 28); loadkeys(r3,r4,r0,r1, 24); | 426 | S4(r2, r3, r4, r0, r1); store_and_load_keys(r3, r4, r0, r1, 28, 24); |
342 | S5(r3,r4,r0,r1,r2); storekeys(r2,r3,r4,r1, 24); loadkeys(r2,r3,r4,r1, 20); | 427 | S5(r3, r4, r0, r1, r2); store_and_load_keys(r2, r3, r4, r1, 24, 20); |
343 | S6(r2,r3,r4,r1,r0); storekeys(r4,r0,r3,r1, 20); loadkeys(r4,r0,r3,r1, 16); | 428 | S6(r2, r3, r4, r1, r0); store_and_load_keys(r4, r0, r3, r1, 20, 16); |
344 | S7(r4,r0,r3,r1,r2); storekeys(r2,r3,r1,r4, 16); loadkeys(r2,r3,r1,r4, 12); | 429 | S7(r4, r0, r3, r1, r2); store_and_load_keys(r2, r3, r1, r4, 16, 12); |
345 | S0(r2,r3,r1,r4,r0); storekeys(r1,r3,r4,r2, 12); loadkeys(r1,r3,r4,r2, 8); | 430 | S0(r2, r3, r1, r4, r0); store_and_load_keys(r1, r3, r4, r2, 12, 8); |
346 | S1(r1,r3,r4,r2,r0); storekeys(r0,r4,r2,r1, 8); loadkeys(r0,r4,r2,r1, 4); | 431 | S1(r1, r3, r4, r2, r0); store_and_load_keys(r0, r4, r2, r1, 8, 4); |
347 | S2(r0,r4,r2,r1,r3); storekeys(r3,r4,r0,r1, 4); loadkeys(r3,r4,r0,r1, 0); | 432 | S2(r0, r4, r2, r1, r3); store_and_load_keys(r3, r4, r0, r1, 4, 0); |
348 | S3(r3,r4,r0,r1,r2); storekeys(r1,r2,r4,r3, 0); | 433 | S3(r3, r4, r0, r1, r2); storekeys(r1, r2, r4, r3, 0); |
349 | 434 | ||
350 | return 0; | 435 | return 0; |
351 | } | 436 | } |
@@ -374,39 +459,39 @@ void __serpent_encrypt(struct serpent_ctx *ctx, u8 *dst, const u8 *src) | |||
374 | r2 = le32_to_cpu(s[2]); | 459 | r2 = le32_to_cpu(s[2]); |
375 | r3 = le32_to_cpu(s[3]); | 460 | r3 = le32_to_cpu(s[3]); |
376 | 461 | ||
377 | K(r0,r1,r2,r3,0); | 462 | K(r0, r1, r2, r3, 0); |
378 | S0(r0,r1,r2,r3,r4); LK(r2,r1,r3,r0,r4,1); | 463 | S0(r0, r1, r2, r3, r4); LK(r2, r1, r3, r0, r4, 1); |
379 | S1(r2,r1,r3,r0,r4); LK(r4,r3,r0,r2,r1,2); | 464 | S1(r2, r1, r3, r0, r4); LK(r4, r3, r0, r2, r1, 2); |
380 | S2(r4,r3,r0,r2,r1); LK(r1,r3,r4,r2,r0,3); | 465 | S2(r4, r3, r0, r2, r1); LK(r1, r3, r4, r2, r0, 3); |
381 | S3(r1,r3,r4,r2,r0); LK(r2,r0,r3,r1,r4,4); | 466 | S3(r1, r3, r4, r2, r0); LK(r2, r0, r3, r1, r4, 4); |
382 | S4(r2,r0,r3,r1,r4); LK(r0,r3,r1,r4,r2,5); | 467 | S4(r2, r0, r3, r1, r4); LK(r0, r3, r1, r4, r2, 5); |
383 | S5(r0,r3,r1,r4,r2); LK(r2,r0,r3,r4,r1,6); | 468 | S5(r0, r3, r1, r4, r2); LK(r2, r0, r3, r4, r1, 6); |
384 | S6(r2,r0,r3,r4,r1); LK(r3,r1,r0,r4,r2,7); | 469 | S6(r2, r0, r3, r4, r1); LK(r3, r1, r0, r4, r2, 7); |
385 | S7(r3,r1,r0,r4,r2); LK(r2,r0,r4,r3,r1,8); | 470 | S7(r3, r1, r0, r4, r2); LK(r2, r0, r4, r3, r1, 8); |
386 | S0(r2,r0,r4,r3,r1); LK(r4,r0,r3,r2,r1,9); | 471 | S0(r2, r0, r4, r3, r1); LK(r4, r0, r3, r2, r1, 9); |
387 | S1(r4,r0,r3,r2,r1); LK(r1,r3,r2,r4,r0,10); | 472 | S1(r4, r0, r3, r2, r1); LK(r1, r3, r2, r4, r0, 10); |
388 | S2(r1,r3,r2,r4,r0); LK(r0,r3,r1,r4,r2,11); | 473 | S2(r1, r3, r2, r4, r0); LK(r0, r3, r1, r4, r2, 11); |
389 | S3(r0,r3,r1,r4,r2); LK(r4,r2,r3,r0,r1,12); | 474 | S3(r0, r3, r1, r4, r2); LK(r4, r2, r3, r0, r1, 12); |
390 | S4(r4,r2,r3,r0,r1); LK(r2,r3,r0,r1,r4,13); | 475 | S4(r4, r2, r3, r0, r1); LK(r2, r3, r0, r1, r4, 13); |
391 | S5(r2,r3,r0,r1,r4); LK(r4,r2,r3,r1,r0,14); | 476 | S5(r2, r3, r0, r1, r4); LK(r4, r2, r3, r1, r0, 14); |
392 | S6(r4,r2,r3,r1,r0); LK(r3,r0,r2,r1,r4,15); | 477 | S6(r4, r2, r3, r1, r0); LK(r3, r0, r2, r1, r4, 15); |
393 | S7(r3,r0,r2,r1,r4); LK(r4,r2,r1,r3,r0,16); | 478 | S7(r3, r0, r2, r1, r4); LK(r4, r2, r1, r3, r0, 16); |
394 | S0(r4,r2,r1,r3,r0); LK(r1,r2,r3,r4,r0,17); | 479 | S0(r4, r2, r1, r3, r0); LK(r1, r2, r3, r4, r0, 17); |
395 | S1(r1,r2,r3,r4,r0); LK(r0,r3,r4,r1,r2,18); | 480 | S1(r1, r2, r3, r4, r0); LK(r0, r3, r4, r1, r2, 18); |
396 | S2(r0,r3,r4,r1,r2); LK(r2,r3,r0,r1,r4,19); | 481 | S2(r0, r3, r4, r1, r2); LK(r2, r3, r0, r1, r4, 19); |
397 | S3(r2,r3,r0,r1,r4); LK(r1,r4,r3,r2,r0,20); | 482 | S3(r2, r3, r0, r1, r4); LK(r1, r4, r3, r2, r0, 20); |
398 | S4(r1,r4,r3,r2,r0); LK(r4,r3,r2,r0,r1,21); | 483 | S4(r1, r4, r3, r2, r0); LK(r4, r3, r2, r0, r1, 21); |
399 | S5(r4,r3,r2,r0,r1); LK(r1,r4,r3,r0,r2,22); | 484 | S5(r4, r3, r2, r0, r1); LK(r1, r4, r3, r0, r2, 22); |
400 | S6(r1,r4,r3,r0,r2); LK(r3,r2,r4,r0,r1,23); | 485 | S6(r1, r4, r3, r0, r2); LK(r3, r2, r4, r0, r1, 23); |
401 | S7(r3,r2,r4,r0,r1); LK(r1,r4,r0,r3,r2,24); | 486 | S7(r3, r2, r4, r0, r1); LK(r1, r4, r0, r3, r2, 24); |
402 | S0(r1,r4,r0,r3,r2); LK(r0,r4,r3,r1,r2,25); | 487 | S0(r1, r4, r0, r3, r2); LK(r0, r4, r3, r1, r2, 25); |
403 | S1(r0,r4,r3,r1,r2); LK(r2,r3,r1,r0,r4,26); | 488 | S1(r0, r4, r3, r1, r2); LK(r2, r3, r1, r0, r4, 26); |
404 | S2(r2,r3,r1,r0,r4); LK(r4,r3,r2,r0,r1,27); | 489 | S2(r2, r3, r1, r0, r4); LK(r4, r3, r2, r0, r1, 27); |
405 | S3(r4,r3,r2,r0,r1); LK(r0,r1,r3,r4,r2,28); | 490 | S3(r4, r3, r2, r0, r1); LK(r0, r1, r3, r4, r2, 28); |
406 | S4(r0,r1,r3,r4,r2); LK(r1,r3,r4,r2,r0,29); | 491 | S4(r0, r1, r3, r4, r2); LK(r1, r3, r4, r2, r0, 29); |
407 | S5(r1,r3,r4,r2,r0); LK(r0,r1,r3,r2,r4,30); | 492 | S5(r1, r3, r4, r2, r0); LK(r0, r1, r3, r2, r4, 30); |
408 | S6(r0,r1,r3,r2,r4); LK(r3,r4,r1,r2,r0,31); | 493 | S6(r0, r1, r3, r2, r4); LK(r3, r4, r1, r2, r0, 31); |
409 | S7(r3,r4,r1,r2,r0); K(r0,r1,r2,r3,32); | 494 | S7(r3, r4, r1, r2, r0); K(r0, r1, r2, r3, 32); |
410 | 495 | ||
411 | d[0] = cpu_to_le32(r0); | 496 | d[0] = cpu_to_le32(r0); |
412 | d[1] = cpu_to_le32(r1); | 497 | d[1] = cpu_to_le32(r1); |
@@ -434,39 +519,39 @@ void __serpent_decrypt(struct serpent_ctx *ctx, u8 *dst, const u8 *src) | |||
434 | r2 = le32_to_cpu(s[2]); | 519 | r2 = le32_to_cpu(s[2]); |
435 | r3 = le32_to_cpu(s[3]); | 520 | r3 = le32_to_cpu(s[3]); |
436 | 521 | ||
437 | K(r0,r1,r2,r3,32); | 522 | K(r0, r1, r2, r3, 32); |
438 | SI7(r0,r1,r2,r3,r4); KL(r1,r3,r0,r4,r2,31); | 523 | SI7(r0, r1, r2, r3, r4); KL(r1, r3, r0, r4, r2, 31); |
439 | SI6(r1,r3,r0,r4,r2); KL(r0,r2,r4,r1,r3,30); | 524 | SI6(r1, r3, r0, r4, r2); KL(r0, r2, r4, r1, r3, 30); |
440 | SI5(r0,r2,r4,r1,r3); KL(r2,r3,r0,r4,r1,29); | 525 | SI5(r0, r2, r4, r1, r3); KL(r2, r3, r0, r4, r1, 29); |
441 | SI4(r2,r3,r0,r4,r1); KL(r2,r0,r1,r4,r3,28); | 526 | SI4(r2, r3, r0, r4, r1); KL(r2, r0, r1, r4, r3, 28); |
442 | SI3(r2,r0,r1,r4,r3); KL(r1,r2,r3,r4,r0,27); | 527 | SI3(r2, r0, r1, r4, r3); KL(r1, r2, r3, r4, r0, 27); |
443 | SI2(r1,r2,r3,r4,r0); KL(r2,r0,r4,r3,r1,26); | 528 | SI2(r1, r2, r3, r4, r0); KL(r2, r0, r4, r3, r1, 26); |
444 | SI1(r2,r0,r4,r3,r1); KL(r1,r0,r4,r3,r2,25); | 529 | SI1(r2, r0, r4, r3, r1); KL(r1, r0, r4, r3, r2, 25); |
445 | SI0(r1,r0,r4,r3,r2); KL(r4,r2,r0,r1,r3,24); | 530 | SI0(r1, r0, r4, r3, r2); KL(r4, r2, r0, r1, r3, 24); |
446 | SI7(r4,r2,r0,r1,r3); KL(r2,r1,r4,r3,r0,23); | 531 | SI7(r4, r2, r0, r1, r3); KL(r2, r1, r4, r3, r0, 23); |
447 | SI6(r2,r1,r4,r3,r0); KL(r4,r0,r3,r2,r1,22); | 532 | SI6(r2, r1, r4, r3, r0); KL(r4, r0, r3, r2, r1, 22); |
448 | SI5(r4,r0,r3,r2,r1); KL(r0,r1,r4,r3,r2,21); | 533 | SI5(r4, r0, r3, r2, r1); KL(r0, r1, r4, r3, r2, 21); |
449 | SI4(r0,r1,r4,r3,r2); KL(r0,r4,r2,r3,r1,20); | 534 | SI4(r0, r1, r4, r3, r2); KL(r0, r4, r2, r3, r1, 20); |
450 | SI3(r0,r4,r2,r3,r1); KL(r2,r0,r1,r3,r4,19); | 535 | SI3(r0, r4, r2, r3, r1); KL(r2, r0, r1, r3, r4, 19); |
451 | SI2(r2,r0,r1,r3,r4); KL(r0,r4,r3,r1,r2,18); | 536 | SI2(r2, r0, r1, r3, r4); KL(r0, r4, r3, r1, r2, 18); |
452 | SI1(r0,r4,r3,r1,r2); KL(r2,r4,r3,r1,r0,17); | 537 | SI1(r0, r4, r3, r1, r2); KL(r2, r4, r3, r1, r0, 17); |
453 | SI0(r2,r4,r3,r1,r0); KL(r3,r0,r4,r2,r1,16); | 538 | SI0(r2, r4, r3, r1, r0); KL(r3, r0, r4, r2, r1, 16); |
454 | SI7(r3,r0,r4,r2,r1); KL(r0,r2,r3,r1,r4,15); | 539 | SI7(r3, r0, r4, r2, r1); KL(r0, r2, r3, r1, r4, 15); |
455 | SI6(r0,r2,r3,r1,r4); KL(r3,r4,r1,r0,r2,14); | 540 | SI6(r0, r2, r3, r1, r4); KL(r3, r4, r1, r0, r2, 14); |
456 | SI5(r3,r4,r1,r0,r2); KL(r4,r2,r3,r1,r0,13); | 541 | SI5(r3, r4, r1, r0, r2); KL(r4, r2, r3, r1, r0, 13); |
457 | SI4(r4,r2,r3,r1,r0); KL(r4,r3,r0,r1,r2,12); | 542 | SI4(r4, r2, r3, r1, r0); KL(r4, r3, r0, r1, r2, 12); |
458 | SI3(r4,r3,r0,r1,r2); KL(r0,r4,r2,r1,r3,11); | 543 | SI3(r4, r3, r0, r1, r2); KL(r0, r4, r2, r1, r3, 11); |
459 | SI2(r0,r4,r2,r1,r3); KL(r4,r3,r1,r2,r0,10); | 544 | SI2(r0, r4, r2, r1, r3); KL(r4, r3, r1, r2, r0, 10); |
460 | SI1(r4,r3,r1,r2,r0); KL(r0,r3,r1,r2,r4,9); | 545 | SI1(r4, r3, r1, r2, r0); KL(r0, r3, r1, r2, r4, 9); |
461 | SI0(r0,r3,r1,r2,r4); KL(r1,r4,r3,r0,r2,8); | 546 | SI0(r0, r3, r1, r2, r4); KL(r1, r4, r3, r0, r2, 8); |
462 | SI7(r1,r4,r3,r0,r2); KL(r4,r0,r1,r2,r3,7); | 547 | SI7(r1, r4, r3, r0, r2); KL(r4, r0, r1, r2, r3, 7); |
463 | SI6(r4,r0,r1,r2,r3); KL(r1,r3,r2,r4,r0,6); | 548 | SI6(r4, r0, r1, r2, r3); KL(r1, r3, r2, r4, r0, 6); |
464 | SI5(r1,r3,r2,r4,r0); KL(r3,r0,r1,r2,r4,5); | 549 | SI5(r1, r3, r2, r4, r0); KL(r3, r0, r1, r2, r4, 5); |
465 | SI4(r3,r0,r1,r2,r4); KL(r3,r1,r4,r2,r0,4); | 550 | SI4(r3, r0, r1, r2, r4); KL(r3, r1, r4, r2, r0, 4); |
466 | SI3(r3,r1,r4,r2,r0); KL(r4,r3,r0,r2,r1,3); | 551 | SI3(r3, r1, r4, r2, r0); KL(r4, r3, r0, r2, r1, 3); |
467 | SI2(r4,r3,r0,r2,r1); KL(r3,r1,r2,r0,r4,2); | 552 | SI2(r4, r3, r0, r2, r1); KL(r3, r1, r2, r0, r4, 2); |
468 | SI1(r3,r1,r2,r0,r4); KL(r4,r1,r2,r0,r3,1); | 553 | SI1(r3, r1, r2, r0, r4); KL(r4, r1, r2, r0, r3, 1); |
469 | SI0(r4,r1,r2,r0,r3); K(r2,r3,r1,r4,0); | 554 | SI0(r4, r1, r2, r0, r3); K(r2, r3, r1, r4, 0); |
470 | 555 | ||
471 | d[0] = cpu_to_le32(r2); | 556 | d[0] = cpu_to_le32(r2); |
472 | d[1] = cpu_to_le32(r3); | 557 | d[1] = cpu_to_le32(r3); |
@@ -495,9 +580,9 @@ static struct crypto_alg serpent_alg = { | |||
495 | .cra_u = { .cipher = { | 580 | .cra_u = { .cipher = { |
496 | .cia_min_keysize = SERPENT_MIN_KEY_SIZE, | 581 | .cia_min_keysize = SERPENT_MIN_KEY_SIZE, |
497 | .cia_max_keysize = SERPENT_MAX_KEY_SIZE, | 582 | .cia_max_keysize = SERPENT_MAX_KEY_SIZE, |
498 | .cia_setkey = serpent_setkey, | 583 | .cia_setkey = serpent_setkey, |
499 | .cia_encrypt = serpent_encrypt, | 584 | .cia_encrypt = serpent_encrypt, |
500 | .cia_decrypt = serpent_decrypt } } | 585 | .cia_decrypt = serpent_decrypt } } |
501 | }; | 586 | }; |
502 | 587 | ||
503 | static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key, | 588 | static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key, |
@@ -508,7 +593,7 @@ static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key, | |||
508 | 593 | ||
509 | for (i = 0; i < keylen; ++i) | 594 | for (i = 0; i < keylen; ++i) |
510 | rev_key[keylen - i - 1] = key[i]; | 595 | rev_key[keylen - i - 1] = key[i]; |
511 | 596 | ||
512 | return serpent_setkey(tfm, rev_key, keylen); | 597 | return serpent_setkey(tfm, rev_key, keylen); |
513 | } | 598 | } |
514 | 599 | ||
@@ -563,9 +648,9 @@ static struct crypto_alg tnepres_alg = { | |||
563 | .cra_u = { .cipher = { | 648 | .cra_u = { .cipher = { |
564 | .cia_min_keysize = SERPENT_MIN_KEY_SIZE, | 649 | .cia_min_keysize = SERPENT_MIN_KEY_SIZE, |
565 | .cia_max_keysize = SERPENT_MAX_KEY_SIZE, | 650 | .cia_max_keysize = SERPENT_MAX_KEY_SIZE, |
566 | .cia_setkey = tnepres_setkey, | 651 | .cia_setkey = tnepres_setkey, |
567 | .cia_encrypt = tnepres_encrypt, | 652 | .cia_encrypt = tnepres_encrypt, |
568 | .cia_decrypt = tnepres_decrypt } } | 653 | .cia_decrypt = tnepres_decrypt } } |
569 | }; | 654 | }; |
570 | 655 | ||
571 | static int __init serpent_mod_init(void) | 656 | static int __init serpent_mod_init(void) |