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,305 @@
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
+ #if (defined(FullUnrolling))
18
+ #define rounds24 \
19
+ prepareTheta \
20
+ thetaRhoPiChiIotaPrepareTheta( 0, A, E) \
21
+ thetaRhoPiChiIotaPrepareTheta( 1, E, A) \
22
+ thetaRhoPiChiIotaPrepareTheta( 2, A, E) \
23
+ thetaRhoPiChiIotaPrepareTheta( 3, E, A) \
24
+ thetaRhoPiChiIotaPrepareTheta( 4, A, E) \
25
+ thetaRhoPiChiIotaPrepareTheta( 5, E, A) \
26
+ thetaRhoPiChiIotaPrepareTheta( 6, A, E) \
27
+ thetaRhoPiChiIotaPrepareTheta( 7, E, A) \
28
+ thetaRhoPiChiIotaPrepareTheta( 8, A, E) \
29
+ thetaRhoPiChiIotaPrepareTheta( 9, E, A) \
30
+ thetaRhoPiChiIotaPrepareTheta(10, A, E) \
31
+ thetaRhoPiChiIotaPrepareTheta(11, E, A) \
32
+ thetaRhoPiChiIotaPrepareTheta(12, A, E) \
33
+ thetaRhoPiChiIotaPrepareTheta(13, E, A) \
34
+ thetaRhoPiChiIotaPrepareTheta(14, A, E) \
35
+ thetaRhoPiChiIotaPrepareTheta(15, E, A) \
36
+ thetaRhoPiChiIotaPrepareTheta(16, A, E) \
37
+ thetaRhoPiChiIotaPrepareTheta(17, E, A) \
38
+ thetaRhoPiChiIotaPrepareTheta(18, A, E) \
39
+ thetaRhoPiChiIotaPrepareTheta(19, E, A) \
40
+ thetaRhoPiChiIotaPrepareTheta(20, A, E) \
41
+ thetaRhoPiChiIotaPrepareTheta(21, E, A) \
42
+ thetaRhoPiChiIotaPrepareTheta(22, A, E) \
43
+ thetaRhoPiChiIota(23, E, A) \
44
+
45
+ #define rounds12 \
46
+ prepareTheta \
47
+ thetaRhoPiChiIotaPrepareTheta(12, A, E) \
48
+ thetaRhoPiChiIotaPrepareTheta(13, E, A) \
49
+ thetaRhoPiChiIotaPrepareTheta(14, A, E) \
50
+ thetaRhoPiChiIotaPrepareTheta(15, E, A) \
51
+ thetaRhoPiChiIotaPrepareTheta(16, A, E) \
52
+ thetaRhoPiChiIotaPrepareTheta(17, E, A) \
53
+ thetaRhoPiChiIotaPrepareTheta(18, A, E) \
54
+ thetaRhoPiChiIotaPrepareTheta(19, E, A) \
55
+ thetaRhoPiChiIotaPrepareTheta(20, A, E) \
56
+ thetaRhoPiChiIotaPrepareTheta(21, E, A) \
57
+ thetaRhoPiChiIotaPrepareTheta(22, A, E) \
58
+ thetaRhoPiChiIota(23, E, A) \
59
+
60
+ #define rounds6 \
61
+ prepareTheta \
62
+ thetaRhoPiChiIotaPrepareTheta(18, A, E) \
63
+ thetaRhoPiChiIotaPrepareTheta(19, E, A) \
64
+ thetaRhoPiChiIotaPrepareTheta(20, A, E) \
65
+ thetaRhoPiChiIotaPrepareTheta(21, E, A) \
66
+ thetaRhoPiChiIotaPrepareTheta(22, A, E) \
67
+ thetaRhoPiChiIota(23, E, A) \
68
+
69
+ #define rounds4 \
70
+ prepareTheta \
71
+ thetaRhoPiChiIotaPrepareTheta(20, A, E) \
72
+ thetaRhoPiChiIotaPrepareTheta(21, E, A) \
73
+ thetaRhoPiChiIotaPrepareTheta(22, A, E) \
74
+ thetaRhoPiChiIota(23, E, A) \
75
+
76
+ #elif (Unrolling == 12)
77
+ #define rounds24 \
78
+ prepareTheta \
79
+ for(i=0; i<24; i+=12) { \
80
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
81
+ thetaRhoPiChiIotaPrepareTheta(i+ 1, E, A) \
82
+ thetaRhoPiChiIotaPrepareTheta(i+ 2, A, E) \
83
+ thetaRhoPiChiIotaPrepareTheta(i+ 3, E, A) \
84
+ thetaRhoPiChiIotaPrepareTheta(i+ 4, A, E) \
85
+ thetaRhoPiChiIotaPrepareTheta(i+ 5, E, A) \
86
+ thetaRhoPiChiIotaPrepareTheta(i+ 6, A, E) \
87
+ thetaRhoPiChiIotaPrepareTheta(i+ 7, E, A) \
88
+ thetaRhoPiChiIotaPrepareTheta(i+ 8, A, E) \
89
+ thetaRhoPiChiIotaPrepareTheta(i+ 9, E, A) \
90
+ thetaRhoPiChiIotaPrepareTheta(i+10, A, E) \
91
+ thetaRhoPiChiIotaPrepareTheta(i+11, E, A) \
92
+ } \
93
+
94
+ #define rounds12 \
95
+ prepareTheta \
96
+ thetaRhoPiChiIotaPrepareTheta(12, A, E) \
97
+ thetaRhoPiChiIotaPrepareTheta(13, E, A) \
98
+ thetaRhoPiChiIotaPrepareTheta(14, A, E) \
99
+ thetaRhoPiChiIotaPrepareTheta(15, E, A) \
100
+ thetaRhoPiChiIotaPrepareTheta(16, A, E) \
101
+ thetaRhoPiChiIotaPrepareTheta(17, E, A) \
102
+ thetaRhoPiChiIotaPrepareTheta(18, A, E) \
103
+ thetaRhoPiChiIotaPrepareTheta(19, E, A) \
104
+ thetaRhoPiChiIotaPrepareTheta(20, A, E) \
105
+ thetaRhoPiChiIotaPrepareTheta(21, E, A) \
106
+ thetaRhoPiChiIotaPrepareTheta(22, A, E) \
107
+ thetaRhoPiChiIota(23, E, A) \
108
+
109
+ #define rounds6 \
110
+ prepareTheta \
111
+ thetaRhoPiChiIotaPrepareTheta(18, A, E) \
112
+ thetaRhoPiChiIotaPrepareTheta(19, E, A) \
113
+ thetaRhoPiChiIotaPrepareTheta(20, A, E) \
114
+ thetaRhoPiChiIotaPrepareTheta(21, E, A) \
115
+ thetaRhoPiChiIotaPrepareTheta(22, A, E) \
116
+ thetaRhoPiChiIota(23, E, A) \
117
+
118
+ #define rounds4 \
119
+ prepareTheta \
120
+ thetaRhoPiChiIotaPrepareTheta(20, A, E) \
121
+ thetaRhoPiChiIotaPrepareTheta(21, E, A) \
122
+ thetaRhoPiChiIotaPrepareTheta(22, A, E) \
123
+ thetaRhoPiChiIota(23, E, A) \
124
+
125
+ #elif (Unrolling == 6)
126
+ #define rounds24 \
127
+ prepareTheta \
128
+ for(i=0; i<24; i+=6) { \
129
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
130
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
131
+ thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
132
+ thetaRhoPiChiIotaPrepareTheta(i+3, E, A) \
133
+ thetaRhoPiChiIotaPrepareTheta(i+4, A, E) \
134
+ thetaRhoPiChiIotaPrepareTheta(i+5, E, A) \
135
+ } \
136
+
137
+ #define rounds12 \
138
+ prepareTheta \
139
+ for(i=12; i<24; i+=6) { \
140
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
141
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
142
+ thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
143
+ thetaRhoPiChiIotaPrepareTheta(i+3, E, A) \
144
+ thetaRhoPiChiIotaPrepareTheta(i+4, A, E) \
145
+ thetaRhoPiChiIotaPrepareTheta(i+5, E, A) \
146
+ } \
147
+
148
+ #define rounds6 \
149
+ prepareTheta \
150
+ thetaRhoPiChiIotaPrepareTheta(18, A, E) \
151
+ thetaRhoPiChiIotaPrepareTheta(19, E, A) \
152
+ thetaRhoPiChiIotaPrepareTheta(20, A, E) \
153
+ thetaRhoPiChiIotaPrepareTheta(21, E, A) \
154
+ thetaRhoPiChiIotaPrepareTheta(22, A, E) \
155
+ thetaRhoPiChiIota(23, E, A) \
156
+
157
+ #define rounds4 \
158
+ prepareTheta \
159
+ thetaRhoPiChiIotaPrepareTheta(20, A, E) \
160
+ thetaRhoPiChiIotaPrepareTheta(21, E, A) \
161
+ thetaRhoPiChiIotaPrepareTheta(22, A, E) \
162
+ thetaRhoPiChiIota(23, E, A) \
163
+
164
+ #elif (Unrolling == 4)
165
+ #define rounds24 \
166
+ prepareTheta \
167
+ for(i=0; i<24; i+=4) { \
168
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
169
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
170
+ thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
171
+ thetaRhoPiChiIotaPrepareTheta(i+3, E, A) \
172
+ } \
173
+
174
+ #define rounds12 \
175
+ prepareTheta \
176
+ for(i=12; i<24; i+=4) { \
177
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
178
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
179
+ thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
180
+ thetaRhoPiChiIotaPrepareTheta(i+3, E, A) \
181
+ } \
182
+
183
+ #define rounds6 \
184
+ prepareTheta \
185
+ for(i=18; i<24; i+=2) { \
186
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
187
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
188
+ } \
189
+
190
+ #define rounds4 \
191
+ prepareTheta \
192
+ thetaRhoPiChiIotaPrepareTheta(20, A, E) \
193
+ thetaRhoPiChiIotaPrepareTheta(21, E, A) \
194
+ thetaRhoPiChiIotaPrepareTheta(22, A, E) \
195
+ thetaRhoPiChiIota(23, E, A) \
196
+
197
+ #elif (Unrolling == 3)
198
+ #define rounds24 \
199
+ prepareTheta \
200
+ for(i=0; i<24; i+=3) { \
201
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
202
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
203
+ thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
204
+ copyStateVariables(A, E) \
205
+ } \
206
+
207
+ #define rounds12 \
208
+ prepareTheta \
209
+ for(i=12; i<24; i+=3) { \
210
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
211
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
212
+ thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
213
+ copyStateVariables(A, E) \
214
+ } \
215
+
216
+ #define rounds6 \
217
+ prepareTheta \
218
+ for(i=18; i<24; i+=3) { \
219
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
220
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
221
+ thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
222
+ copyStateVariables(A, E) \
223
+ } \
224
+
225
+ #define rounds4 \
226
+ prepareTheta \
227
+ for(i=20; i<24; i+=2) { \
228
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
229
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
230
+ } \
231
+
232
+ #elif (Unrolling == 2)
233
+ #define rounds24 \
234
+ prepareTheta \
235
+ for(i=0; i<24; i+=2) { \
236
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
237
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
238
+ } \
239
+
240
+ #define rounds12 \
241
+ prepareTheta \
242
+ for(i=12; i<24; i+=2) { \
243
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
244
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
245
+ } \
246
+
247
+ #define rounds6 \
248
+ prepareTheta \
249
+ for(i=18; i<24; i+=2) { \
250
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
251
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
252
+ } \
253
+
254
+ #define rounds4 \
255
+ prepareTheta \
256
+ for(i=20; i<24; i+=2) { \
257
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
258
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
259
+ } \
260
+
261
+ #elif (Unrolling == 1)
262
+ #define rounds24 \
263
+ prepareTheta \
264
+ for(i=0; i<24; i++) { \
265
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
266
+ copyStateVariables(A, E) \
267
+ } \
268
+
269
+ #define rounds12 \
270
+ prepareTheta \
271
+ for(i=12; i<24; i++) { \
272
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
273
+ copyStateVariables(A, E) \
274
+ } \
275
+
276
+ #define rounds6 \
277
+ prepareTheta \
278
+ for(i=18; i<24; i++) { \
279
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
280
+ copyStateVariables(A, E) \
281
+ } \
282
+
283
+ #define rounds4 \
284
+ prepareTheta \
285
+ for(i=20; i<24; i++) { \
286
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
287
+ copyStateVariables(A, E) \
288
+ } \
289
+
290
+ #else
291
+ #error "Unrolling is not correctly specified!"
292
+ #endif
293
+
294
+ #define roundsN(__nrounds) \
295
+ prepareTheta \
296
+ i = 24 - (__nrounds); \
297
+ if ((i&1) != 0) { \
298
+ thetaRhoPiChiIotaPrepareTheta(i, A, E) \
299
+ copyStateVariables(A, E) \
300
+ ++i; \
301
+ } \
302
+ for( /* empty */; i<24; i+=2) { \
303
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
304
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
305
+ }
@@ -0,0 +1,44 @@
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 the designers, 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
+
18
+ Please refer to SnP-documentation.h for more details.
19
+ */
20
+
21
+ #ifndef _KeccakP_1600_SnP_h_
22
+ #define _KeccakP_1600_SnP_h_
23
+
24
+ #define KeccakP1600_implementation "32-bit bit-interleaved reference implementation"
25
+ #define KeccakP1600_stateSizeInBytes 200
26
+ #define KeccakP1600_stateAlignment 4
27
+
28
+ #ifdef KeccakReference
29
+ void KeccakP1600_StaticInitialize( void );
30
+ #else
31
+ #define KeccakP1600_StaticInitialize()
32
+ #endif
33
+ void KeccakP1600_Initialize(void *state);
34
+ void KeccakP1600_AddByte(void *state, unsigned char data, unsigned int offset);
35
+ void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
36
+ void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
37
+ void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount);
38
+ void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds);
39
+ void KeccakP1600_Permute_12rounds(void *state);
40
+ void KeccakP1600_Permute_24rounds(void *state);
41
+ void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length);
42
+ void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length);
43
+
44
+ #endif
@@ -0,0 +1,23 @@
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 the designers, 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
+ #ifndef _KeccakP_1600_reference_h_
18
+ #define _KeccakP_1600_reference_h_
19
+
20
+ void KeccakP1600_DisplayRoundConstants(FILE *f);
21
+ void KeccakP1600_DisplayRhoOffsets(FILE *f);
22
+
23
+ #endif