1 | n/a | /* |
---|
2 | n/a | Implementation by the Keccak, Keyak and Ketje Teams, namely, Guido Bertoni, |
---|
3 | n/a | Joan Daemen, Michaël Peeters, Gilles Van Assche and Ronny Van Keer, hereby |
---|
4 | n/a | denoted as "the implementer". |
---|
5 | n/a | |
---|
6 | n/a | For more information, feedback or questions, please refer to our websites: |
---|
7 | n/a | http://keccak.noekeon.org/ |
---|
8 | n/a | http://keyak.noekeon.org/ |
---|
9 | n/a | http://ketje.noekeon.org/ |
---|
10 | n/a | |
---|
11 | n/a | To the extent possible under law, the implementer has waived all copyright |
---|
12 | n/a | and related or neighboring rights to the source code in this file. |
---|
13 | n/a | http://creativecommons.org/publicdomain/zero/1.0/ |
---|
14 | n/a | */ |
---|
15 | n/a | |
---|
16 | n/a | #include <string.h> |
---|
17 | n/a | /* #include "brg_endian.h" */ |
---|
18 | n/a | #include "KeccakP-1600-SnP.h" |
---|
19 | n/a | #include "SnP-Relaned.h" |
---|
20 | n/a | |
---|
21 | n/a | typedef unsigned char UINT8; |
---|
22 | n/a | typedef unsigned int UINT32; |
---|
23 | n/a | /* WARNING: on 8-bit and 16-bit platforms, this should be replaced by: */ |
---|
24 | n/a | |
---|
25 | n/a | /*typedef unsigned long UINT32; */ |
---|
26 | n/a | |
---|
27 | n/a | |
---|
28 | n/a | #define ROL32(a, offset) ((((UINT32)a) << (offset)) ^ (((UINT32)a) >> (32-(offset)))) |
---|
29 | n/a | |
---|
30 | n/a | /* Credit to Henry S. Warren, Hacker's Delight, Addison-Wesley, 2002 */ |
---|
31 | n/a | |
---|
32 | n/a | #define prepareToBitInterleaving(low, high, temp, temp0, temp1) \ |
---|
33 | n/a | temp0 = (low); \ |
---|
34 | n/a | temp = (temp0 ^ (temp0 >> 1)) & 0x22222222UL; temp0 = temp0 ^ temp ^ (temp << 1); \ |
---|
35 | n/a | temp = (temp0 ^ (temp0 >> 2)) & 0x0C0C0C0CUL; temp0 = temp0 ^ temp ^ (temp << 2); \ |
---|
36 | n/a | temp = (temp0 ^ (temp0 >> 4)) & 0x00F000F0UL; temp0 = temp0 ^ temp ^ (temp << 4); \ |
---|
37 | n/a | temp = (temp0 ^ (temp0 >> 8)) & 0x0000FF00UL; temp0 = temp0 ^ temp ^ (temp << 8); \ |
---|
38 | n/a | temp1 = (high); \ |
---|
39 | n/a | temp = (temp1 ^ (temp1 >> 1)) & 0x22222222UL; temp1 = temp1 ^ temp ^ (temp << 1); \ |
---|
40 | n/a | temp = (temp1 ^ (temp1 >> 2)) & 0x0C0C0C0CUL; temp1 = temp1 ^ temp ^ (temp << 2); \ |
---|
41 | n/a | temp = (temp1 ^ (temp1 >> 4)) & 0x00F000F0UL; temp1 = temp1 ^ temp ^ (temp << 4); \ |
---|
42 | n/a | temp = (temp1 ^ (temp1 >> 8)) & 0x0000FF00UL; temp1 = temp1 ^ temp ^ (temp << 8); |
---|
43 | n/a | |
---|
44 | n/a | #define toBitInterleavingAndXOR(low, high, even, odd, temp, temp0, temp1) \ |
---|
45 | n/a | prepareToBitInterleaving(low, high, temp, temp0, temp1) \ |
---|
46 | n/a | even ^= (temp0 & 0x0000FFFF) | (temp1 << 16); \ |
---|
47 | n/a | odd ^= (temp0 >> 16) | (temp1 & 0xFFFF0000); |
---|
48 | n/a | |
---|
49 | n/a | #define toBitInterleavingAndAND(low, high, even, odd, temp, temp0, temp1) \ |
---|
50 | n/a | prepareToBitInterleaving(low, high, temp, temp0, temp1) \ |
---|
51 | n/a | even &= (temp0 & 0x0000FFFF) | (temp1 << 16); \ |
---|
52 | n/a | odd &= (temp0 >> 16) | (temp1 & 0xFFFF0000); |
---|
53 | n/a | |
---|
54 | n/a | #define toBitInterleavingAndSet(low, high, even, odd, temp, temp0, temp1) \ |
---|
55 | n/a | prepareToBitInterleaving(low, high, temp, temp0, temp1) \ |
---|
56 | n/a | even = (temp0 & 0x0000FFFF) | (temp1 << 16); \ |
---|
57 | n/a | odd = (temp0 >> 16) | (temp1 & 0xFFFF0000); |
---|
58 | n/a | |
---|
59 | n/a | /* Credit to Henry S. Warren, Hacker's Delight, Addison-Wesley, 2002 */ |
---|
60 | n/a | |
---|
61 | n/a | #define prepareFromBitInterleaving(even, odd, temp, temp0, temp1) \ |
---|
62 | n/a | temp0 = (even); \ |
---|
63 | n/a | temp1 = (odd); \ |
---|
64 | n/a | temp = (temp0 & 0x0000FFFF) | (temp1 << 16); \ |
---|
65 | n/a | temp1 = (temp0 >> 16) | (temp1 & 0xFFFF0000); \ |
---|
66 | n/a | temp0 = temp; \ |
---|
67 | n/a | temp = (temp0 ^ (temp0 >> 8)) & 0x0000FF00UL; temp0 = temp0 ^ temp ^ (temp << 8); \ |
---|
68 | n/a | temp = (temp0 ^ (temp0 >> 4)) & 0x00F000F0UL; temp0 = temp0 ^ temp ^ (temp << 4); \ |
---|
69 | n/a | temp = (temp0 ^ (temp0 >> 2)) & 0x0C0C0C0CUL; temp0 = temp0 ^ temp ^ (temp << 2); \ |
---|
70 | n/a | temp = (temp0 ^ (temp0 >> 1)) & 0x22222222UL; temp0 = temp0 ^ temp ^ (temp << 1); \ |
---|
71 | n/a | temp = (temp1 ^ (temp1 >> 8)) & 0x0000FF00UL; temp1 = temp1 ^ temp ^ (temp << 8); \ |
---|
72 | n/a | temp = (temp1 ^ (temp1 >> 4)) & 0x00F000F0UL; temp1 = temp1 ^ temp ^ (temp << 4); \ |
---|
73 | n/a | temp = (temp1 ^ (temp1 >> 2)) & 0x0C0C0C0CUL; temp1 = temp1 ^ temp ^ (temp << 2); \ |
---|
74 | n/a | temp = (temp1 ^ (temp1 >> 1)) & 0x22222222UL; temp1 = temp1 ^ temp ^ (temp << 1); |
---|
75 | n/a | |
---|
76 | n/a | #define fromBitInterleaving(even, odd, low, high, temp, temp0, temp1) \ |
---|
77 | n/a | prepareFromBitInterleaving(even, odd, temp, temp0, temp1) \ |
---|
78 | n/a | low = temp0; \ |
---|
79 | n/a | high = temp1; |
---|
80 | n/a | |
---|
81 | n/a | #define fromBitInterleavingAndXOR(even, odd, lowIn, highIn, lowOut, highOut, temp, temp0, temp1) \ |
---|
82 | n/a | prepareFromBitInterleaving(even, odd, temp, temp0, temp1) \ |
---|
83 | n/a | lowOut = lowIn ^ temp0; \ |
---|
84 | n/a | highOut = highIn ^ temp1; |
---|
85 | n/a | |
---|
86 | n/a | void KeccakP1600_SetBytesInLaneToZero(void *state, unsigned int lanePosition, unsigned int offset, unsigned int length) |
---|
87 | n/a | { |
---|
88 | n/a | UINT8 laneAsBytes[8]; |
---|
89 | n/a | UINT32 low, high; |
---|
90 | n/a | UINT32 temp, temp0, temp1; |
---|
91 | n/a | UINT32 *stateAsHalfLanes = (UINT32*)state; |
---|
92 | n/a | |
---|
93 | n/a | memset(laneAsBytes, 0xFF, offset); |
---|
94 | n/a | memset(laneAsBytes+offset, 0x00, length); |
---|
95 | n/a | memset(laneAsBytes+offset+length, 0xFF, 8-offset-length); |
---|
96 | n/a | #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) |
---|
97 | n/a | low = *((UINT32*)(laneAsBytes+0)); |
---|
98 | n/a | high = *((UINT32*)(laneAsBytes+4)); |
---|
99 | n/a | #else |
---|
100 | n/a | low = laneAsBytes[0] |
---|
101 | n/a | | ((UINT32)(laneAsBytes[1]) << 8) |
---|
102 | n/a | | ((UINT32)(laneAsBytes[2]) << 16) |
---|
103 | n/a | | ((UINT32)(laneAsBytes[3]) << 24); |
---|
104 | n/a | high = laneAsBytes[4] |
---|
105 | n/a | | ((UINT32)(laneAsBytes[5]) << 8) |
---|
106 | n/a | | ((UINT32)(laneAsBytes[6]) << 16) |
---|
107 | n/a | | ((UINT32)(laneAsBytes[7]) << 24); |
---|
108 | n/a | #endif |
---|
109 | n/a | toBitInterleavingAndAND(low, high, stateAsHalfLanes[lanePosition*2+0], stateAsHalfLanes[lanePosition*2+1], temp, temp0, temp1); |
---|
110 | n/a | } |
---|
111 | n/a | |
---|
112 | n/a | /* ---------------------------------------------------------------- */ |
---|
113 | n/a | |
---|
114 | n/a | void KeccakP1600_Initialize(void *state) |
---|
115 | n/a | { |
---|
116 | n/a | memset(state, 0, 200); |
---|
117 | n/a | } |
---|
118 | n/a | |
---|
119 | n/a | /* ---------------------------------------------------------------- */ |
---|
120 | n/a | |
---|
121 | n/a | void KeccakP1600_AddByte(void *state, unsigned char byte, unsigned int offset) |
---|
122 | n/a | { |
---|
123 | n/a | unsigned int lanePosition = offset/8; |
---|
124 | n/a | unsigned int offsetInLane = offset%8; |
---|
125 | n/a | UINT32 low, high; |
---|
126 | n/a | UINT32 temp, temp0, temp1; |
---|
127 | n/a | UINT32 *stateAsHalfLanes = (UINT32*)state; |
---|
128 | n/a | |
---|
129 | n/a | if (offsetInLane < 4) { |
---|
130 | n/a | low = (UINT32)byte << (offsetInLane*8); |
---|
131 | n/a | high = 0; |
---|
132 | n/a | } |
---|
133 | n/a | else { |
---|
134 | n/a | low = 0; |
---|
135 | n/a | high = (UINT32)byte << ((offsetInLane-4)*8); |
---|
136 | n/a | } |
---|
137 | n/a | toBitInterleavingAndXOR(low, high, stateAsHalfLanes[lanePosition*2+0], stateAsHalfLanes[lanePosition*2+1], temp, temp0, temp1); |
---|
138 | n/a | } |
---|
139 | n/a | |
---|
140 | n/a | /* ---------------------------------------------------------------- */ |
---|
141 | n/a | |
---|
142 | n/a | void KeccakP1600_AddBytesInLane(void *state, unsigned int lanePosition, const unsigned char *data, unsigned int offset, unsigned int length) |
---|
143 | n/a | { |
---|
144 | n/a | UINT8 laneAsBytes[8]; |
---|
145 | n/a | UINT32 low, high; |
---|
146 | n/a | UINT32 temp, temp0, temp1; |
---|
147 | n/a | UINT32 *stateAsHalfLanes = (UINT32*)state; |
---|
148 | n/a | |
---|
149 | n/a | memset(laneAsBytes, 0, 8); |
---|
150 | n/a | memcpy(laneAsBytes+offset, data, length); |
---|
151 | n/a | #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) |
---|
152 | n/a | low = *((UINT32*)(laneAsBytes+0)); |
---|
153 | n/a | high = *((UINT32*)(laneAsBytes+4)); |
---|
154 | n/a | #else |
---|
155 | n/a | low = laneAsBytes[0] |
---|
156 | n/a | | ((UINT32)(laneAsBytes[1]) << 8) |
---|
157 | n/a | | ((UINT32)(laneAsBytes[2]) << 16) |
---|
158 | n/a | | ((UINT32)(laneAsBytes[3]) << 24); |
---|
159 | n/a | high = laneAsBytes[4] |
---|
160 | n/a | | ((UINT32)(laneAsBytes[5]) << 8) |
---|
161 | n/a | | ((UINT32)(laneAsBytes[6]) << 16) |
---|
162 | n/a | | ((UINT32)(laneAsBytes[7]) << 24); |
---|
163 | n/a | #endif |
---|
164 | n/a | toBitInterleavingAndXOR(low, high, stateAsHalfLanes[lanePosition*2+0], stateAsHalfLanes[lanePosition*2+1], temp, temp0, temp1); |
---|
165 | n/a | } |
---|
166 | n/a | |
---|
167 | n/a | /* ---------------------------------------------------------------- */ |
---|
168 | n/a | |
---|
169 | n/a | void KeccakP1600_AddLanes(void *state, const unsigned char *data, unsigned int laneCount) |
---|
170 | n/a | { |
---|
171 | n/a | #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) |
---|
172 | n/a | const UINT32 * pI = (const UINT32 *)data; |
---|
173 | n/a | UINT32 * pS = (UINT32*)state; |
---|
174 | n/a | UINT32 t, x0, x1; |
---|
175 | n/a | int i; |
---|
176 | n/a | for (i = laneCount-1; i >= 0; --i) { |
---|
177 | n/a | #ifdef NO_MISALIGNED_ACCESSES |
---|
178 | n/a | UINT32 low; |
---|
179 | n/a | UINT32 high; |
---|
180 | n/a | memcpy(&low, pI++, 4); |
---|
181 | n/a | memcpy(&high, pI++, 4); |
---|
182 | n/a | toBitInterleavingAndXOR(low, high, *(pS++), *(pS++), t, x0, x1); |
---|
183 | n/a | #else |
---|
184 | n/a | toBitInterleavingAndXOR(*(pI++), *(pI++), *(pS++), *(pS++), t, x0, x1) |
---|
185 | n/a | #endif |
---|
186 | n/a | } |
---|
187 | n/a | #else |
---|
188 | n/a | unsigned int lanePosition; |
---|
189 | n/a | for(lanePosition=0; lanePosition<laneCount; lanePosition++) { |
---|
190 | n/a | UINT8 laneAsBytes[8]; |
---|
191 | n/a | UINT32 low, high, temp, temp0, temp1; |
---|
192 | n/a | UINT32 *stateAsHalfLanes; |
---|
193 | n/a | memcpy(laneAsBytes, data+lanePosition*8, 8); |
---|
194 | n/a | low = laneAsBytes[0] |
---|
195 | n/a | | ((UINT32)(laneAsBytes[1]) << 8) |
---|
196 | n/a | | ((UINT32)(laneAsBytes[2]) << 16) |
---|
197 | n/a | | ((UINT32)(laneAsBytes[3]) << 24); |
---|
198 | n/a | high = laneAsBytes[4] |
---|
199 | n/a | | ((UINT32)(laneAsBytes[5]) << 8) |
---|
200 | n/a | | ((UINT32)(laneAsBytes[6]) << 16) |
---|
201 | n/a | | ((UINT32)(laneAsBytes[7]) << 24); |
---|
202 | n/a | stateAsHalfLanes = (UINT32*)state; |
---|
203 | n/a | toBitInterleavingAndXOR(low, high, stateAsHalfLanes[lanePosition*2+0], stateAsHalfLanes[lanePosition*2+1], temp, temp0, temp1); |
---|
204 | n/a | } |
---|
205 | n/a | #endif |
---|
206 | n/a | } |
---|
207 | n/a | |
---|
208 | n/a | /* ---------------------------------------------------------------- */ |
---|
209 | n/a | |
---|
210 | n/a | void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length) |
---|
211 | n/a | { |
---|
212 | n/a | SnP_AddBytes(state, data, offset, length, KeccakP1600_AddLanes, KeccakP1600_AddBytesInLane, 8); |
---|
213 | n/a | } |
---|
214 | n/a | |
---|
215 | n/a | /* ---------------------------------------------------------------- */ |
---|
216 | n/a | |
---|
217 | n/a | void KeccakP1600_OverwriteBytesInLane(void *state, unsigned int lanePosition, const unsigned char *data, unsigned int offset, unsigned int length) |
---|
218 | n/a | { |
---|
219 | n/a | KeccakP1600_SetBytesInLaneToZero(state, lanePosition, offset, length); |
---|
220 | n/a | KeccakP1600_AddBytesInLane(state, lanePosition, data, offset, length); |
---|
221 | n/a | } |
---|
222 | n/a | |
---|
223 | n/a | /* ---------------------------------------------------------------- */ |
---|
224 | n/a | |
---|
225 | n/a | void KeccakP1600_OverwriteLanes(void *state, const unsigned char *data, unsigned int laneCount) |
---|
226 | n/a | { |
---|
227 | n/a | #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) |
---|
228 | n/a | const UINT32 * pI = (const UINT32 *)data; |
---|
229 | n/a | UINT32 * pS = (UINT32 *)state; |
---|
230 | n/a | UINT32 t, x0, x1; |
---|
231 | n/a | int i; |
---|
232 | n/a | for (i = laneCount-1; i >= 0; --i) { |
---|
233 | n/a | #ifdef NO_MISALIGNED_ACCESSES |
---|
234 | n/a | UINT32 low; |
---|
235 | n/a | UINT32 high; |
---|
236 | n/a | memcpy(&low, pI++, 4); |
---|
237 | n/a | memcpy(&high, pI++, 4); |
---|
238 | n/a | toBitInterleavingAndSet(low, high, *(pS++), *(pS++), t, x0, x1); |
---|
239 | n/a | #else |
---|
240 | n/a | toBitInterleavingAndSet(*(pI++), *(pI++), *(pS++), *(pS++), t, x0, x1) |
---|
241 | n/a | #endif |
---|
242 | n/a | } |
---|
243 | n/a | #else |
---|
244 | n/a | unsigned int lanePosition; |
---|
245 | n/a | for(lanePosition=0; lanePosition<laneCount; lanePosition++) { |
---|
246 | n/a | UINT8 laneAsBytes[8]; |
---|
247 | n/a | UINT32 low, high, temp, temp0, temp1; |
---|
248 | n/a | UINT32 *stateAsHalfLanes; |
---|
249 | n/a | memcpy(laneAsBytes, data+lanePosition*8, 8); |
---|
250 | n/a | low = laneAsBytes[0] |
---|
251 | n/a | | ((UINT32)(laneAsBytes[1]) << 8) |
---|
252 | n/a | | ((UINT32)(laneAsBytes[2]) << 16) |
---|
253 | n/a | | ((UINT32)(laneAsBytes[3]) << 24); |
---|
254 | n/a | high = laneAsBytes[4] |
---|
255 | n/a | | ((UINT32)(laneAsBytes[5]) << 8) |
---|
256 | n/a | | ((UINT32)(laneAsBytes[6]) << 16) |
---|
257 | n/a | | ((UINT32)(laneAsBytes[7]) << 24); |
---|
258 | n/a | stateAsHalfLanes = (UINT32*)state; |
---|
259 | n/a | toBitInterleavingAndSet(low, high, stateAsHalfLanes[lanePosition*2+0], stateAsHalfLanes[lanePosition*2+1], temp, temp0, temp1); |
---|
260 | n/a | } |
---|
261 | n/a | #endif |
---|
262 | n/a | } |
---|
263 | n/a | |
---|
264 | n/a | /* ---------------------------------------------------------------- */ |
---|
265 | n/a | |
---|
266 | n/a | void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length) |
---|
267 | n/a | { |
---|
268 | n/a | SnP_OverwriteBytes(state, data, offset, length, KeccakP1600_OverwriteLanes, KeccakP1600_OverwriteBytesInLane, 8); |
---|
269 | n/a | } |
---|
270 | n/a | |
---|
271 | n/a | /* ---------------------------------------------------------------- */ |
---|
272 | n/a | |
---|
273 | n/a | void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount) |
---|
274 | n/a | { |
---|
275 | n/a | UINT32 *stateAsHalfLanes = (UINT32*)state; |
---|
276 | n/a | unsigned int i; |
---|
277 | n/a | |
---|
278 | n/a | for(i=0; i<byteCount/8; i++) { |
---|
279 | n/a | stateAsHalfLanes[i*2+0] = 0; |
---|
280 | n/a | stateAsHalfLanes[i*2+1] = 0; |
---|
281 | n/a | } |
---|
282 | n/a | if (byteCount%8 != 0) |
---|
283 | n/a | KeccakP1600_SetBytesInLaneToZero(state, byteCount/8, 0, byteCount%8); |
---|
284 | n/a | } |
---|
285 | n/a | |
---|
286 | n/a | /* ---------------------------------------------------------------- */ |
---|
287 | n/a | |
---|
288 | n/a | void KeccakP1600_ExtractBytesInLane(const void *state, unsigned int lanePosition, unsigned char *data, unsigned int offset, unsigned int length) |
---|
289 | n/a | { |
---|
290 | n/a | UINT32 *stateAsHalfLanes = (UINT32*)state; |
---|
291 | n/a | UINT32 low, high, temp, temp0, temp1; |
---|
292 | n/a | UINT8 laneAsBytes[8]; |
---|
293 | n/a | |
---|
294 | n/a | fromBitInterleaving(stateAsHalfLanes[lanePosition*2], stateAsHalfLanes[lanePosition*2+1], low, high, temp, temp0, temp1); |
---|
295 | n/a | #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) |
---|
296 | n/a | *((UINT32*)(laneAsBytes+0)) = low; |
---|
297 | n/a | *((UINT32*)(laneAsBytes+4)) = high; |
---|
298 | n/a | #else |
---|
299 | n/a | laneAsBytes[0] = low & 0xFF; |
---|
300 | n/a | laneAsBytes[1] = (low >> 8) & 0xFF; |
---|
301 | n/a | laneAsBytes[2] = (low >> 16) & 0xFF; |
---|
302 | n/a | laneAsBytes[3] = (low >> 24) & 0xFF; |
---|
303 | n/a | laneAsBytes[4] = high & 0xFF; |
---|
304 | n/a | laneAsBytes[5] = (high >> 8) & 0xFF; |
---|
305 | n/a | laneAsBytes[6] = (high >> 16) & 0xFF; |
---|
306 | n/a | laneAsBytes[7] = (high >> 24) & 0xFF; |
---|
307 | n/a | #endif |
---|
308 | n/a | memcpy(data, laneAsBytes+offset, length); |
---|
309 | n/a | } |
---|
310 | n/a | |
---|
311 | n/a | /* ---------------------------------------------------------------- */ |
---|
312 | n/a | |
---|
313 | n/a | void KeccakP1600_ExtractLanes(const void *state, unsigned char *data, unsigned int laneCount) |
---|
314 | n/a | { |
---|
315 | n/a | #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) |
---|
316 | n/a | UINT32 * pI = (UINT32 *)data; |
---|
317 | n/a | const UINT32 * pS = ( const UINT32 *)state; |
---|
318 | n/a | UINT32 t, x0, x1; |
---|
319 | n/a | int i; |
---|
320 | n/a | for (i = laneCount-1; i >= 0; --i) { |
---|
321 | n/a | #ifdef NO_MISALIGNED_ACCESSES |
---|
322 | n/a | UINT32 low; |
---|
323 | n/a | UINT32 high; |
---|
324 | n/a | fromBitInterleaving(*(pS++), *(pS++), low, high, t, x0, x1); |
---|
325 | n/a | memcpy(pI++, &low, 4); |
---|
326 | n/a | memcpy(pI++, &high, 4); |
---|
327 | n/a | #else |
---|
328 | n/a | fromBitInterleaving(*(pS++), *(pS++), *(pI++), *(pI++), t, x0, x1) |
---|
329 | n/a | #endif |
---|
330 | n/a | } |
---|
331 | n/a | #else |
---|
332 | n/a | unsigned int lanePosition; |
---|
333 | n/a | for(lanePosition=0; lanePosition<laneCount; lanePosition++) { |
---|
334 | n/a | UINT32 *stateAsHalfLanes = (UINT32*)state; |
---|
335 | n/a | UINT32 low, high, temp, temp0, temp1; |
---|
336 | n/a | UINT8 laneAsBytes[8]; |
---|
337 | n/a | fromBitInterleaving(stateAsHalfLanes[lanePosition*2], stateAsHalfLanes[lanePosition*2+1], low, high, temp, temp0, temp1); |
---|
338 | n/a | laneAsBytes[0] = low & 0xFF; |
---|
339 | n/a | laneAsBytes[1] = (low >> 8) & 0xFF; |
---|
340 | n/a | laneAsBytes[2] = (low >> 16) & 0xFF; |
---|
341 | n/a | laneAsBytes[3] = (low >> 24) & 0xFF; |
---|
342 | n/a | laneAsBytes[4] = high & 0xFF; |
---|
343 | n/a | laneAsBytes[5] = (high >> 8) & 0xFF; |
---|
344 | n/a | laneAsBytes[6] = (high >> 16) & 0xFF; |
---|
345 | n/a | laneAsBytes[7] = (high >> 24) & 0xFF; |
---|
346 | n/a | memcpy(data+lanePosition*8, laneAsBytes, 8); |
---|
347 | n/a | } |
---|
348 | n/a | #endif |
---|
349 | n/a | } |
---|
350 | n/a | |
---|
351 | n/a | /* ---------------------------------------------------------------- */ |
---|
352 | n/a | |
---|
353 | n/a | void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length) |
---|
354 | n/a | { |
---|
355 | n/a | SnP_ExtractBytes(state, data, offset, length, KeccakP1600_ExtractLanes, KeccakP1600_ExtractBytesInLane, 8); |
---|
356 | n/a | } |
---|
357 | n/a | |
---|
358 | n/a | /* ---------------------------------------------------------------- */ |
---|
359 | n/a | |
---|
360 | n/a | void KeccakP1600_ExtractAndAddBytesInLane(const void *state, unsigned int lanePosition, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length) |
---|
361 | n/a | { |
---|
362 | n/a | UINT32 *stateAsHalfLanes = (UINT32*)state; |
---|
363 | n/a | UINT32 low, high, temp, temp0, temp1; |
---|
364 | n/a | UINT8 laneAsBytes[8]; |
---|
365 | n/a | unsigned int i; |
---|
366 | n/a | |
---|
367 | n/a | fromBitInterleaving(stateAsHalfLanes[lanePosition*2], stateAsHalfLanes[lanePosition*2+1], low, high, temp, temp0, temp1); |
---|
368 | n/a | #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) |
---|
369 | n/a | *((UINT32*)(laneAsBytes+0)) = low; |
---|
370 | n/a | *((UINT32*)(laneAsBytes+4)) = high; |
---|
371 | n/a | #else |
---|
372 | n/a | laneAsBytes[0] = low & 0xFF; |
---|
373 | n/a | laneAsBytes[1] = (low >> 8) & 0xFF; |
---|
374 | n/a | laneAsBytes[2] = (low >> 16) & 0xFF; |
---|
375 | n/a | laneAsBytes[3] = (low >> 24) & 0xFF; |
---|
376 | n/a | laneAsBytes[4] = high & 0xFF; |
---|
377 | n/a | laneAsBytes[5] = (high >> 8) & 0xFF; |
---|
378 | n/a | laneAsBytes[6] = (high >> 16) & 0xFF; |
---|
379 | n/a | laneAsBytes[7] = (high >> 24) & 0xFF; |
---|
380 | n/a | #endif |
---|
381 | n/a | for(i=0; i<length; i++) |
---|
382 | n/a | output[i] = input[i] ^ laneAsBytes[offset+i]; |
---|
383 | n/a | } |
---|
384 | n/a | |
---|
385 | n/a | /* ---------------------------------------------------------------- */ |
---|
386 | n/a | |
---|
387 | n/a | void KeccakP1600_ExtractAndAddLanes(const void *state, const unsigned char *input, unsigned char *output, unsigned int laneCount) |
---|
388 | n/a | { |
---|
389 | n/a | #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN) |
---|
390 | n/a | const UINT32 * pI = (const UINT32 *)input; |
---|
391 | n/a | UINT32 * pO = (UINT32 *)output; |
---|
392 | n/a | const UINT32 * pS = (const UINT32 *)state; |
---|
393 | n/a | UINT32 t, x0, x1; |
---|
394 | n/a | int i; |
---|
395 | n/a | for (i = laneCount-1; i >= 0; --i) { |
---|
396 | n/a | #ifdef NO_MISALIGNED_ACCESSES |
---|
397 | n/a | UINT32 low; |
---|
398 | n/a | UINT32 high; |
---|
399 | n/a | fromBitInterleaving(*(pS++), *(pS++), low, high, t, x0, x1); |
---|
400 | n/a | *(pO++) = *(pI++) ^ low; |
---|
401 | n/a | *(pO++) = *(pI++) ^ high; |
---|
402 | n/a | #else |
---|
403 | n/a | fromBitInterleavingAndXOR(*(pS++), *(pS++), *(pI++), *(pI++), *(pO++), *(pO++), t, x0, x1) |
---|
404 | n/a | #endif |
---|
405 | n/a | } |
---|
406 | n/a | #else |
---|
407 | n/a | unsigned int lanePosition; |
---|
408 | n/a | for(lanePosition=0; lanePosition<laneCount; lanePosition++) { |
---|
409 | n/a | UINT32 *stateAsHalfLanes = (UINT32*)state; |
---|
410 | n/a | UINT32 low, high, temp, temp0, temp1; |
---|
411 | n/a | UINT8 laneAsBytes[8]; |
---|
412 | n/a | fromBitInterleaving(stateAsHalfLanes[lanePosition*2], stateAsHalfLanes[lanePosition*2+1], low, high, temp, temp0, temp1); |
---|
413 | n/a | laneAsBytes[0] = low & 0xFF; |
---|
414 | n/a | laneAsBytes[1] = (low >> 8) & 0xFF; |
---|
415 | n/a | laneAsBytes[2] = (low >> 16) & 0xFF; |
---|
416 | n/a | laneAsBytes[3] = (low >> 24) & 0xFF; |
---|
417 | n/a | laneAsBytes[4] = high & 0xFF; |
---|
418 | n/a | laneAsBytes[5] = (high >> 8) & 0xFF; |
---|
419 | n/a | laneAsBytes[6] = (high >> 16) & 0xFF; |
---|
420 | n/a | laneAsBytes[7] = (high >> 24) & 0xFF; |
---|
421 | n/a | ((UINT32*)(output+lanePosition*8))[0] = ((UINT32*)(input+lanePosition*8))[0] ^ (*(const UINT32*)(laneAsBytes+0)); |
---|
422 | n/a | ((UINT32*)(output+lanePosition*8))[1] = ((UINT32*)(input+lanePosition*8))[0] ^ (*(const UINT32*)(laneAsBytes+4)); |
---|
423 | n/a | } |
---|
424 | n/a | #endif |
---|
425 | n/a | } |
---|
426 | n/a | /* ---------------------------------------------------------------- */ |
---|
427 | n/a | |
---|
428 | n/a | void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length) |
---|
429 | n/a | { |
---|
430 | n/a | SnP_ExtractAndAddBytes(state, input, output, offset, length, KeccakP1600_ExtractAndAddLanes, KeccakP1600_ExtractAndAddBytesInLane, 8); |
---|
431 | n/a | } |
---|
432 | n/a | |
---|
433 | n/a | /* ---------------------------------------------------------------- */ |
---|
434 | n/a | |
---|
435 | n/a | static const UINT32 KeccakF1600RoundConstants_int2[2*24+1] = |
---|
436 | n/a | { |
---|
437 | n/a | 0x00000001UL, 0x00000000UL, |
---|
438 | n/a | 0x00000000UL, 0x00000089UL, |
---|
439 | n/a | 0x00000000UL, 0x8000008bUL, |
---|
440 | n/a | 0x00000000UL, 0x80008080UL, |
---|
441 | n/a | 0x00000001UL, 0x0000008bUL, |
---|
442 | n/a | 0x00000001UL, 0x00008000UL, |
---|
443 | n/a | 0x00000001UL, 0x80008088UL, |
---|
444 | n/a | 0x00000001UL, 0x80000082UL, |
---|
445 | n/a | 0x00000000UL, 0x0000000bUL, |
---|
446 | n/a | 0x00000000UL, 0x0000000aUL, |
---|
447 | n/a | 0x00000001UL, 0x00008082UL, |
---|
448 | n/a | 0x00000000UL, 0x00008003UL, |
---|
449 | n/a | 0x00000001UL, 0x0000808bUL, |
---|
450 | n/a | 0x00000001UL, 0x8000000bUL, |
---|
451 | n/a | 0x00000001UL, 0x8000008aUL, |
---|
452 | n/a | 0x00000001UL, 0x80000081UL, |
---|
453 | n/a | 0x00000000UL, 0x80000081UL, |
---|
454 | n/a | 0x00000000UL, 0x80000008UL, |
---|
455 | n/a | 0x00000000UL, 0x00000083UL, |
---|
456 | n/a | 0x00000000UL, 0x80008003UL, |
---|
457 | n/a | 0x00000001UL, 0x80008088UL, |
---|
458 | n/a | 0x00000000UL, 0x80000088UL, |
---|
459 | n/a | 0x00000001UL, 0x00008000UL, |
---|
460 | n/a | 0x00000000UL, 0x80008082UL, |
---|
461 | n/a | 0x000000FFUL |
---|
462 | n/a | }; |
---|
463 | n/a | |
---|
464 | n/a | #define KeccakAtoD_round0() \ |
---|
465 | n/a | Cx = Abu0^Agu0^Aku0^Amu0^Asu0; \ |
---|
466 | n/a | Du1 = Abe1^Age1^Ake1^Ame1^Ase1; \ |
---|
467 | n/a | Da0 = Cx^ROL32(Du1, 1); \ |
---|
468 | n/a | Cz = Abu1^Agu1^Aku1^Amu1^Asu1; \ |
---|
469 | n/a | Du0 = Abe0^Age0^Ake0^Ame0^Ase0; \ |
---|
470 | n/a | Da1 = Cz^Du0; \ |
---|
471 | n/a | \ |
---|
472 | n/a | Cw = Abi0^Agi0^Aki0^Ami0^Asi0; \ |
---|
473 | n/a | Do0 = Cw^ROL32(Cz, 1); \ |
---|
474 | n/a | Cy = Abi1^Agi1^Aki1^Ami1^Asi1; \ |
---|
475 | n/a | Do1 = Cy^Cx; \ |
---|
476 | n/a | \ |
---|
477 | n/a | Cx = Aba0^Aga0^Aka0^Ama0^Asa0; \ |
---|
478 | n/a | De0 = Cx^ROL32(Cy, 1); \ |
---|
479 | n/a | Cz = Aba1^Aga1^Aka1^Ama1^Asa1; \ |
---|
480 | n/a | De1 = Cz^Cw; \ |
---|
481 | n/a | \ |
---|
482 | n/a | Cy = Abo1^Ago1^Ako1^Amo1^Aso1; \ |
---|
483 | n/a | Di0 = Du0^ROL32(Cy, 1); \ |
---|
484 | n/a | Cw = Abo0^Ago0^Ako0^Amo0^Aso0; \ |
---|
485 | n/a | Di1 = Du1^Cw; \ |
---|
486 | n/a | \ |
---|
487 | n/a | Du0 = Cw^ROL32(Cz, 1); \ |
---|
488 | n/a | Du1 = Cy^Cx; \ |
---|
489 | n/a | |
---|
490 | n/a | #define KeccakAtoD_round1() \ |
---|
491 | n/a | Cx = Asu0^Agu0^Amu0^Abu1^Aku1; \ |
---|
492 | n/a | Du1 = Age1^Ame0^Abe0^Ake1^Ase1; \ |
---|
493 | n/a | Da0 = Cx^ROL32(Du1, 1); \ |
---|
494 | n/a | Cz = Asu1^Agu1^Amu1^Abu0^Aku0; \ |
---|
495 | n/a | Du0 = Age0^Ame1^Abe1^Ake0^Ase0; \ |
---|
496 | n/a | Da1 = Cz^Du0; \ |
---|
497 | n/a | \ |
---|
498 | n/a | Cw = Aki1^Asi1^Agi0^Ami1^Abi0; \ |
---|
499 | n/a | Do0 = Cw^ROL32(Cz, 1); \ |
---|
500 | n/a | Cy = Aki0^Asi0^Agi1^Ami0^Abi1; \ |
---|
501 | n/a | Do1 = Cy^Cx; \ |
---|
502 | n/a | \ |
---|
503 | n/a | Cx = Aba0^Aka1^Asa0^Aga0^Ama1; \ |
---|
504 | n/a | De0 = Cx^ROL32(Cy, 1); \ |
---|
505 | n/a | Cz = Aba1^Aka0^Asa1^Aga1^Ama0; \ |
---|
506 | n/a | De1 = Cz^Cw; \ |
---|
507 | n/a | \ |
---|
508 | n/a | Cy = Amo0^Abo1^Ako0^Aso1^Ago0; \ |
---|
509 | n/a | Di0 = Du0^ROL32(Cy, 1); \ |
---|
510 | n/a | Cw = Amo1^Abo0^Ako1^Aso0^Ago1; \ |
---|
511 | n/a | Di1 = Du1^Cw; \ |
---|
512 | n/a | \ |
---|
513 | n/a | Du0 = Cw^ROL32(Cz, 1); \ |
---|
514 | n/a | Du1 = Cy^Cx; \ |
---|
515 | n/a | |
---|
516 | n/a | #define KeccakAtoD_round2() \ |
---|
517 | n/a | Cx = Aku1^Agu0^Abu1^Asu1^Amu1; \ |
---|
518 | n/a | Du1 = Ame0^Ake0^Age0^Abe0^Ase1; \ |
---|
519 | n/a | Da0 = Cx^ROL32(Du1, 1); \ |
---|
520 | n/a | Cz = Aku0^Agu1^Abu0^Asu0^Amu0; \ |
---|
521 | n/a | Du0 = Ame1^Ake1^Age1^Abe1^Ase0; \ |
---|
522 | n/a | Da1 = Cz^Du0; \ |
---|
523 | n/a | \ |
---|
524 | n/a | Cw = Agi1^Abi1^Asi1^Ami0^Aki1; \ |
---|
525 | n/a | Do0 = Cw^ROL32(Cz, 1); \ |
---|
526 | n/a | Cy = Agi0^Abi0^Asi0^Ami1^Aki0; \ |
---|
527 | n/a | Do1 = Cy^Cx; \ |
---|
528 | n/a | \ |
---|
529 | n/a | Cx = Aba0^Asa1^Ama1^Aka1^Aga1; \ |
---|
530 | n/a | De0 = Cx^ROL32(Cy, 1); \ |
---|
531 | n/a | Cz = Aba1^Asa0^Ama0^Aka0^Aga0; \ |
---|
532 | n/a | De1 = Cz^Cw; \ |
---|
533 | n/a | \ |
---|
534 | n/a | Cy = Aso0^Amo0^Ako1^Ago0^Abo0; \ |
---|
535 | n/a | Di0 = Du0^ROL32(Cy, 1); \ |
---|
536 | n/a | Cw = Aso1^Amo1^Ako0^Ago1^Abo1; \ |
---|
537 | n/a | Di1 = Du1^Cw; \ |
---|
538 | n/a | \ |
---|
539 | n/a | Du0 = Cw^ROL32(Cz, 1); \ |
---|
540 | n/a | Du1 = Cy^Cx; \ |
---|
541 | n/a | |
---|
542 | n/a | #define KeccakAtoD_round3() \ |
---|
543 | n/a | Cx = Amu1^Agu0^Asu1^Aku0^Abu0; \ |
---|
544 | n/a | Du1 = Ake0^Abe1^Ame1^Age0^Ase1; \ |
---|
545 | n/a | Da0 = Cx^ROL32(Du1, 1); \ |
---|
546 | n/a | Cz = Amu0^Agu1^Asu0^Aku1^Abu1; \ |
---|
547 | n/a | Du0 = Ake1^Abe0^Ame0^Age1^Ase0; \ |
---|
548 | n/a | Da1 = Cz^Du0; \ |
---|
549 | n/a | \ |
---|
550 | n/a | Cw = Asi0^Aki0^Abi1^Ami1^Agi1; \ |
---|
551 | n/a | Do0 = Cw^ROL32(Cz, 1); \ |
---|
552 | n/a | Cy = Asi1^Aki1^Abi0^Ami0^Agi0; \ |
---|
553 | n/a | Do1 = Cy^Cx; \ |
---|
554 | n/a | \ |
---|
555 | n/a | Cx = Aba0^Ama0^Aga1^Asa1^Aka0; \ |
---|
556 | n/a | De0 = Cx^ROL32(Cy, 1); \ |
---|
557 | n/a | Cz = Aba1^Ama1^Aga0^Asa0^Aka1; \ |
---|
558 | n/a | De1 = Cz^Cw; \ |
---|
559 | n/a | \ |
---|
560 | n/a | Cy = Ago1^Aso0^Ako0^Abo0^Amo1; \ |
---|
561 | n/a | Di0 = Du0^ROL32(Cy, 1); \ |
---|
562 | n/a | Cw = Ago0^Aso1^Ako1^Abo1^Amo0; \ |
---|
563 | n/a | Di1 = Du1^Cw; \ |
---|
564 | n/a | \ |
---|
565 | n/a | Du0 = Cw^ROL32(Cz, 1); \ |
---|
566 | n/a | Du1 = Cy^Cx; \ |
---|
567 | n/a | |
---|
568 | n/a | void KeccakP1600_Permute_Nrounds(void *state, unsigned int nRounds) |
---|
569 | n/a | { |
---|
570 | n/a | { |
---|
571 | n/a | UINT32 Da0, De0, Di0, Do0, Du0; |
---|
572 | n/a | UINT32 Da1, De1, Di1, Do1, Du1; |
---|
573 | n/a | UINT32 Ca0, Ce0, Ci0, Co0, Cu0; |
---|
574 | n/a | UINT32 Cx, Cy, Cz, Cw; |
---|
575 | n/a | #define Ba Ca0 |
---|
576 | n/a | #define Be Ce0 |
---|
577 | n/a | #define Bi Ci0 |
---|
578 | n/a | #define Bo Co0 |
---|
579 | n/a | #define Bu Cu0 |
---|
580 | n/a | const UINT32 *pRoundConstants = KeccakF1600RoundConstants_int2+(24-nRounds)*2; |
---|
581 | n/a | UINT32 *stateAsHalfLanes = (UINT32*)state; |
---|
582 | n/a | #define Aba0 stateAsHalfLanes[ 0] |
---|
583 | n/a | #define Aba1 stateAsHalfLanes[ 1] |
---|
584 | n/a | #define Abe0 stateAsHalfLanes[ 2] |
---|
585 | n/a | #define Abe1 stateAsHalfLanes[ 3] |
---|
586 | n/a | #define Abi0 stateAsHalfLanes[ 4] |
---|
587 | n/a | #define Abi1 stateAsHalfLanes[ 5] |
---|
588 | n/a | #define Abo0 stateAsHalfLanes[ 6] |
---|
589 | n/a | #define Abo1 stateAsHalfLanes[ 7] |
---|
590 | n/a | #define Abu0 stateAsHalfLanes[ 8] |
---|
591 | n/a | #define Abu1 stateAsHalfLanes[ 9] |
---|
592 | n/a | #define Aga0 stateAsHalfLanes[10] |
---|
593 | n/a | #define Aga1 stateAsHalfLanes[11] |
---|
594 | n/a | #define Age0 stateAsHalfLanes[12] |
---|
595 | n/a | #define Age1 stateAsHalfLanes[13] |
---|
596 | n/a | #define Agi0 stateAsHalfLanes[14] |
---|
597 | n/a | #define Agi1 stateAsHalfLanes[15] |
---|
598 | n/a | #define Ago0 stateAsHalfLanes[16] |
---|
599 | n/a | #define Ago1 stateAsHalfLanes[17] |
---|
600 | n/a | #define Agu0 stateAsHalfLanes[18] |
---|
601 | n/a | #define Agu1 stateAsHalfLanes[19] |
---|
602 | n/a | #define Aka0 stateAsHalfLanes[20] |
---|
603 | n/a | #define Aka1 stateAsHalfLanes[21] |
---|
604 | n/a | #define Ake0 stateAsHalfLanes[22] |
---|
605 | n/a | #define Ake1 stateAsHalfLanes[23] |
---|
606 | n/a | #define Aki0 stateAsHalfLanes[24] |
---|
607 | n/a | #define Aki1 stateAsHalfLanes[25] |
---|
608 | n/a | #define Ako0 stateAsHalfLanes[26] |
---|
609 | n/a | #define Ako1 stateAsHalfLanes[27] |
---|
610 | n/a | #define Aku0 stateAsHalfLanes[28] |
---|
611 | n/a | #define Aku1 stateAsHalfLanes[29] |
---|
612 | n/a | #define Ama0 stateAsHalfLanes[30] |
---|
613 | n/a | #define Ama1 stateAsHalfLanes[31] |
---|
614 | n/a | #define Ame0 stateAsHalfLanes[32] |
---|
615 | n/a | #define Ame1 stateAsHalfLanes[33] |
---|
616 | n/a | #define Ami0 stateAsHalfLanes[34] |
---|
617 | n/a | #define Ami1 stateAsHalfLanes[35] |
---|
618 | n/a | #define Amo0 stateAsHalfLanes[36] |
---|
619 | n/a | #define Amo1 stateAsHalfLanes[37] |
---|
620 | n/a | #define Amu0 stateAsHalfLanes[38] |
---|
621 | n/a | #define Amu1 stateAsHalfLanes[39] |
---|
622 | n/a | #define Asa0 stateAsHalfLanes[40] |
---|
623 | n/a | #define Asa1 stateAsHalfLanes[41] |
---|
624 | n/a | #define Ase0 stateAsHalfLanes[42] |
---|
625 | n/a | #define Ase1 stateAsHalfLanes[43] |
---|
626 | n/a | #define Asi0 stateAsHalfLanes[44] |
---|
627 | n/a | #define Asi1 stateAsHalfLanes[45] |
---|
628 | n/a | #define Aso0 stateAsHalfLanes[46] |
---|
629 | n/a | #define Aso1 stateAsHalfLanes[47] |
---|
630 | n/a | #define Asu0 stateAsHalfLanes[48] |
---|
631 | n/a | #define Asu1 stateAsHalfLanes[49] |
---|
632 | n/a | |
---|
633 | n/a | do |
---|
634 | n/a | { |
---|
635 | n/a | /* --- Code for 4 rounds */ |
---|
636 | n/a | |
---|
637 | n/a | /* --- using factor 2 interleaving, 64-bit lanes mapped to 32-bit words */ |
---|
638 | n/a | |
---|
639 | n/a | KeccakAtoD_round0(); |
---|
640 | n/a | |
---|
641 | n/a | Ba = (Aba0^Da0); |
---|
642 | n/a | Be = ROL32((Age0^De0), 22); |
---|
643 | n/a | Bi = ROL32((Aki1^Di1), 22); |
---|
644 | n/a | Bo = ROL32((Amo1^Do1), 11); |
---|
645 | n/a | Bu = ROL32((Asu0^Du0), 7); |
---|
646 | n/a | Aba0 = Ba ^((~Be)& Bi ); |
---|
647 | n/a | Aba0 ^= *(pRoundConstants++); |
---|
648 | n/a | Age0 = Be ^((~Bi)& Bo ); |
---|
649 | n/a | Aki1 = Bi ^((~Bo)& Bu ); |
---|
650 | n/a | Amo1 = Bo ^((~Bu)& Ba ); |
---|
651 | n/a | Asu0 = Bu ^((~Ba)& Be ); |
---|
652 | n/a | |
---|
653 | n/a | Ba = (Aba1^Da1); |
---|
654 | n/a | Be = ROL32((Age1^De1), 22); |
---|
655 | n/a | Bi = ROL32((Aki0^Di0), 21); |
---|
656 | n/a | Bo = ROL32((Amo0^Do0), 10); |
---|
657 | n/a | Bu = ROL32((Asu1^Du1), 7); |
---|
658 | n/a | Aba1 = Ba ^((~Be)& Bi ); |
---|
659 | n/a | Aba1 ^= *(pRoundConstants++); |
---|
660 | n/a | Age1 = Be ^((~Bi)& Bo ); |
---|
661 | n/a | Aki0 = Bi ^((~Bo)& Bu ); |
---|
662 | n/a | Amo0 = Bo ^((~Bu)& Ba ); |
---|
663 | n/a | Asu1 = Bu ^((~Ba)& Be ); |
---|
664 | n/a | |
---|
665 | n/a | Bi = ROL32((Aka1^Da1), 2); |
---|
666 | n/a | Bo = ROL32((Ame1^De1), 23); |
---|
667 | n/a | Bu = ROL32((Asi1^Di1), 31); |
---|
668 | n/a | Ba = ROL32((Abo0^Do0), 14); |
---|
669 | n/a | Be = ROL32((Agu0^Du0), 10); |
---|
670 | n/a | Aka1 = Ba ^((~Be)& Bi ); |
---|
671 | n/a | Ame1 = Be ^((~Bi)& Bo ); |
---|
672 | n/a | Asi1 = Bi ^((~Bo)& Bu ); |
---|
673 | n/a | Abo0 = Bo ^((~Bu)& Ba ); |
---|
674 | n/a | Agu0 = Bu ^((~Ba)& Be ); |
---|
675 | n/a | |
---|
676 | n/a | Bi = ROL32((Aka0^Da0), 1); |
---|
677 | n/a | Bo = ROL32((Ame0^De0), 22); |
---|
678 | n/a | Bu = ROL32((Asi0^Di0), 30); |
---|
679 | n/a | Ba = ROL32((Abo1^Do1), 14); |
---|
680 | n/a | Be = ROL32((Agu1^Du1), 10); |
---|
681 | n/a | Aka0 = Ba ^((~Be)& Bi ); |
---|
682 | n/a | Ame0 = Be ^((~Bi)& Bo ); |
---|
683 | n/a | Asi0 = Bi ^((~Bo)& Bu ); |
---|
684 | n/a | Abo1 = Bo ^((~Bu)& Ba ); |
---|
685 | n/a | Agu1 = Bu ^((~Ba)& Be ); |
---|
686 | n/a | |
---|
687 | n/a | Bu = ROL32((Asa0^Da0), 9); |
---|
688 | n/a | Ba = ROL32((Abe1^De1), 1); |
---|
689 | n/a | Be = ROL32((Agi0^Di0), 3); |
---|
690 | n/a | Bi = ROL32((Ako1^Do1), 13); |
---|
691 | n/a | Bo = ROL32((Amu0^Du0), 4); |
---|
692 | n/a | Asa0 = Ba ^((~Be)& Bi ); |
---|
693 | n/a | Abe1 = Be ^((~Bi)& Bo ); |
---|
694 | n/a | Agi0 = Bi ^((~Bo)& Bu ); |
---|
695 | n/a | Ako1 = Bo ^((~Bu)& Ba ); |
---|
696 | n/a | Amu0 = Bu ^((~Ba)& Be ); |
---|
697 | n/a | |
---|
698 | n/a | Bu = ROL32((Asa1^Da1), 9); |
---|
699 | n/a | Ba = (Abe0^De0); |
---|
700 | n/a | Be = ROL32((Agi1^Di1), 3); |
---|
701 | n/a | Bi = ROL32((Ako0^Do0), 12); |
---|
702 | n/a | Bo = ROL32((Amu1^Du1), 4); |
---|
703 | n/a | Asa1 = Ba ^((~Be)& Bi ); |
---|
704 | n/a | Abe0 = Be ^((~Bi)& Bo ); |
---|
705 | n/a | Agi1 = Bi ^((~Bo)& Bu ); |
---|
706 | n/a | Ako0 = Bo ^((~Bu)& Ba ); |
---|
707 | n/a | Amu1 = Bu ^((~Ba)& Be ); |
---|
708 | n/a | |
---|
709 | n/a | Be = ROL32((Aga0^Da0), 18); |
---|
710 | n/a | Bi = ROL32((Ake0^De0), 5); |
---|
711 | n/a | Bo = ROL32((Ami1^Di1), 8); |
---|
712 | n/a | Bu = ROL32((Aso0^Do0), 28); |
---|
713 | n/a | Ba = ROL32((Abu1^Du1), 14); |
---|
714 | n/a | Aga0 = Ba ^((~Be)& Bi ); |
---|
715 | n/a | Ake0 = Be ^((~Bi)& Bo ); |
---|
716 | n/a | Ami1 = Bi ^((~Bo)& Bu ); |
---|
717 | n/a | Aso0 = Bo ^((~Bu)& Ba ); |
---|
718 | n/a | Abu1 = Bu ^((~Ba)& Be ); |
---|
719 | n/a | |
---|
720 | n/a | Be = ROL32((Aga1^Da1), 18); |
---|
721 | n/a | Bi = ROL32((Ake1^De1), 5); |
---|
722 | n/a | Bo = ROL32((Ami0^Di0), 7); |
---|
723 | n/a | Bu = ROL32((Aso1^Do1), 28); |
---|
724 | n/a | Ba = ROL32((Abu0^Du0), 13); |
---|
725 | n/a | Aga1 = Ba ^((~Be)& Bi ); |
---|
726 | n/a | Ake1 = Be ^((~Bi)& Bo ); |
---|
727 | n/a | Ami0 = Bi ^((~Bo)& Bu ); |
---|
728 | n/a | Aso1 = Bo ^((~Bu)& Ba ); |
---|
729 | n/a | Abu0 = Bu ^((~Ba)& Be ); |
---|
730 | n/a | |
---|
731 | n/a | Bo = ROL32((Ama1^Da1), 21); |
---|
732 | n/a | Bu = ROL32((Ase0^De0), 1); |
---|
733 | n/a | Ba = ROL32((Abi0^Di0), 31); |
---|
734 | n/a | Be = ROL32((Ago1^Do1), 28); |
---|
735 | n/a | Bi = ROL32((Aku1^Du1), 20); |
---|
736 | n/a | Ama1 = Ba ^((~Be)& Bi ); |
---|
737 | n/a | Ase0 = Be ^((~Bi)& Bo ); |
---|
738 | n/a | Abi0 = Bi ^((~Bo)& Bu ); |
---|
739 | n/a | Ago1 = Bo ^((~Bu)& Ba ); |
---|
740 | n/a | Aku1 = Bu ^((~Ba)& Be ); |
---|
741 | n/a | |
---|
742 | n/a | Bo = ROL32((Ama0^Da0), 20); |
---|
743 | n/a | Bu = ROL32((Ase1^De1), 1); |
---|
744 | n/a | Ba = ROL32((Abi1^Di1), 31); |
---|
745 | n/a | Be = ROL32((Ago0^Do0), 27); |
---|
746 | n/a | Bi = ROL32((Aku0^Du0), 19); |
---|
747 | n/a | Ama0 = Ba ^((~Be)& Bi ); |
---|
748 | n/a | Ase1 = Be ^((~Bi)& Bo ); |
---|
749 | n/a | Abi1 = Bi ^((~Bo)& Bu ); |
---|
750 | n/a | Ago0 = Bo ^((~Bu)& Ba ); |
---|
751 | n/a | Aku0 = Bu ^((~Ba)& Be ); |
---|
752 | n/a | |
---|
753 | n/a | KeccakAtoD_round1(); |
---|
754 | n/a | |
---|
755 | n/a | Ba = (Aba0^Da0); |
---|
756 | n/a | Be = ROL32((Ame1^De0), 22); |
---|
757 | n/a | Bi = ROL32((Agi1^Di1), 22); |
---|
758 | n/a | Bo = ROL32((Aso1^Do1), 11); |
---|
759 | n/a | Bu = ROL32((Aku1^Du0), 7); |
---|
760 | n/a | Aba0 = Ba ^((~Be)& Bi ); |
---|
761 | n/a | Aba0 ^= *(pRoundConstants++); |
---|
762 | n/a | Ame1 = Be ^((~Bi)& Bo ); |
---|
763 | n/a | Agi1 = Bi ^((~Bo)& Bu ); |
---|
764 | n/a | Aso1 = Bo ^((~Bu)& Ba ); |
---|
765 | n/a | Aku1 = Bu ^((~Ba)& Be ); |
---|
766 | n/a | |
---|
767 | n/a | Ba = (Aba1^Da1); |
---|
768 | n/a | Be = ROL32((Ame0^De1), 22); |
---|
769 | n/a | Bi = ROL32((Agi0^Di0), 21); |
---|
770 | n/a | Bo = ROL32((Aso0^Do0), 10); |
---|
771 | n/a | Bu = ROL32((Aku0^Du1), 7); |
---|
772 | n/a | Aba1 = Ba ^((~Be)& Bi ); |
---|
773 | n/a | Aba1 ^= *(pRoundConstants++); |
---|
774 | n/a | Ame0 = Be ^((~Bi)& Bo ); |
---|
775 | n/a | Agi0 = Bi ^((~Bo)& Bu ); |
---|
776 | n/a | Aso0 = Bo ^((~Bu)& Ba ); |
---|
777 | n/a | Aku0 = Bu ^((~Ba)& Be ); |
---|
778 | n/a | |
---|
779 | n/a | Bi = ROL32((Asa1^Da1), 2); |
---|
780 | n/a | Bo = ROL32((Ake1^De1), 23); |
---|
781 | n/a | Bu = ROL32((Abi1^Di1), 31); |
---|
782 | n/a | Ba = ROL32((Amo1^Do0), 14); |
---|
783 | n/a | Be = ROL32((Agu0^Du0), 10); |
---|
784 | n/a | Asa1 = Ba ^((~Be)& Bi ); |
---|
785 | n/a | Ake1 = Be ^((~Bi)& Bo ); |
---|
786 | n/a | Abi1 = Bi ^((~Bo)& Bu ); |
---|
787 | n/a | Amo1 = Bo ^((~Bu)& Ba ); |
---|
788 | n/a | Agu0 = Bu ^((~Ba)& Be ); |
---|
789 | n/a | |
---|
790 | n/a | Bi = ROL32((Asa0^Da0), 1); |
---|
791 | n/a | Bo = ROL32((Ake0^De0), 22); |
---|
792 | n/a | Bu = ROL32((Abi0^Di0), 30); |
---|
793 | n/a | Ba = ROL32((Amo0^Do1), 14); |
---|
794 | n/a | Be = ROL32((Agu1^Du1), 10); |
---|
795 | n/a | Asa0 = Ba ^((~Be)& Bi ); |
---|
796 | n/a | Ake0 = Be ^((~Bi)& Bo ); |
---|
797 | n/a | Abi0 = Bi ^((~Bo)& Bu ); |
---|
798 | n/a | Amo0 = Bo ^((~Bu)& Ba ); |
---|
799 | n/a | Agu1 = Bu ^((~Ba)& Be ); |
---|
800 | n/a | |
---|
801 | n/a | Bu = ROL32((Ama1^Da0), 9); |
---|
802 | n/a | Ba = ROL32((Age1^De1), 1); |
---|
803 | n/a | Be = ROL32((Asi1^Di0), 3); |
---|
804 | n/a | Bi = ROL32((Ako0^Do1), 13); |
---|
805 | n/a | Bo = ROL32((Abu1^Du0), 4); |
---|
806 | n/a | Ama1 = Ba ^((~Be)& Bi ); |
---|
807 | n/a | Age1 = Be ^((~Bi)& Bo ); |
---|
808 | n/a | Asi1 = Bi ^((~Bo)& Bu ); |
---|
809 | n/a | Ako0 = Bo ^((~Bu)& Ba ); |
---|
810 | n/a | Abu1 = Bu ^((~Ba)& Be ); |
---|
811 | n/a | |
---|
812 | n/a | Bu = ROL32((Ama0^Da1), 9); |
---|
813 | n/a | Ba = (Age0^De0); |
---|
814 | n/a | Be = ROL32((Asi0^Di1), 3); |
---|
815 | n/a | Bi = ROL32((Ako1^Do0), 12); |
---|
816 | n/a | Bo = ROL32((Abu0^Du1), 4); |
---|
817 | n/a | Ama0 = Ba ^((~Be)& Bi ); |
---|
818 | n/a | Age0 = Be ^((~Bi)& Bo ); |
---|
819 | n/a | Asi0 = Bi ^((~Bo)& Bu ); |
---|
820 | n/a | Ako1 = Bo ^((~Bu)& Ba ); |
---|
821 | n/a | Abu0 = Bu ^((~Ba)& Be ); |
---|
822 | n/a | |
---|
823 | n/a | Be = ROL32((Aka1^Da0), 18); |
---|
824 | n/a | Bi = ROL32((Abe1^De0), 5); |
---|
825 | n/a | Bo = ROL32((Ami0^Di1), 8); |
---|
826 | n/a | Bu = ROL32((Ago1^Do0), 28); |
---|
827 | n/a | Ba = ROL32((Asu1^Du1), 14); |
---|
828 | n/a | Aka1 = Ba ^((~Be)& Bi ); |
---|
829 | n/a | Abe1 = Be ^((~Bi)& Bo ); |
---|
830 | n/a | Ami0 = Bi ^((~Bo)& Bu ); |
---|
831 | n/a | Ago1 = Bo ^((~Bu)& Ba ); |
---|
832 | n/a | Asu1 = Bu ^((~Ba)& Be ); |
---|
833 | n/a | |
---|
834 | n/a | Be = ROL32((Aka0^Da1), 18); |
---|
835 | n/a | Bi = ROL32((Abe0^De1), 5); |
---|
836 | n/a | Bo = ROL32((Ami1^Di0), 7); |
---|
837 | n/a | Bu = ROL32((Ago0^Do1), 28); |
---|
838 | n/a | Ba = ROL32((Asu0^Du0), 13); |
---|
839 | n/a | Aka0 = Ba ^((~Be)& Bi ); |
---|
840 | n/a | Abe0 = Be ^((~Bi)& Bo ); |
---|
841 | n/a | Ami1 = Bi ^((~Bo)& Bu ); |
---|
842 | n/a | Ago0 = Bo ^((~Bu)& Ba ); |
---|
843 | n/a | Asu0 = Bu ^((~Ba)& Be ); |
---|
844 | n/a | |
---|
845 | n/a | Bo = ROL32((Aga1^Da1), 21); |
---|
846 | n/a | Bu = ROL32((Ase0^De0), 1); |
---|
847 | n/a | Ba = ROL32((Aki1^Di0), 31); |
---|
848 | n/a | Be = ROL32((Abo1^Do1), 28); |
---|
849 | n/a | Bi = ROL32((Amu1^Du1), 20); |
---|
850 | n/a | Aga1 = Ba ^((~Be)& Bi ); |
---|
851 | n/a | Ase0 = Be ^((~Bi)& Bo ); |
---|
852 | n/a | Aki1 = Bi ^((~Bo)& Bu ); |
---|
853 | n/a | Abo1 = Bo ^((~Bu)& Ba ); |
---|
854 | n/a | Amu1 = Bu ^((~Ba)& Be ); |
---|
855 | n/a | |
---|
856 | n/a | Bo = ROL32((Aga0^Da0), 20); |
---|
857 | n/a | Bu = ROL32((Ase1^De1), 1); |
---|
858 | n/a | Ba = ROL32((Aki0^Di1), 31); |
---|
859 | n/a | Be = ROL32((Abo0^Do0), 27); |
---|
860 | n/a | Bi = ROL32((Amu0^Du0), 19); |
---|
861 | n/a | Aga0 = Ba ^((~Be)& Bi ); |
---|
862 | n/a | Ase1 = Be ^((~Bi)& Bo ); |
---|
863 | n/a | Aki0 = Bi ^((~Bo)& Bu ); |
---|
864 | n/a | Abo0 = Bo ^((~Bu)& Ba ); |
---|
865 | n/a | Amu0 = Bu ^((~Ba)& Be ); |
---|
866 | n/a | |
---|
867 | n/a | KeccakAtoD_round2(); |
---|
868 | n/a | |
---|
869 | n/a | Ba = (Aba0^Da0); |
---|
870 | n/a | Be = ROL32((Ake1^De0), 22); |
---|
871 | n/a | Bi = ROL32((Asi0^Di1), 22); |
---|
872 | n/a | Bo = ROL32((Ago0^Do1), 11); |
---|
873 | n/a | Bu = ROL32((Amu1^Du0), 7); |
---|
874 | n/a | Aba0 = Ba ^((~Be)& Bi ); |
---|
875 | n/a | Aba0 ^= *(pRoundConstants++); |
---|
876 | n/a | Ake1 = Be ^((~Bi)& Bo ); |
---|
877 | n/a | Asi0 = Bi ^((~Bo)& Bu ); |
---|
878 | n/a | Ago0 = Bo ^((~Bu)& Ba ); |
---|
879 | n/a | Amu1 = Bu ^((~Ba)& Be ); |
---|
880 | n/a | |
---|
881 | n/a | Ba = (Aba1^Da1); |
---|
882 | n/a | Be = ROL32((Ake0^De1), 22); |
---|
883 | n/a | Bi = ROL32((Asi1^Di0), 21); |
---|
884 | n/a | Bo = ROL32((Ago1^Do0), 10); |
---|
885 | n/a | Bu = ROL32((Amu0^Du1), 7); |
---|
886 | n/a | Aba1 = Ba ^((~Be)& Bi ); |
---|
887 | n/a | Aba1 ^= *(pRoundConstants++); |
---|
888 | n/a | Ake0 = Be ^((~Bi)& Bo ); |
---|
889 | n/a | Asi1 = Bi ^((~Bo)& Bu ); |
---|
890 | n/a | Ago1 = Bo ^((~Bu)& Ba ); |
---|
891 | n/a | Amu0 = Bu ^((~Ba)& Be ); |
---|
892 | n/a | |
---|
893 | n/a | Bi = ROL32((Ama0^Da1), 2); |
---|
894 | n/a | Bo = ROL32((Abe0^De1), 23); |
---|
895 | n/a | Bu = ROL32((Aki0^Di1), 31); |
---|
896 | n/a | Ba = ROL32((Aso1^Do0), 14); |
---|
897 | n/a | Be = ROL32((Agu0^Du0), 10); |
---|
898 | n/a | Ama0 = Ba ^((~Be)& Bi ); |
---|
899 | n/a | Abe0 = Be ^((~Bi)& Bo ); |
---|
900 | n/a | Aki0 = Bi ^((~Bo)& Bu ); |
---|
901 | n/a | Aso1 = Bo ^((~Bu)& Ba ); |
---|
902 | n/a | Agu0 = Bu ^((~Ba)& Be ); |
---|
903 | n/a | |
---|
904 | n/a | Bi = ROL32((Ama1^Da0), 1); |
---|
905 | n/a | Bo = ROL32((Abe1^De0), 22); |
---|
906 | n/a | Bu = ROL32((Aki1^Di0), 30); |
---|
907 | n/a | Ba = ROL32((Aso0^Do1), 14); |
---|
908 | n/a | Be = ROL32((Agu1^Du1), 10); |
---|
909 | n/a | Ama1 = Ba ^((~Be)& Bi ); |
---|
910 | n/a | Abe1 = Be ^((~Bi)& Bo ); |
---|
911 | n/a | Aki1 = Bi ^((~Bo)& Bu ); |
---|
912 | n/a | Aso0 = Bo ^((~Bu)& Ba ); |
---|
913 | n/a | Agu1 = Bu ^((~Ba)& Be ); |
---|
914 | n/a | |
---|
915 | n/a | Bu = ROL32((Aga1^Da0), 9); |
---|
916 | n/a | Ba = ROL32((Ame0^De1), 1); |
---|
917 | n/a | Be = ROL32((Abi1^Di0), 3); |
---|
918 | n/a | Bi = ROL32((Ako1^Do1), 13); |
---|
919 | n/a | Bo = ROL32((Asu1^Du0), 4); |
---|
920 | n/a | Aga1 = Ba ^((~Be)& Bi ); |
---|
921 | n/a | Ame0 = Be ^((~Bi)& Bo ); |
---|
922 | n/a | Abi1 = Bi ^((~Bo)& Bu ); |
---|
923 | n/a | Ako1 = Bo ^((~Bu)& Ba ); |
---|
924 | n/a | Asu1 = Bu ^((~Ba)& Be ); |
---|
925 | n/a | |
---|
926 | n/a | Bu = ROL32((Aga0^Da1), 9); |
---|
927 | n/a | Ba = (Ame1^De0); |
---|
928 | n/a | Be = ROL32((Abi0^Di1), 3); |
---|
929 | n/a | Bi = ROL32((Ako0^Do0), 12); |
---|
930 | n/a | Bo = ROL32((Asu0^Du1), 4); |
---|
931 | n/a | Aga0 = Ba ^((~Be)& Bi ); |
---|
932 | n/a | Ame1 = Be ^((~Bi)& Bo ); |
---|
933 | n/a | Abi0 = Bi ^((~Bo)& Bu ); |
---|
934 | n/a | Ako0 = Bo ^((~Bu)& Ba ); |
---|
935 | n/a | Asu0 = Bu ^((~Ba)& Be ); |
---|
936 | n/a | |
---|
937 | n/a | Be = ROL32((Asa1^Da0), 18); |
---|
938 | n/a | Bi = ROL32((Age1^De0), 5); |
---|
939 | n/a | Bo = ROL32((Ami1^Di1), 8); |
---|
940 | n/a | Bu = ROL32((Abo1^Do0), 28); |
---|
941 | n/a | Ba = ROL32((Aku0^Du1), 14); |
---|
942 | n/a | Asa1 = Ba ^((~Be)& Bi ); |
---|
943 | n/a | Age1 = Be ^((~Bi)& Bo ); |
---|
944 | n/a | Ami1 = Bi ^((~Bo)& Bu ); |
---|
945 | n/a | Abo1 = Bo ^((~Bu)& Ba ); |
---|
946 | n/a | Aku0 = Bu ^((~Ba)& Be ); |
---|
947 | n/a | |
---|
948 | n/a | Be = ROL32((Asa0^Da1), 18); |
---|
949 | n/a | Bi = ROL32((Age0^De1), 5); |
---|
950 | n/a | Bo = ROL32((Ami0^Di0), 7); |
---|
951 | n/a | Bu = ROL32((Abo0^Do1), 28); |
---|
952 | n/a | Ba = ROL32((Aku1^Du0), 13); |
---|
953 | n/a | Asa0 = Ba ^((~Be)& Bi ); |
---|
954 | n/a | Age0 = Be ^((~Bi)& Bo ); |
---|
955 | n/a | Ami0 = Bi ^((~Bo)& Bu ); |
---|
956 | n/a | Abo0 = Bo ^((~Bu)& Ba ); |
---|
957 | n/a | Aku1 = Bu ^((~Ba)& Be ); |
---|
958 | n/a | |
---|
959 | n/a | Bo = ROL32((Aka0^Da1), 21); |
---|
960 | n/a | Bu = ROL32((Ase0^De0), 1); |
---|
961 | n/a | Ba = ROL32((Agi1^Di0), 31); |
---|
962 | n/a | Be = ROL32((Amo0^Do1), 28); |
---|
963 | n/a | Bi = ROL32((Abu0^Du1), 20); |
---|
964 | n/a | Aka0 = Ba ^((~Be)& Bi ); |
---|
965 | n/a | Ase0 = Be ^((~Bi)& Bo ); |
---|
966 | n/a | Agi1 = Bi ^((~Bo)& Bu ); |
---|
967 | n/a | Amo0 = Bo ^((~Bu)& Ba ); |
---|
968 | n/a | Abu0 = Bu ^((~Ba)& Be ); |
---|
969 | n/a | |
---|
970 | n/a | Bo = ROL32((Aka1^Da0), 20); |
---|
971 | n/a | Bu = ROL32((Ase1^De1), 1); |
---|
972 | n/a | Ba = ROL32((Agi0^Di1), 31); |
---|
973 | n/a | Be = ROL32((Amo1^Do0), 27); |
---|
974 | n/a | Bi = ROL32((Abu1^Du0), 19); |
---|
975 | n/a | Aka1 = Ba ^((~Be)& Bi ); |
---|
976 | n/a | Ase1 = Be ^((~Bi)& Bo ); |
---|
977 | n/a | Agi0 = Bi ^((~Bo)& Bu ); |
---|
978 | n/a | Amo1 = Bo ^((~Bu)& Ba ); |
---|
979 | n/a | Abu1 = Bu ^((~Ba)& Be ); |
---|
980 | n/a | |
---|
981 | n/a | KeccakAtoD_round3(); |
---|
982 | n/a | |
---|
983 | n/a | Ba = (Aba0^Da0); |
---|
984 | n/a | Be = ROL32((Abe0^De0), 22); |
---|
985 | n/a | Bi = ROL32((Abi0^Di1), 22); |
---|
986 | n/a | Bo = ROL32((Abo0^Do1), 11); |
---|
987 | n/a | Bu = ROL32((Abu0^Du0), 7); |
---|
988 | n/a | Aba0 = Ba ^((~Be)& Bi ); |
---|
989 | n/a | Aba0 ^= *(pRoundConstants++); |
---|
990 | n/a | Abe0 = Be ^((~Bi)& Bo ); |
---|
991 | n/a | Abi0 = Bi ^((~Bo)& Bu ); |
---|
992 | n/a | Abo0 = Bo ^((~Bu)& Ba ); |
---|
993 | n/a | Abu0 = Bu ^((~Ba)& Be ); |
---|
994 | n/a | |
---|
995 | n/a | Ba = (Aba1^Da1); |
---|
996 | n/a | Be = ROL32((Abe1^De1), 22); |
---|
997 | n/a | Bi = ROL32((Abi1^Di0), 21); |
---|
998 | n/a | Bo = ROL32((Abo1^Do0), 10); |
---|
999 | n/a | Bu = ROL32((Abu1^Du1), 7); |
---|
1000 | n/a | Aba1 = Ba ^((~Be)& Bi ); |
---|
1001 | n/a | Aba1 ^= *(pRoundConstants++); |
---|
1002 | n/a | Abe1 = Be ^((~Bi)& Bo ); |
---|
1003 | n/a | Abi1 = Bi ^((~Bo)& Bu ); |
---|
1004 | n/a | Abo1 = Bo ^((~Bu)& Ba ); |
---|
1005 | n/a | Abu1 = Bu ^((~Ba)& Be ); |
---|
1006 | n/a | |
---|
1007 | n/a | Bi = ROL32((Aga0^Da1), 2); |
---|
1008 | n/a | Bo = ROL32((Age0^De1), 23); |
---|
1009 | n/a | Bu = ROL32((Agi0^Di1), 31); |
---|
1010 | n/a | Ba = ROL32((Ago0^Do0), 14); |
---|
1011 | n/a | Be = ROL32((Agu0^Du0), 10); |
---|
1012 | n/a | Aga0 = Ba ^((~Be)& Bi ); |
---|
1013 | n/a | Age0 = Be ^((~Bi)& Bo ); |
---|
1014 | n/a | Agi0 = Bi ^((~Bo)& Bu ); |
---|
1015 | n/a | Ago0 = Bo ^((~Bu)& Ba ); |
---|
1016 | n/a | Agu0 = Bu ^((~Ba)& Be ); |
---|
1017 | n/a | |
---|
1018 | n/a | Bi = ROL32((Aga1^Da0), 1); |
---|
1019 | n/a | Bo = ROL32((Age1^De0), 22); |
---|
1020 | n/a | Bu = ROL32((Agi1^Di0), 30); |
---|
1021 | n/a | Ba = ROL32((Ago1^Do1), 14); |
---|
1022 | n/a | Be = ROL32((Agu1^Du1), 10); |
---|
1023 | n/a | Aga1 = Ba ^((~Be)& Bi ); |
---|
1024 | n/a | Age1 = Be ^((~Bi)& Bo ); |
---|
1025 | n/a | Agi1 = Bi ^((~Bo)& Bu ); |
---|
1026 | n/a | Ago1 = Bo ^((~Bu)& Ba ); |
---|
1027 | n/a | Agu1 = Bu ^((~Ba)& Be ); |
---|
1028 | n/a | |
---|
1029 | n/a | Bu = ROL32((Aka0^Da0), 9); |
---|
1030 | n/a | Ba = ROL32((Ake0^De1), 1); |
---|
1031 | n/a | Be = ROL32((Aki0^Di0), 3); |
---|
1032 | n/a | Bi = ROL32((Ako0^Do1), 13); |
---|
1033 | n/a | Bo = ROL32((Aku0^Du0), 4); |
---|
1034 | n/a | Aka0 = Ba ^((~Be)& Bi ); |
---|
1035 | n/a | Ake0 = Be ^((~Bi)& Bo ); |
---|
1036 | n/a | Aki0 = Bi ^((~Bo)& Bu ); |
---|
1037 | n/a | Ako0 = Bo ^((~Bu)& Ba ); |
---|
1038 | n/a | Aku0 = Bu ^((~Ba)& Be ); |
---|
1039 | n/a | |
---|
1040 | n/a | Bu = ROL32((Aka1^Da1), 9); |
---|
1041 | n/a | Ba = (Ake1^De0); |
---|
1042 | n/a | Be = ROL32((Aki1^Di1), 3); |
---|
1043 | n/a | Bi = ROL32((Ako1^Do0), 12); |
---|
1044 | n/a | Bo = ROL32((Aku1^Du1), 4); |
---|
1045 | n/a | Aka1 = Ba ^((~Be)& Bi ); |
---|
1046 | n/a | Ake1 = Be ^((~Bi)& Bo ); |
---|
1047 | n/a | Aki1 = Bi ^((~Bo)& Bu ); |
---|
1048 | n/a | Ako1 = Bo ^((~Bu)& Ba ); |
---|
1049 | n/a | Aku1 = Bu ^((~Ba)& Be ); |
---|
1050 | n/a | |
---|
1051 | n/a | Be = ROL32((Ama0^Da0), 18); |
---|
1052 | n/a | Bi = ROL32((Ame0^De0), 5); |
---|
1053 | n/a | Bo = ROL32((Ami0^Di1), 8); |
---|
1054 | n/a | Bu = ROL32((Amo0^Do0), 28); |
---|
1055 | n/a | Ba = ROL32((Amu0^Du1), 14); |
---|
1056 | n/a | Ama0 = Ba ^((~Be)& Bi ); |
---|
1057 | n/a | Ame0 = Be ^((~Bi)& Bo ); |
---|
1058 | n/a | Ami0 = Bi ^((~Bo)& Bu ); |
---|
1059 | n/a | Amo0 = Bo ^((~Bu)& Ba ); |
---|
1060 | n/a | Amu0 = Bu ^((~Ba)& Be ); |
---|
1061 | n/a | |
---|
1062 | n/a | Be = ROL32((Ama1^Da1), 18); |
---|
1063 | n/a | Bi = ROL32((Ame1^De1), 5); |
---|
1064 | n/a | Bo = ROL32((Ami1^Di0), 7); |
---|
1065 | n/a | Bu = ROL32((Amo1^Do1), 28); |
---|
1066 | n/a | Ba = ROL32((Amu1^Du0), 13); |
---|
1067 | n/a | Ama1 = Ba ^((~Be)& Bi ); |
---|
1068 | n/a | Ame1 = Be ^((~Bi)& Bo ); |
---|
1069 | n/a | Ami1 = Bi ^((~Bo)& Bu ); |
---|
1070 | n/a | Amo1 = Bo ^((~Bu)& Ba ); |
---|
1071 | n/a | Amu1 = Bu ^((~Ba)& Be ); |
---|
1072 | n/a | |
---|
1073 | n/a | Bo = ROL32((Asa0^Da1), 21); |
---|
1074 | n/a | Bu = ROL32((Ase0^De0), 1); |
---|
1075 | n/a | Ba = ROL32((Asi0^Di0), 31); |
---|
1076 | n/a | Be = ROL32((Aso0^Do1), 28); |
---|
1077 | n/a | Bi = ROL32((Asu0^Du1), 20); |
---|
1078 | n/a | Asa0 = Ba ^((~Be)& Bi ); |
---|
1079 | n/a | Ase0 = Be ^((~Bi)& Bo ); |
---|
1080 | n/a | Asi0 = Bi ^((~Bo)& Bu ); |
---|
1081 | n/a | Aso0 = Bo ^((~Bu)& Ba ); |
---|
1082 | n/a | Asu0 = Bu ^((~Ba)& Be ); |
---|
1083 | n/a | |
---|
1084 | n/a | Bo = ROL32((Asa1^Da0), 20); |
---|
1085 | n/a | Bu = ROL32((Ase1^De1), 1); |
---|
1086 | n/a | Ba = ROL32((Asi1^Di1), 31); |
---|
1087 | n/a | Be = ROL32((Aso1^Do0), 27); |
---|
1088 | n/a | Bi = ROL32((Asu1^Du0), 19); |
---|
1089 | n/a | Asa1 = Ba ^((~Be)& Bi ); |
---|
1090 | n/a | Ase1 = Be ^((~Bi)& Bo ); |
---|
1091 | n/a | Asi1 = Bi ^((~Bo)& Bu ); |
---|
1092 | n/a | Aso1 = Bo ^((~Bu)& Ba ); |
---|
1093 | n/a | Asu1 = Bu ^((~Ba)& Be ); |
---|
1094 | n/a | } |
---|
1095 | n/a | while ( *pRoundConstants != 0xFF ); |
---|
1096 | n/a | |
---|
1097 | n/a | #undef Aba0 |
---|
1098 | n/a | #undef Aba1 |
---|
1099 | n/a | #undef Abe0 |
---|
1100 | n/a | #undef Abe1 |
---|
1101 | n/a | #undef Abi0 |
---|
1102 | n/a | #undef Abi1 |
---|
1103 | n/a | #undef Abo0 |
---|
1104 | n/a | #undef Abo1 |
---|
1105 | n/a | #undef Abu0 |
---|
1106 | n/a | #undef Abu1 |
---|
1107 | n/a | #undef Aga0 |
---|
1108 | n/a | #undef Aga1 |
---|
1109 | n/a | #undef Age0 |
---|
1110 | n/a | #undef Age1 |
---|
1111 | n/a | #undef Agi0 |
---|
1112 | n/a | #undef Agi1 |
---|
1113 | n/a | #undef Ago0 |
---|
1114 | n/a | #undef Ago1 |
---|
1115 | n/a | #undef Agu0 |
---|
1116 | n/a | #undef Agu1 |
---|
1117 | n/a | #undef Aka0 |
---|
1118 | n/a | #undef Aka1 |
---|
1119 | n/a | #undef Ake0 |
---|
1120 | n/a | #undef Ake1 |
---|
1121 | n/a | #undef Aki0 |
---|
1122 | n/a | #undef Aki1 |
---|
1123 | n/a | #undef Ako0 |
---|
1124 | n/a | #undef Ako1 |
---|
1125 | n/a | #undef Aku0 |
---|
1126 | n/a | #undef Aku1 |
---|
1127 | n/a | #undef Ama0 |
---|
1128 | n/a | #undef Ama1 |
---|
1129 | n/a | #undef Ame0 |
---|
1130 | n/a | #undef Ame1 |
---|
1131 | n/a | #undef Ami0 |
---|
1132 | n/a | #undef Ami1 |
---|
1133 | n/a | #undef Amo0 |
---|
1134 | n/a | #undef Amo1 |
---|
1135 | n/a | #undef Amu0 |
---|
1136 | n/a | #undef Amu1 |
---|
1137 | n/a | #undef Asa0 |
---|
1138 | n/a | #undef Asa1 |
---|
1139 | n/a | #undef Ase0 |
---|
1140 | n/a | #undef Ase1 |
---|
1141 | n/a | #undef Asi0 |
---|
1142 | n/a | #undef Asi1 |
---|
1143 | n/a | #undef Aso0 |
---|
1144 | n/a | #undef Aso1 |
---|
1145 | n/a | #undef Asu0 |
---|
1146 | n/a | #undef Asu1 |
---|
1147 | n/a | } |
---|
1148 | n/a | } |
---|
1149 | n/a | |
---|
1150 | n/a | /* ---------------------------------------------------------------- */ |
---|
1151 | n/a | |
---|
1152 | n/a | void KeccakP1600_Permute_12rounds(void *state) |
---|
1153 | n/a | { |
---|
1154 | n/a | KeccakP1600_Permute_Nrounds(state, 12); |
---|
1155 | n/a | } |
---|
1156 | n/a | |
---|
1157 | n/a | /* ---------------------------------------------------------------- */ |
---|
1158 | n/a | |
---|
1159 | n/a | void KeccakP1600_Permute_24rounds(void *state) |
---|
1160 | n/a | { |
---|
1161 | n/a | KeccakP1600_Permute_Nrounds(state, 24); |
---|
1162 | n/a | } |
---|