sha3 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +8 -5
  4. data/certs/johanns.pem +23 -22
  5. data/ext/sha3/config.h +26 -0
  6. data/ext/sha3/digest.c +6 -6
  7. data/ext/sha3/extconf.rb +40 -10
  8. data/ext/sha3/lib/common/align.h +33 -0
  9. data/ext/sha3/{brg_endian.h → lib/common/brg_endian.h} +8 -7
  10. data/ext/sha3/{KeccakHash.c → lib/high/Keccak/FIPS202/KeccakHash.c} +26 -25
  11. data/ext/sha3/{KeccakHash.h → lib/high/Keccak/FIPS202/KeccakHash.h} +34 -19
  12. data/ext/sha3/lib/high/Keccak/KeccakSponge.c +111 -0
  13. data/ext/sha3/lib/high/Keccak/KeccakSponge.h +76 -0
  14. data/ext/sha3/lib/high/Keccak/KeccakSponge.inc +316 -0
  15. data/ext/sha3/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros +748 -0
  16. data/ext/sha3/lib/low/KeccakP-1600/common/KeccakP-1600-unrolling.macros +305 -0
  17. data/ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-SnP.h +44 -0
  18. data/ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference.h +23 -0
  19. data/ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference32BI.c +625 -0
  20. data/ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-SnP.h +44 -0
  21. data/ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.c +444 -0
  22. data/ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.h +23 -0
  23. data/lib/sha3/version.rb +1 -1
  24. data/sha3.gemspec +6 -5
  25. data/tests.sh +8 -7
  26. data.tar.gz.sig +0 -0
  27. metadata +50 -66
  28. metadata.gz.sig +0 -0
  29. data/ext/sha3/KeccakF-1600-interface.h +0 -40
  30. data/ext/sha3/KeccakSponge.c +0 -192
  31. data/ext/sha3/KeccakSponge.h +0 -113
  32. data/ext/sha3/Optimized64/KeccakF-1600-64.macros +0 -2199
  33. data/ext/sha3/Optimized64/KeccakF-1600-opt64-settings.h +0 -3
  34. data/ext/sha3/Optimized64/KeccakF-1600-opt64.c +0 -508
  35. data/ext/sha3/Optimized64/KeccakF-1600-unrolling.macros +0 -126
  36. data/ext/sha3/Optimized64/SnP-interface.h +0 -47
  37. data/ext/sha3/Reference/KeccakF-1600-reference.c +0 -311
  38. data/ext/sha3/Reference/KeccakF-reference.h +0 -26
  39. data/ext/sha3/Reference/SnP-FBWL-default.c +0 -96
  40. data/ext/sha3/Reference/SnP-FBWL-default.h +0 -26
  41. data/ext/sha3/Reference/SnP-interface.h +0 -42
  42. data/ext/sha3/Reference/displayIntermediateValues.c +0 -158
  43. data/ext/sha3/Reference/displayIntermediateValues.h +0 -34
  44. data/ext/sha3/SnP-Relaned.h +0 -249
@@ -0,0 +1,748 @@
1
+ /*
2
+ The eXtended Keccak Code Package (XKCP)
3
+ https://github.com/XKCP/XKCP
4
+
5
+ The Keccak-p permutations, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
6
+
7
+ Implementation by Gilles Van Assche and Ronny Van Keer, hereby denoted as "the implementer".
8
+
9
+ For more information, feedback or questions, please refer to the Keccak Team website:
10
+ https://keccak.team/
11
+
12
+ To the extent possible under law, the implementer has waived all copyright
13
+ and related or neighboring rights to the source code in this file.
14
+ http://creativecommons.org/publicdomain/zero/1.0/
15
+ */
16
+
17
+ #define declareABCDE \
18
+ uint64_t Aba, Abe, Abi, Abo, Abu; \
19
+ uint64_t Aga, Age, Agi, Ago, Agu; \
20
+ uint64_t Aka, Ake, Aki, Ako, Aku; \
21
+ uint64_t Ama, Ame, Ami, Amo, Amu; \
22
+ uint64_t Asa, Ase, Asi, Aso, Asu; \
23
+ uint64_t Bba, Bbe, Bbi, Bbo, Bbu; \
24
+ uint64_t Bga, Bge, Bgi, Bgo, Bgu; \
25
+ uint64_t Bka, Bke, Bki, Bko, Bku; \
26
+ uint64_t Bma, Bme, Bmi, Bmo, Bmu; \
27
+ uint64_t Bsa, Bse, Bsi, Bso, Bsu; \
28
+ uint64_t Ca, Ce, Ci, Co, Cu; \
29
+ uint64_t Da, De, Di, Do, Du; \
30
+ uint64_t Eba, Ebe, Ebi, Ebo, Ebu; \
31
+ uint64_t Ega, Ege, Egi, Ego, Egu; \
32
+ uint64_t Eka, Eke, Eki, Eko, Eku; \
33
+ uint64_t Ema, Eme, Emi, Emo, Emu; \
34
+ uint64_t Esa, Ese, Esi, Eso, Esu; \
35
+
36
+ #define prepareTheta \
37
+ Ca = Aba^Aga^Aka^Ama^Asa; \
38
+ Ce = Abe^Age^Ake^Ame^Ase; \
39
+ Ci = Abi^Agi^Aki^Ami^Asi; \
40
+ Co = Abo^Ago^Ako^Amo^Aso; \
41
+ Cu = Abu^Agu^Aku^Amu^Asu; \
42
+
43
+ #ifdef UseBebigokimisa
44
+ /* --- Code for round, with prepare-theta (lane complementing pattern 'bebigokimisa') */
45
+ /* --- 64-bit lanes mapped to 64-bit words */
46
+ #define thetaRhoPiChiIotaPrepareTheta(i, A, E) \
47
+ Da = Cu^ROL64(Ce, 1); \
48
+ De = Ca^ROL64(Ci, 1); \
49
+ Di = Ce^ROL64(Co, 1); \
50
+ Do = Ci^ROL64(Cu, 1); \
51
+ Du = Co^ROL64(Ca, 1); \
52
+ \
53
+ A##ba ^= Da; \
54
+ Bba = A##ba; \
55
+ A##ge ^= De; \
56
+ Bbe = ROL64(A##ge, 44); \
57
+ A##ki ^= Di; \
58
+ Bbi = ROL64(A##ki, 43); \
59
+ A##mo ^= Do; \
60
+ Bbo = ROL64(A##mo, 21); \
61
+ A##su ^= Du; \
62
+ Bbu = ROL64(A##su, 14); \
63
+ E##ba = Bba ^( Bbe | Bbi ); \
64
+ E##ba ^= KeccakF1600RoundConstants[i]; \
65
+ Ca = E##ba; \
66
+ E##be = Bbe ^((~Bbi)| Bbo ); \
67
+ Ce = E##be; \
68
+ E##bi = Bbi ^( Bbo & Bbu ); \
69
+ Ci = E##bi; \
70
+ E##bo = Bbo ^( Bbu | Bba ); \
71
+ Co = E##bo; \
72
+ E##bu = Bbu ^( Bba & Bbe ); \
73
+ Cu = E##bu; \
74
+ \
75
+ A##bo ^= Do; \
76
+ Bga = ROL64(A##bo, 28); \
77
+ A##gu ^= Du; \
78
+ Bge = ROL64(A##gu, 20); \
79
+ A##ka ^= Da; \
80
+ Bgi = ROL64(A##ka, 3); \
81
+ A##me ^= De; \
82
+ Bgo = ROL64(A##me, 45); \
83
+ A##si ^= Di; \
84
+ Bgu = ROL64(A##si, 61); \
85
+ E##ga = Bga ^( Bge | Bgi ); \
86
+ Ca ^= E##ga; \
87
+ E##ge = Bge ^( Bgi & Bgo ); \
88
+ Ce ^= E##ge; \
89
+ E##gi = Bgi ^( Bgo |(~Bgu)); \
90
+ Ci ^= E##gi; \
91
+ E##go = Bgo ^( Bgu | Bga ); \
92
+ Co ^= E##go; \
93
+ E##gu = Bgu ^( Bga & Bge ); \
94
+ Cu ^= E##gu; \
95
+ \
96
+ A##be ^= De; \
97
+ Bka = ROL64(A##be, 1); \
98
+ A##gi ^= Di; \
99
+ Bke = ROL64(A##gi, 6); \
100
+ A##ko ^= Do; \
101
+ Bki = ROL64(A##ko, 25); \
102
+ A##mu ^= Du; \
103
+ Bko = ROL64(A##mu, 8); \
104
+ A##sa ^= Da; \
105
+ Bku = ROL64(A##sa, 18); \
106
+ E##ka = Bka ^( Bke | Bki ); \
107
+ Ca ^= E##ka; \
108
+ E##ke = Bke ^( Bki & Bko ); \
109
+ Ce ^= E##ke; \
110
+ E##ki = Bki ^((~Bko)& Bku ); \
111
+ Ci ^= E##ki; \
112
+ E##ko = (~Bko)^( Bku | Bka ); \
113
+ Co ^= E##ko; \
114
+ E##ku = Bku ^( Bka & Bke ); \
115
+ Cu ^= E##ku; \
116
+ \
117
+ A##bu ^= Du; \
118
+ Bma = ROL64(A##bu, 27); \
119
+ A##ga ^= Da; \
120
+ Bme = ROL64(A##ga, 36); \
121
+ A##ke ^= De; \
122
+ Bmi = ROL64(A##ke, 10); \
123
+ A##mi ^= Di; \
124
+ Bmo = ROL64(A##mi, 15); \
125
+ A##so ^= Do; \
126
+ Bmu = ROL64(A##so, 56); \
127
+ E##ma = Bma ^( Bme & Bmi ); \
128
+ Ca ^= E##ma; \
129
+ E##me = Bme ^( Bmi | Bmo ); \
130
+ Ce ^= E##me; \
131
+ E##mi = Bmi ^((~Bmo)| Bmu ); \
132
+ Ci ^= E##mi; \
133
+ E##mo = (~Bmo)^( Bmu & Bma ); \
134
+ Co ^= E##mo; \
135
+ E##mu = Bmu ^( Bma | Bme ); \
136
+ Cu ^= E##mu; \
137
+ \
138
+ A##bi ^= Di; \
139
+ Bsa = ROL64(A##bi, 62); \
140
+ A##go ^= Do; \
141
+ Bse = ROL64(A##go, 55); \
142
+ A##ku ^= Du; \
143
+ Bsi = ROL64(A##ku, 39); \
144
+ A##ma ^= Da; \
145
+ Bso = ROL64(A##ma, 41); \
146
+ A##se ^= De; \
147
+ Bsu = ROL64(A##se, 2); \
148
+ E##sa = Bsa ^((~Bse)& Bsi ); \
149
+ Ca ^= E##sa; \
150
+ E##se = (~Bse)^( Bsi | Bso ); \
151
+ Ce ^= E##se; \
152
+ E##si = Bsi ^( Bso & Bsu ); \
153
+ Ci ^= E##si; \
154
+ E##so = Bso ^( Bsu | Bsa ); \
155
+ Co ^= E##so; \
156
+ E##su = Bsu ^( Bsa & Bse ); \
157
+ Cu ^= E##su; \
158
+ \
159
+
160
+ /* --- Code for round (lane complementing pattern 'bebigokimisa') */
161
+ /* --- 64-bit lanes mapped to 64-bit words */
162
+ #define thetaRhoPiChiIota(i, A, E) \
163
+ Da = Cu^ROL64(Ce, 1); \
164
+ De = Ca^ROL64(Ci, 1); \
165
+ Di = Ce^ROL64(Co, 1); \
166
+ Do = Ci^ROL64(Cu, 1); \
167
+ Du = Co^ROL64(Ca, 1); \
168
+ \
169
+ A##ba ^= Da; \
170
+ Bba = A##ba; \
171
+ A##ge ^= De; \
172
+ Bbe = ROL64(A##ge, 44); \
173
+ A##ki ^= Di; \
174
+ Bbi = ROL64(A##ki, 43); \
175
+ A##mo ^= Do; \
176
+ Bbo = ROL64(A##mo, 21); \
177
+ A##su ^= Du; \
178
+ Bbu = ROL64(A##su, 14); \
179
+ E##ba = Bba ^( Bbe | Bbi ); \
180
+ E##ba ^= KeccakF1600RoundConstants[i]; \
181
+ E##be = Bbe ^((~Bbi)| Bbo ); \
182
+ E##bi = Bbi ^( Bbo & Bbu ); \
183
+ E##bo = Bbo ^( Bbu | Bba ); \
184
+ E##bu = Bbu ^( Bba & Bbe ); \
185
+ \
186
+ A##bo ^= Do; \
187
+ Bga = ROL64(A##bo, 28); \
188
+ A##gu ^= Du; \
189
+ Bge = ROL64(A##gu, 20); \
190
+ A##ka ^= Da; \
191
+ Bgi = ROL64(A##ka, 3); \
192
+ A##me ^= De; \
193
+ Bgo = ROL64(A##me, 45); \
194
+ A##si ^= Di; \
195
+ Bgu = ROL64(A##si, 61); \
196
+ E##ga = Bga ^( Bge | Bgi ); \
197
+ E##ge = Bge ^( Bgi & Bgo ); \
198
+ E##gi = Bgi ^( Bgo |(~Bgu)); \
199
+ E##go = Bgo ^( Bgu | Bga ); \
200
+ E##gu = Bgu ^( Bga & Bge ); \
201
+ \
202
+ A##be ^= De; \
203
+ Bka = ROL64(A##be, 1); \
204
+ A##gi ^= Di; \
205
+ Bke = ROL64(A##gi, 6); \
206
+ A##ko ^= Do; \
207
+ Bki = ROL64(A##ko, 25); \
208
+ A##mu ^= Du; \
209
+ Bko = ROL64(A##mu, 8); \
210
+ A##sa ^= Da; \
211
+ Bku = ROL64(A##sa, 18); \
212
+ E##ka = Bka ^( Bke | Bki ); \
213
+ E##ke = Bke ^( Bki & Bko ); \
214
+ E##ki = Bki ^((~Bko)& Bku ); \
215
+ E##ko = (~Bko)^( Bku | Bka ); \
216
+ E##ku = Bku ^( Bka & Bke ); \
217
+ \
218
+ A##bu ^= Du; \
219
+ Bma = ROL64(A##bu, 27); \
220
+ A##ga ^= Da; \
221
+ Bme = ROL64(A##ga, 36); \
222
+ A##ke ^= De; \
223
+ Bmi = ROL64(A##ke, 10); \
224
+ A##mi ^= Di; \
225
+ Bmo = ROL64(A##mi, 15); \
226
+ A##so ^= Do; \
227
+ Bmu = ROL64(A##so, 56); \
228
+ E##ma = Bma ^( Bme & Bmi ); \
229
+ E##me = Bme ^( Bmi | Bmo ); \
230
+ E##mi = Bmi ^((~Bmo)| Bmu ); \
231
+ E##mo = (~Bmo)^( Bmu & Bma ); \
232
+ E##mu = Bmu ^( Bma | Bme ); \
233
+ \
234
+ A##bi ^= Di; \
235
+ Bsa = ROL64(A##bi, 62); \
236
+ A##go ^= Do; \
237
+ Bse = ROL64(A##go, 55); \
238
+ A##ku ^= Du; \
239
+ Bsi = ROL64(A##ku, 39); \
240
+ A##ma ^= Da; \
241
+ Bso = ROL64(A##ma, 41); \
242
+ A##se ^= De; \
243
+ Bsu = ROL64(A##se, 2); \
244
+ E##sa = Bsa ^((~Bse)& Bsi ); \
245
+ E##se = (~Bse)^( Bsi | Bso ); \
246
+ E##si = Bsi ^( Bso & Bsu ); \
247
+ E##so = Bso ^( Bsu | Bsa ); \
248
+ E##su = Bsu ^( Bsa & Bse ); \
249
+ \
250
+
251
+ #else /* UseBebigokimisa */
252
+ /* --- Code for round, with prepare-theta */
253
+ /* --- 64-bit lanes mapped to 64-bit words */
254
+ #define thetaRhoPiChiIotaPrepareTheta(i, A, E) \
255
+ Da = Cu^ROL64(Ce, 1); \
256
+ De = Ca^ROL64(Ci, 1); \
257
+ Di = Ce^ROL64(Co, 1); \
258
+ Do = Ci^ROL64(Cu, 1); \
259
+ Du = Co^ROL64(Ca, 1); \
260
+ \
261
+ A##ba ^= Da; \
262
+ Bba = A##ba; \
263
+ A##ge ^= De; \
264
+ Bbe = ROL64(A##ge, 44); \
265
+ A##ki ^= Di; \
266
+ Bbi = ROL64(A##ki, 43); \
267
+ A##mo ^= Do; \
268
+ Bbo = ROL64(A##mo, 21); \
269
+ A##su ^= Du; \
270
+ Bbu = ROL64(A##su, 14); \
271
+ E##ba = Bba ^((~Bbe)& Bbi ); \
272
+ E##ba ^= KeccakF1600RoundConstants[i]; \
273
+ Ca = E##ba; \
274
+ E##be = Bbe ^((~Bbi)& Bbo ); \
275
+ Ce = E##be; \
276
+ E##bi = Bbi ^((~Bbo)& Bbu ); \
277
+ Ci = E##bi; \
278
+ E##bo = Bbo ^((~Bbu)& Bba ); \
279
+ Co = E##bo; \
280
+ E##bu = Bbu ^((~Bba)& Bbe ); \
281
+ Cu = E##bu; \
282
+ \
283
+ A##bo ^= Do; \
284
+ Bga = ROL64(A##bo, 28); \
285
+ A##gu ^= Du; \
286
+ Bge = ROL64(A##gu, 20); \
287
+ A##ka ^= Da; \
288
+ Bgi = ROL64(A##ka, 3); \
289
+ A##me ^= De; \
290
+ Bgo = ROL64(A##me, 45); \
291
+ A##si ^= Di; \
292
+ Bgu = ROL64(A##si, 61); \
293
+ E##ga = Bga ^((~Bge)& Bgi ); \
294
+ Ca ^= E##ga; \
295
+ E##ge = Bge ^((~Bgi)& Bgo ); \
296
+ Ce ^= E##ge; \
297
+ E##gi = Bgi ^((~Bgo)& Bgu ); \
298
+ Ci ^= E##gi; \
299
+ E##go = Bgo ^((~Bgu)& Bga ); \
300
+ Co ^= E##go; \
301
+ E##gu = Bgu ^((~Bga)& Bge ); \
302
+ Cu ^= E##gu; \
303
+ \
304
+ A##be ^= De; \
305
+ Bka = ROL64(A##be, 1); \
306
+ A##gi ^= Di; \
307
+ Bke = ROL64(A##gi, 6); \
308
+ A##ko ^= Do; \
309
+ Bki = ROL64(A##ko, 25); \
310
+ A##mu ^= Du; \
311
+ Bko = ROL64(A##mu, 8); \
312
+ A##sa ^= Da; \
313
+ Bku = ROL64(A##sa, 18); \
314
+ E##ka = Bka ^((~Bke)& Bki ); \
315
+ Ca ^= E##ka; \
316
+ E##ke = Bke ^((~Bki)& Bko ); \
317
+ Ce ^= E##ke; \
318
+ E##ki = Bki ^((~Bko)& Bku ); \
319
+ Ci ^= E##ki; \
320
+ E##ko = Bko ^((~Bku)& Bka ); \
321
+ Co ^= E##ko; \
322
+ E##ku = Bku ^((~Bka)& Bke ); \
323
+ Cu ^= E##ku; \
324
+ \
325
+ A##bu ^= Du; \
326
+ Bma = ROL64(A##bu, 27); \
327
+ A##ga ^= Da; \
328
+ Bme = ROL64(A##ga, 36); \
329
+ A##ke ^= De; \
330
+ Bmi = ROL64(A##ke, 10); \
331
+ A##mi ^= Di; \
332
+ Bmo = ROL64(A##mi, 15); \
333
+ A##so ^= Do; \
334
+ Bmu = ROL64(A##so, 56); \
335
+ E##ma = Bma ^((~Bme)& Bmi ); \
336
+ Ca ^= E##ma; \
337
+ E##me = Bme ^((~Bmi)& Bmo ); \
338
+ Ce ^= E##me; \
339
+ E##mi = Bmi ^((~Bmo)& Bmu ); \
340
+ Ci ^= E##mi; \
341
+ E##mo = Bmo ^((~Bmu)& Bma ); \
342
+ Co ^= E##mo; \
343
+ E##mu = Bmu ^((~Bma)& Bme ); \
344
+ Cu ^= E##mu; \
345
+ \
346
+ A##bi ^= Di; \
347
+ Bsa = ROL64(A##bi, 62); \
348
+ A##go ^= Do; \
349
+ Bse = ROL64(A##go, 55); \
350
+ A##ku ^= Du; \
351
+ Bsi = ROL64(A##ku, 39); \
352
+ A##ma ^= Da; \
353
+ Bso = ROL64(A##ma, 41); \
354
+ A##se ^= De; \
355
+ Bsu = ROL64(A##se, 2); \
356
+ E##sa = Bsa ^((~Bse)& Bsi ); \
357
+ Ca ^= E##sa; \
358
+ E##se = Bse ^((~Bsi)& Bso ); \
359
+ Ce ^= E##se; \
360
+ E##si = Bsi ^((~Bso)& Bsu ); \
361
+ Ci ^= E##si; \
362
+ E##so = Bso ^((~Bsu)& Bsa ); \
363
+ Co ^= E##so; \
364
+ E##su = Bsu ^((~Bsa)& Bse ); \
365
+ Cu ^= E##su; \
366
+ \
367
+
368
+ /* --- Code for round */
369
+ /* --- 64-bit lanes mapped to 64-bit words */
370
+ #define thetaRhoPiChiIota(i, A, E) \
371
+ Da = Cu^ROL64(Ce, 1); \
372
+ De = Ca^ROL64(Ci, 1); \
373
+ Di = Ce^ROL64(Co, 1); \
374
+ Do = Ci^ROL64(Cu, 1); \
375
+ Du = Co^ROL64(Ca, 1); \
376
+ \
377
+ A##ba ^= Da; \
378
+ Bba = A##ba; \
379
+ A##ge ^= De; \
380
+ Bbe = ROL64(A##ge, 44); \
381
+ A##ki ^= Di; \
382
+ Bbi = ROL64(A##ki, 43); \
383
+ A##mo ^= Do; \
384
+ Bbo = ROL64(A##mo, 21); \
385
+ A##su ^= Du; \
386
+ Bbu = ROL64(A##su, 14); \
387
+ E##ba = Bba ^((~Bbe)& Bbi ); \
388
+ E##ba ^= KeccakF1600RoundConstants[i]; \
389
+ E##be = Bbe ^((~Bbi)& Bbo ); \
390
+ E##bi = Bbi ^((~Bbo)& Bbu ); \
391
+ E##bo = Bbo ^((~Bbu)& Bba ); \
392
+ E##bu = Bbu ^((~Bba)& Bbe ); \
393
+ \
394
+ A##bo ^= Do; \
395
+ Bga = ROL64(A##bo, 28); \
396
+ A##gu ^= Du; \
397
+ Bge = ROL64(A##gu, 20); \
398
+ A##ka ^= Da; \
399
+ Bgi = ROL64(A##ka, 3); \
400
+ A##me ^= De; \
401
+ Bgo = ROL64(A##me, 45); \
402
+ A##si ^= Di; \
403
+ Bgu = ROL64(A##si, 61); \
404
+ E##ga = Bga ^((~Bge)& Bgi ); \
405
+ E##ge = Bge ^((~Bgi)& Bgo ); \
406
+ E##gi = Bgi ^((~Bgo)& Bgu ); \
407
+ E##go = Bgo ^((~Bgu)& Bga ); \
408
+ E##gu = Bgu ^((~Bga)& Bge ); \
409
+ \
410
+ A##be ^= De; \
411
+ Bka = ROL64(A##be, 1); \
412
+ A##gi ^= Di; \
413
+ Bke = ROL64(A##gi, 6); \
414
+ A##ko ^= Do; \
415
+ Bki = ROL64(A##ko, 25); \
416
+ A##mu ^= Du; \
417
+ Bko = ROL64(A##mu, 8); \
418
+ A##sa ^= Da; \
419
+ Bku = ROL64(A##sa, 18); \
420
+ E##ka = Bka ^((~Bke)& Bki ); \
421
+ E##ke = Bke ^((~Bki)& Bko ); \
422
+ E##ki = Bki ^((~Bko)& Bku ); \
423
+ E##ko = Bko ^((~Bku)& Bka ); \
424
+ E##ku = Bku ^((~Bka)& Bke ); \
425
+ \
426
+ A##bu ^= Du; \
427
+ Bma = ROL64(A##bu, 27); \
428
+ A##ga ^= Da; \
429
+ Bme = ROL64(A##ga, 36); \
430
+ A##ke ^= De; \
431
+ Bmi = ROL64(A##ke, 10); \
432
+ A##mi ^= Di; \
433
+ Bmo = ROL64(A##mi, 15); \
434
+ A##so ^= Do; \
435
+ Bmu = ROL64(A##so, 56); \
436
+ E##ma = Bma ^((~Bme)& Bmi ); \
437
+ E##me = Bme ^((~Bmi)& Bmo ); \
438
+ E##mi = Bmi ^((~Bmo)& Bmu ); \
439
+ E##mo = Bmo ^((~Bmu)& Bma ); \
440
+ E##mu = Bmu ^((~Bma)& Bme ); \
441
+ \
442
+ A##bi ^= Di; \
443
+ Bsa = ROL64(A##bi, 62); \
444
+ A##go ^= Do; \
445
+ Bse = ROL64(A##go, 55); \
446
+ A##ku ^= Du; \
447
+ Bsi = ROL64(A##ku, 39); \
448
+ A##ma ^= Da; \
449
+ Bso = ROL64(A##ma, 41); \
450
+ A##se ^= De; \
451
+ Bsu = ROL64(A##se, 2); \
452
+ E##sa = Bsa ^((~Bse)& Bsi ); \
453
+ E##se = Bse ^((~Bsi)& Bso ); \
454
+ E##si = Bsi ^((~Bso)& Bsu ); \
455
+ E##so = Bso ^((~Bsu)& Bsa ); \
456
+ E##su = Bsu ^((~Bsa)& Bse ); \
457
+ \
458
+
459
+ #endif /* UseBebigokimisa */
460
+
461
+ #define copyFromState(X, state) \
462
+ X##ba = state[ 0]; \
463
+ X##be = state[ 1]; \
464
+ X##bi = state[ 2]; \
465
+ X##bo = state[ 3]; \
466
+ X##bu = state[ 4]; \
467
+ X##ga = state[ 5]; \
468
+ X##ge = state[ 6]; \
469
+ X##gi = state[ 7]; \
470
+ X##go = state[ 8]; \
471
+ X##gu = state[ 9]; \
472
+ X##ka = state[10]; \
473
+ X##ke = state[11]; \
474
+ X##ki = state[12]; \
475
+ X##ko = state[13]; \
476
+ X##ku = state[14]; \
477
+ X##ma = state[15]; \
478
+ X##me = state[16]; \
479
+ X##mi = state[17]; \
480
+ X##mo = state[18]; \
481
+ X##mu = state[19]; \
482
+ X##sa = state[20]; \
483
+ X##se = state[21]; \
484
+ X##si = state[22]; \
485
+ X##so = state[23]; \
486
+ X##su = state[24]; \
487
+
488
+ #define copyToState(state, X) \
489
+ state[ 0] = X##ba; \
490
+ state[ 1] = X##be; \
491
+ state[ 2] = X##bi; \
492
+ state[ 3] = X##bo; \
493
+ state[ 4] = X##bu; \
494
+ state[ 5] = X##ga; \
495
+ state[ 6] = X##ge; \
496
+ state[ 7] = X##gi; \
497
+ state[ 8] = X##go; \
498
+ state[ 9] = X##gu; \
499
+ state[10] = X##ka; \
500
+ state[11] = X##ke; \
501
+ state[12] = X##ki; \
502
+ state[13] = X##ko; \
503
+ state[14] = X##ku; \
504
+ state[15] = X##ma; \
505
+ state[16] = X##me; \
506
+ state[17] = X##mi; \
507
+ state[18] = X##mo; \
508
+ state[19] = X##mu; \
509
+ state[20] = X##sa; \
510
+ state[21] = X##se; \
511
+ state[22] = X##si; \
512
+ state[23] = X##so; \
513
+ state[24] = X##su; \
514
+
515
+ #define copyStateVariables(X, Y) \
516
+ X##ba = Y##ba; \
517
+ X##be = Y##be; \
518
+ X##bi = Y##bi; \
519
+ X##bo = Y##bo; \
520
+ X##bu = Y##bu; \
521
+ X##ga = Y##ga; \
522
+ X##ge = Y##ge; \
523
+ X##gi = Y##gi; \
524
+ X##go = Y##go; \
525
+ X##gu = Y##gu; \
526
+ X##ka = Y##ka; \
527
+ X##ke = Y##ke; \
528
+ X##ki = Y##ki; \
529
+ X##ko = Y##ko; \
530
+ X##ku = Y##ku; \
531
+ X##ma = Y##ma; \
532
+ X##me = Y##me; \
533
+ X##mi = Y##mi; \
534
+ X##mo = Y##mo; \
535
+ X##mu = Y##mu; \
536
+ X##sa = Y##sa; \
537
+ X##se = Y##se; \
538
+ X##si = Y##si; \
539
+ X##so = Y##so; \
540
+ X##su = Y##su; \
541
+
542
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
543
+ #define HTOLE64(x) (x)
544
+ #else
545
+ #define HTOLE64(x) (\
546
+ ((x & 0xff00000000000000ull) >> 56) | \
547
+ ((x & 0x00ff000000000000ull) >> 40) | \
548
+ ((x & 0x0000ff0000000000ull) >> 24) | \
549
+ ((x & 0x000000ff00000000ull) >> 8) | \
550
+ ((x & 0x00000000ff000000ull) << 8) | \
551
+ ((x & 0x0000000000ff0000ull) << 24) | \
552
+ ((x & 0x000000000000ff00ull) << 40) | \
553
+ ((x & 0x00000000000000ffull) << 56))
554
+ #endif
555
+
556
+ #define addInput(X, input, laneCount) \
557
+ if (laneCount == 21) { \
558
+ X##ba ^= HTOLE64(input[ 0]); \
559
+ X##be ^= HTOLE64(input[ 1]); \
560
+ X##bi ^= HTOLE64(input[ 2]); \
561
+ X##bo ^= HTOLE64(input[ 3]); \
562
+ X##bu ^= HTOLE64(input[ 4]); \
563
+ X##ga ^= HTOLE64(input[ 5]); \
564
+ X##ge ^= HTOLE64(input[ 6]); \
565
+ X##gi ^= HTOLE64(input[ 7]); \
566
+ X##go ^= HTOLE64(input[ 8]); \
567
+ X##gu ^= HTOLE64(input[ 9]); \
568
+ X##ka ^= HTOLE64(input[10]); \
569
+ X##ke ^= HTOLE64(input[11]); \
570
+ X##ki ^= HTOLE64(input[12]); \
571
+ X##ko ^= HTOLE64(input[13]); \
572
+ X##ku ^= HTOLE64(input[14]); \
573
+ X##ma ^= HTOLE64(input[15]); \
574
+ X##me ^= HTOLE64(input[16]); \
575
+ X##mi ^= HTOLE64(input[17]); \
576
+ X##mo ^= HTOLE64(input[18]); \
577
+ X##mu ^= HTOLE64(input[19]); \
578
+ X##sa ^= HTOLE64(input[20]); \
579
+ } \
580
+ else if (laneCount < 16) { \
581
+ if (laneCount < 8) { \
582
+ if (laneCount < 4) { \
583
+ if (laneCount < 2) { \
584
+ if (laneCount < 1) { \
585
+ } \
586
+ else { \
587
+ X##ba ^= HTOLE64(input[ 0]); \
588
+ } \
589
+ } \
590
+ else { \
591
+ X##ba ^= HTOLE64(input[ 0]); \
592
+ X##be ^= HTOLE64(input[ 1]); \
593
+ if (laneCount < 3) { \
594
+ } \
595
+ else { \
596
+ X##bi ^= HTOLE64(input[ 2]); \
597
+ } \
598
+ } \
599
+ } \
600
+ else { \
601
+ X##ba ^= HTOLE64(input[ 0]); \
602
+ X##be ^= HTOLE64(input[ 1]); \
603
+ X##bi ^= HTOLE64(input[ 2]); \
604
+ X##bo ^= HTOLE64(input[ 3]); \
605
+ if (laneCount < 6) { \
606
+ if (laneCount < 5) { \
607
+ } \
608
+ else { \
609
+ X##bu ^= HTOLE64(input[ 4]); \
610
+ } \
611
+ } \
612
+ else { \
613
+ X##bu ^= HTOLE64(input[ 4]); \
614
+ X##ga ^= HTOLE64(input[ 5]); \
615
+ if (laneCount < 7) { \
616
+ } \
617
+ else { \
618
+ X##ge ^= HTOLE64(input[ 6]); \
619
+ } \
620
+ } \
621
+ } \
622
+ } \
623
+ else { \
624
+ X##ba ^= HTOLE64(input[ 0]); \
625
+ X##be ^= HTOLE64(input[ 1]); \
626
+ X##bi ^= HTOLE64(input[ 2]); \
627
+ X##bo ^= HTOLE64(input[ 3]); \
628
+ X##bu ^= HTOLE64(input[ 4]); \
629
+ X##ga ^= HTOLE64(input[ 5]); \
630
+ X##ge ^= HTOLE64(input[ 6]); \
631
+ X##gi ^= HTOLE64(input[ 7]); \
632
+ if (laneCount < 12) { \
633
+ if (laneCount < 10) { \
634
+ if (laneCount < 9) { \
635
+ } \
636
+ else { \
637
+ X##go ^= HTOLE64(input[ 8]); \
638
+ } \
639
+ } \
640
+ else { \
641
+ X##go ^= HTOLE64(input[ 8]); \
642
+ X##gu ^= HTOLE64(input[ 9]); \
643
+ if (laneCount < 11) { \
644
+ } \
645
+ else { \
646
+ X##ka ^= HTOLE64(input[10]); \
647
+ } \
648
+ } \
649
+ } \
650
+ else { \
651
+ X##go ^= HTOLE64(input[ 8]); \
652
+ X##gu ^= HTOLE64(input[ 9]); \
653
+ X##ka ^= HTOLE64(input[10]); \
654
+ X##ke ^= HTOLE64(input[11]); \
655
+ if (laneCount < 14) { \
656
+ if (laneCount < 13) { \
657
+ } \
658
+ else { \
659
+ X##ki ^= HTOLE64(input[12]); \
660
+ } \
661
+ } \
662
+ else { \
663
+ X##ki ^= HTOLE64(input[12]); \
664
+ X##ko ^= HTOLE64(input[13]); \
665
+ if (laneCount < 15) { \
666
+ } \
667
+ else { \
668
+ X##ku ^= HTOLE64(input[14]); \
669
+ } \
670
+ } \
671
+ } \
672
+ } \
673
+ } \
674
+ else { \
675
+ X##ba ^= HTOLE64(input[ 0]); \
676
+ X##be ^= HTOLE64(input[ 1]); \
677
+ X##bi ^= HTOLE64(input[ 2]); \
678
+ X##bo ^= HTOLE64(input[ 3]); \
679
+ X##bu ^= HTOLE64(input[ 4]); \
680
+ X##ga ^= HTOLE64(input[ 5]); \
681
+ X##ge ^= HTOLE64(input[ 6]); \
682
+ X##gi ^= HTOLE64(input[ 7]); \
683
+ X##go ^= HTOLE64(input[ 8]); \
684
+ X##gu ^= HTOLE64(input[ 9]); \
685
+ X##ka ^= HTOLE64(input[10]); \
686
+ X##ke ^= HTOLE64(input[11]); \
687
+ X##ki ^= HTOLE64(input[12]); \
688
+ X##ko ^= HTOLE64(input[13]); \
689
+ X##ku ^= HTOLE64(input[14]); \
690
+ X##ma ^= HTOLE64(input[15]); \
691
+ if (laneCount < 24) { \
692
+ if (laneCount < 20) { \
693
+ if (laneCount < 18) { \
694
+ if (laneCount < 17) { \
695
+ } \
696
+ else { \
697
+ X##me ^= HTOLE64(input[16]); \
698
+ } \
699
+ } \
700
+ else { \
701
+ X##me ^= HTOLE64(input[16]); \
702
+ X##mi ^= HTOLE64(input[17]); \
703
+ if (laneCount < 19) { \
704
+ } \
705
+ else { \
706
+ X##mo ^= HTOLE64(input[18]); \
707
+ } \
708
+ } \
709
+ } \
710
+ else { \
711
+ X##me ^= HTOLE64(input[16]); \
712
+ X##mi ^= HTOLE64(input[17]); \
713
+ X##mo ^= HTOLE64(input[18]); \
714
+ X##mu ^= HTOLE64(input[19]); \
715
+ if (laneCount < 22) { \
716
+ if (laneCount < 21) { \
717
+ } \
718
+ else { \
719
+ X##sa ^= HTOLE64(input[20]); \
720
+ } \
721
+ } \
722
+ else { \
723
+ X##sa ^= HTOLE64(input[20]); \
724
+ X##se ^= HTOLE64(input[21]); \
725
+ if (laneCount < 23) { \
726
+ } \
727
+ else { \
728
+ X##si ^= HTOLE64(input[22]); \
729
+ } \
730
+ } \
731
+ } \
732
+ } \
733
+ else { \
734
+ X##me ^= HTOLE64(input[16]); \
735
+ X##mi ^= HTOLE64(input[17]); \
736
+ X##mo ^= HTOLE64(input[18]); \
737
+ X##mu ^= HTOLE64(input[19]); \
738
+ X##sa ^= HTOLE64(input[20]); \
739
+ X##se ^= HTOLE64(input[21]); \
740
+ X##si ^= HTOLE64(input[22]); \
741
+ X##so ^= HTOLE64(input[23]); \
742
+ if (laneCount < 25) { \
743
+ } \
744
+ else { \
745
+ X##su ^= HTOLE64(input[24]); \
746
+ } \
747
+ } \
748
+ }