digest-kangarootwelve 0.4.6 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/digest-kangarootwelve.gemspec +1 -1
- data/ext/digest/kangarootwelve/.sitearchdir.-.digest.time +0 -0
- data/ext/digest/kangarootwelve/XKCP/lib/high/KangarooTwelve/KangarooTwelve.c +32 -32
- data/ext/digest/kangarootwelve/XKCP/lib/high/KangarooTwelve/KangarooTwelve.h +5 -5
- data/ext/digest/kangarootwelve/XKCP/lib/high/Keccak/KeccakSponge.c +0 -18
- data/ext/digest/kangarootwelve/XKCP/lib/high/Keccak/KeccakSponge.h +0 -6
- data/ext/digest/kangarootwelve/XKCP/lib/high/TurboSHAKE/TurboSHAKE.c +71 -0
- data/ext/digest/kangarootwelve/XKCP/lib/high/TurboSHAKE/TurboSHAKE.h +49 -0
- data/ext/digest/kangarootwelve/XKCP/lib/low/KeccakP-1600/AVX2/KeccakP-1600-AVX2.s +0 -52
- data/ext/digest/kangarootwelve/XKCP/lib/low/KeccakP-1600/AVX512/KeccakP-1600-AVX512.s +0 -48
- data/ext/digest/kangarootwelve/XKCP/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros +19 -9
- data/ext/digest/kangarootwelve/XKCP/lib/low/common/PlSnP-Fallback.inc +3 -2
- data/ext/digest/kangarootwelve/ext.c +3 -1
- data/ext/digest/kangarootwelve/targets/armv6/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/armv6/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/armv6m/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/armv6m/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/armv7a/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/armv7a/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/armv7m/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/armv7m/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/armv8a/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/armv8a/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/avr8/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/avr8/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/avx/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/avx/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/avx2/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/avx2/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/avx2noasm/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/avx2noasm/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/avx512/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/avx512/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/avx512noasm/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/avx512noasm/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/compact/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/compact/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/config.h +1 -0
- data/ext/digest/kangarootwelve/targets/generic32/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/generic32/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/generic32lc/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/generic32lc/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/generic64/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/generic64/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/generic64lc/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/generic64lc/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/reference/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/reference/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/reference32bits/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/reference32bits/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/ssse3/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/ssse3/TurboSHAKE.h +1 -0
- data/ext/digest/kangarootwelve/targets/xop/TurboSHAKE.c +1 -0
- data/ext/digest/kangarootwelve/targets/xop/TurboSHAKE.h +1 -0
- data/lib/digest/kangarootwelve/version.rb +1 -1
- metadata +54 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a6cfce02fd762e9a160af1eec3255d54ed7dd489f10de784965377ae0d60998
|
4
|
+
data.tar.gz: 2d6f2ee7d596ea64c777af39cad590e3db405eadb2b2ffe03e1827c88741b114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7484d076de7e4d1a12604b6a5c48f277c60d3543a83b88aa98fa1b43fb6b4d66315b77978183ef6993e6cfaf512fbfaaf865cb2e470c638cb273747ee4799139
|
7
|
+
data.tar.gz: 7f6b97d95218498100afe513d254307ce5dad1cb3d8a0fb419cab422e53909e67d37b2f87a38fb6093ff4c6f0db9de3f72c8c38799d9fadcfefb03e34ece5e2d
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.require_paths = ["lib"]
|
39
39
|
|
40
40
|
spec.add_development_dependency "rake"
|
41
|
-
spec.add_development_dependency "rake-compiler", "~> 1.
|
41
|
+
spec.add_development_dependency "rake-compiler", "~> 1.2", ">= 1.2.3"
|
42
42
|
spec.add_development_dependency "minitest", "~> 5.8"
|
43
43
|
spec.add_development_dependency "nori"
|
44
44
|
spec.add_development_dependency "nokogiri"
|
File without changes
|
@@ -4,7 +4,7 @@ https://github.com/XKCP/XKCP
|
|
4
4
|
|
5
5
|
KangarooTwelve, designed by Guido Bertoni, Joan Daemen, Michaël Peeters, Gilles Van Assche, Ronny Van Keer and Benoît Viguier.
|
6
6
|
|
7
|
-
Implementation by Ronny Van Keer, hereby denoted as "the implementer".
|
7
|
+
Implementation by Gilles Van Assche and Ronny Van Keer, hereby denoted as "the implementer".
|
8
8
|
|
9
9
|
For more information, feedback or questions, please refer to the Keccak Team website:
|
10
10
|
https://keccak.team/
|
@@ -66,8 +66,8 @@ http://creativecommons.org/publicdomain/zero/1.0/
|
|
66
66
|
inLen -= Parallellism * chunkSize; \
|
67
67
|
ktInstance->blockNumber += Parallellism; \
|
68
68
|
KeccakP1600times##Parallellism##_ExtractLanesAll(states, intermediate, capacityInLanes, capacityInLanes ); \
|
69
|
-
if (
|
70
|
-
|
69
|
+
if (TurboSHAKE_Absorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
|
70
|
+
}
|
71
71
|
|
72
72
|
#define ParallelSpongeLoop( Parallellism ) \
|
73
73
|
while ( inLen >= Parallellism * chunkSize ) { \
|
@@ -95,8 +95,8 @@ http://creativecommons.org/publicdomain/zero/1.0/
|
|
95
95
|
inLen -= Parallellism * chunkSize; \
|
96
96
|
ktInstance->blockNumber += Parallellism; \
|
97
97
|
KeccakP1600times##Parallellism##_ExtractLanesAll(states, intermediate, capacityInLanes, capacityInLanes ); \
|
98
|
-
if (
|
99
|
-
|
98
|
+
if (TurboSHAKE_Absorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
|
99
|
+
}
|
100
100
|
|
101
101
|
#define ProcessLeaves( Parallellism ) \
|
102
102
|
while ( inLen >= Parallellism * chunkSize ) { \
|
@@ -106,15 +106,15 @@ http://creativecommons.org/publicdomain/zero/1.0/
|
|
106
106
|
input += Parallellism * chunkSize; \
|
107
107
|
inLen -= Parallellism * chunkSize; \
|
108
108
|
ktInstance->blockNumber += Parallellism; \
|
109
|
-
if (
|
109
|
+
if (TurboSHAKE_Absorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
|
110
110
|
}
|
111
111
|
|
112
|
-
static unsigned int right_encode(
|
112
|
+
static unsigned int right_encode(unsigned char * encbuf, size_t value)
|
113
113
|
{
|
114
114
|
unsigned int n, i;
|
115
115
|
size_t v;
|
116
116
|
|
117
|
-
for (
|
117
|
+
for (v = value, n = 0; v && (n < sizeof(size_t)); ++n, v >>= 8)
|
118
118
|
; /* empty */
|
119
119
|
for ( i = 1; i <= n; ++i )
|
120
120
|
encbuf[i-1] = (unsigned char)(value >> (8 * (n-i)));
|
@@ -128,7 +128,7 @@ int KangarooTwelve_Initialize(KangarooTwelve_Instance *ktInstance, size_t output
|
|
128
128
|
ktInstance->queueAbsorbedLen = 0;
|
129
129
|
ktInstance->blockNumber = 0;
|
130
130
|
ktInstance->phase = ABSORBING;
|
131
|
-
return
|
131
|
+
return TurboSHAKE128_Initialize(&ktInstance->finalNode);
|
132
132
|
}
|
133
133
|
|
134
134
|
int KangarooTwelve_Update(KangarooTwelve_Instance *ktInstance, const unsigned char *input, size_t inLen)
|
@@ -136,10 +136,10 @@ int KangarooTwelve_Update(KangarooTwelve_Instance *ktInstance, const unsigned ch
|
|
136
136
|
if (ktInstance->phase != ABSORBING)
|
137
137
|
return 1;
|
138
138
|
|
139
|
-
if (
|
139
|
+
if (ktInstance->blockNumber == 0) {
|
140
140
|
/* First block, absorb in final node */
|
141
141
|
unsigned int len = (inLen < (chunkSize - ktInstance->queueAbsorbedLen)) ? (unsigned int)inLen : (chunkSize - ktInstance->queueAbsorbedLen);
|
142
|
-
if (
|
142
|
+
if (TurboSHAKE_Absorb(&ktInstance->finalNode, input, len) != 0)
|
143
143
|
return 1;
|
144
144
|
input += len;
|
145
145
|
inLen -= len;
|
@@ -149,7 +149,7 @@ int KangarooTwelve_Update(KangarooTwelve_Instance *ktInstance, const unsigned ch
|
|
149
149
|
const unsigned char padding = 0x03; /* '110^6': message hop, simple padding */
|
150
150
|
ktInstance->queueAbsorbedLen = 0;
|
151
151
|
ktInstance->blockNumber = 1;
|
152
|
-
if (
|
152
|
+
if (TurboSHAKE_Absorb(&ktInstance->finalNode, &padding, 1) != 0)
|
153
153
|
return 1;
|
154
154
|
ktInstance->finalNode.byteIOIndex = (ktInstance->finalNode.byteIOIndex + 7) & ~7; /* Zero padding up to 64 bits */
|
155
155
|
}
|
@@ -157,7 +157,7 @@ int KangarooTwelve_Update(KangarooTwelve_Instance *ktInstance, const unsigned ch
|
|
157
157
|
else if ( ktInstance->queueAbsorbedLen != 0 ) {
|
158
158
|
/* There is data in the queue, absorb further in queue until block complete */
|
159
159
|
unsigned int len = (inLen < (chunkSize - ktInstance->queueAbsorbedLen)) ? (unsigned int)inLen : (chunkSize - ktInstance->queueAbsorbedLen);
|
160
|
-
if (
|
160
|
+
if (TurboSHAKE_Absorb(&ktInstance->queueNode, input, len) != 0)
|
161
161
|
return 1;
|
162
162
|
input += len;
|
163
163
|
inLen -= len;
|
@@ -166,11 +166,11 @@ int KangarooTwelve_Update(KangarooTwelve_Instance *ktInstance, const unsigned ch
|
|
166
166
|
unsigned char intermediate[capacityInBytes];
|
167
167
|
ktInstance->queueAbsorbedLen = 0;
|
168
168
|
++ktInstance->blockNumber;
|
169
|
-
if (
|
169
|
+
if (TurboSHAKE_AbsorbDomainSeparationByte(&ktInstance->queueNode, suffixLeaf) != 0)
|
170
170
|
return 1;
|
171
|
-
if (
|
171
|
+
if (TurboSHAKE_Squeeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
|
172
172
|
return 1;
|
173
|
-
if (
|
173
|
+
if (TurboSHAKE_Absorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
|
174
174
|
return 1;
|
175
175
|
}
|
176
176
|
}
|
@@ -203,24 +203,24 @@ int KangarooTwelve_Update(KangarooTwelve_Instance *ktInstance, const unsigned ch
|
|
203
203
|
#else
|
204
204
|
ParallelSpongeLoop( 2 )
|
205
205
|
#endif
|
206
|
-
|
206
|
+
#endif
|
207
207
|
|
208
208
|
while ( inLen > 0 ) {
|
209
209
|
unsigned int len = (inLen < chunkSize) ? (unsigned int)inLen : chunkSize;
|
210
|
-
if (
|
210
|
+
if (TurboSHAKE128_Initialize(&ktInstance->queueNode) != 0)
|
211
211
|
return 1;
|
212
|
-
if (
|
212
|
+
if (TurboSHAKE_Absorb(&ktInstance->queueNode, input, len) != 0)
|
213
213
|
return 1;
|
214
214
|
input += len;
|
215
215
|
inLen -= len;
|
216
216
|
if ( len == chunkSize ) {
|
217
217
|
unsigned char intermediate[capacityInBytes];
|
218
218
|
++ktInstance->blockNumber;
|
219
|
-
if (
|
219
|
+
if (TurboSHAKE_AbsorbDomainSeparationByte(&ktInstance->queueNode, suffixLeaf) != 0)
|
220
220
|
return 1;
|
221
|
-
if (
|
221
|
+
if (TurboSHAKE_Squeeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
|
222
222
|
return 1;
|
223
|
-
if (
|
223
|
+
if (TurboSHAKE_Absorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
|
224
224
|
return 1;
|
225
225
|
}
|
226
226
|
else
|
@@ -244,37 +244,37 @@ int KangarooTwelve_Final(KangarooTwelve_Instance *ktInstance, unsigned char * ou
|
|
244
244
|
if (KangarooTwelve_Update(ktInstance, encbuf, right_encode(encbuf, customLen)) != 0)
|
245
245
|
return 1;
|
246
246
|
|
247
|
-
if (
|
247
|
+
if (ktInstance->blockNumber == 0) {
|
248
248
|
/* Non complete first block in final node, pad it */
|
249
249
|
padding = 0x07; /* '11': message hop, final node */
|
250
250
|
}
|
251
251
|
else {
|
252
252
|
unsigned int n;
|
253
253
|
|
254
|
-
if (
|
254
|
+
if (ktInstance->queueAbsorbedLen != 0) {
|
255
255
|
/* There is data in the queue node */
|
256
256
|
unsigned char intermediate[capacityInBytes];
|
257
257
|
++ktInstance->blockNumber;
|
258
|
-
if (
|
258
|
+
if (TurboSHAKE_AbsorbDomainSeparationByte(&ktInstance->queueNode, suffixLeaf) != 0)
|
259
259
|
return 1;
|
260
|
-
if (
|
260
|
+
if (TurboSHAKE_Squeeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
|
261
261
|
return 1;
|
262
|
-
if (
|
262
|
+
if (TurboSHAKE_Absorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
|
263
263
|
return 1;
|
264
264
|
}
|
265
265
|
--ktInstance->blockNumber; /* Absorb right_encode(number of Chaining Values) || 0xFF || 0xFF */
|
266
266
|
n = right_encode(encbuf, ktInstance->blockNumber);
|
267
267
|
encbuf[n++] = 0xFF;
|
268
268
|
encbuf[n++] = 0xFF;
|
269
|
-
if (
|
269
|
+
if (TurboSHAKE_Absorb(&ktInstance->finalNode, encbuf, n) != 0)
|
270
270
|
return 1;
|
271
271
|
padding = 0x06; /* '01': chaining hop, final node */
|
272
272
|
}
|
273
|
-
if (
|
273
|
+
if (TurboSHAKE_AbsorbDomainSeparationByte(&ktInstance->finalNode, padding) != 0)
|
274
274
|
return 1;
|
275
|
-
if (
|
275
|
+
if (ktInstance->fixedOutputLength != 0) {
|
276
276
|
ktInstance->phase = FINAL;
|
277
|
-
return
|
277
|
+
return TurboSHAKE_Squeeze(&ktInstance->finalNode, output, ktInstance->fixedOutputLength);
|
278
278
|
}
|
279
279
|
ktInstance->phase = SQUEEZING;
|
280
280
|
return 0;
|
@@ -284,7 +284,7 @@ int KangarooTwelve_Squeeze(KangarooTwelve_Instance *ktInstance, unsigned char *
|
|
284
284
|
{
|
285
285
|
if (ktInstance->phase != SQUEEZING)
|
286
286
|
return 1;
|
287
|
-
return
|
287
|
+
return TurboSHAKE_Squeeze(&ktInstance->finalNode, output, outputLen);
|
288
288
|
}
|
289
289
|
|
290
290
|
int KangarooTwelve( const unsigned char * input, size_t inLen, unsigned char * output, size_t outLen, const unsigned char * customization, size_t customLen )
|
@@ -4,7 +4,7 @@ https://github.com/XKCP/XKCP
|
|
4
4
|
|
5
5
|
KangarooTwelve, designed by Guido Bertoni, Joan Daemen, Michaël Peeters, Gilles Van Assche, Ronny Van Keer and Benoît Viguier.
|
6
6
|
|
7
|
-
Implementation by Ronny Van Keer, hereby denoted as "the implementer".
|
7
|
+
Implementation by Gilles Van Assche and Ronny Van Keer, hereby denoted as "the implementer".
|
8
8
|
|
9
9
|
For more information, feedback or questions, please refer to the Keccak Team website:
|
10
10
|
https://keccak.team/
|
@@ -22,14 +22,14 @@ http://creativecommons.org/publicdomain/zero/1.0/
|
|
22
22
|
|
23
23
|
#include <stddef.h>
|
24
24
|
#include "align.h"
|
25
|
-
#include "
|
25
|
+
#include "TurboSHAKE.h"
|
26
26
|
#include "Phases.h"
|
27
27
|
|
28
28
|
typedef KCP_Phases KangarooTwelve_Phases;
|
29
29
|
|
30
30
|
typedef struct {
|
31
|
-
|
32
|
-
|
31
|
+
TurboSHAKE_Instance queueNode;
|
32
|
+
TurboSHAKE_Instance finalNode;
|
33
33
|
size_t fixedOutputLength;
|
34
34
|
size_t blockNumber;
|
35
35
|
unsigned int queueAbsorbedLen;
|
@@ -45,7 +45,7 @@ typedef struct {
|
|
45
45
|
* @param customByteLen The length of the customization string in bytes.
|
46
46
|
* @return 0 if successful, 1 otherwise.
|
47
47
|
*/
|
48
|
-
int KangarooTwelve(const unsigned char *input, size_t inputByteLen, unsigned char *output, size_t outputByteLen, const unsigned char *customization, size_t customByteLen
|
48
|
+
int KangarooTwelve(const unsigned char *input, size_t inputByteLen, unsigned char *output, size_t outputByteLen, const unsigned char *customization, size_t customByteLen);
|
49
49
|
|
50
50
|
/**
|
51
51
|
* Function to initialize a KangarooTwelve instance.
|
@@ -91,21 +91,3 @@ http://creativecommons.org/publicdomain/zero/1.0/
|
|
91
91
|
#undef SnP_Permute
|
92
92
|
#undef SnP_FastLoop_Absorb
|
93
93
|
#endif
|
94
|
-
|
95
|
-
#ifdef XKCP_has_KeccakP1600
|
96
|
-
#include "KeccakP-1600-SnP.h"
|
97
|
-
|
98
|
-
#define prefix KeccakWidth1600_12rounds
|
99
|
-
#define SnP KeccakP1600
|
100
|
-
#define SnP_width 1600
|
101
|
-
#define SnP_Permute KeccakP1600_Permute_12rounds
|
102
|
-
#if defined(KeccakP1600_12rounds_FastLoop_supported)
|
103
|
-
#define SnP_FastLoop_Absorb KeccakP1600_12rounds_FastLoop_Absorb
|
104
|
-
#endif
|
105
|
-
#include "KeccakSponge.inc"
|
106
|
-
#undef prefix
|
107
|
-
#undef SnP
|
108
|
-
#undef SnP_width
|
109
|
-
#undef SnP_Permute
|
110
|
-
#undef SnP_FastLoop_Absorb
|
111
|
-
#endif
|
@@ -67,10 +67,4 @@ http://creativecommons.org/publicdomain/zero/1.0/
|
|
67
67
|
#define XKCP_has_Sponge_Keccak_width1600
|
68
68
|
#endif
|
69
69
|
|
70
|
-
#ifdef XKCP_has_KeccakP1600
|
71
|
-
#include "KeccakP-1600-SnP.h"
|
72
|
-
XKCP_DeclareSpongeStructure(KeccakWidth1600_12rounds, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment)
|
73
|
-
XKCP_DeclareSpongeFunctions(KeccakWidth1600_12rounds)
|
74
|
-
#endif
|
75
|
-
|
76
70
|
#endif
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/*
|
2
|
+
The eXtended Keccak Code Package (XKCP)
|
3
|
+
https://github.com/XKCP/XKCP
|
4
|
+
|
5
|
+
TurboSHAKE, proposed by Guido Bertoni, Joan Daemen, Seth Hoffert, Michaël Peeters, Gilles Van Assche, Ronny Van Keer and Benoît Viguier.
|
6
|
+
|
7
|
+
Implementation by Gilles Van Assche, 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
|
+
#include "TurboSHAKE.h"
|
18
|
+
|
19
|
+
#ifdef XKCP_has_KeccakP1600
|
20
|
+
#include "KeccakP-1600-SnP.h"
|
21
|
+
|
22
|
+
#define prefix TurboSHAKE
|
23
|
+
#define SnP KeccakP1600
|
24
|
+
#define SnP_width 1600
|
25
|
+
#define SnP_Permute KeccakP1600_Permute_12rounds
|
26
|
+
#if defined(KeccakP1600_12rounds_FastLoop_supported)
|
27
|
+
#define SnP_FastLoop_Absorb KeccakP1600_12rounds_FastLoop_Absorb
|
28
|
+
#endif
|
29
|
+
#include "KeccakSponge.inc"
|
30
|
+
#undef prefix
|
31
|
+
#undef SnP
|
32
|
+
#undef SnP_width
|
33
|
+
#undef SnP_Permute
|
34
|
+
#undef SnP_FastLoop_Absorb
|
35
|
+
#endif
|
36
|
+
|
37
|
+
XKCP_DeclareSpongeFunctions(TurboSHAKE)
|
38
|
+
|
39
|
+
int TurboSHAKE(unsigned int capacity, const unsigned char *input, size_t inputByteLen, unsigned char domain, unsigned char *output, size_t outputByteLen)
|
40
|
+
{
|
41
|
+
TurboSHAKE_Instance instance;
|
42
|
+
|
43
|
+
if (TurboSHAKE_Initialize(&instance, capacity)) return 1;
|
44
|
+
if (TurboSHAKE_Absorb(&instance, input, inputByteLen)) return 1;
|
45
|
+
if (TurboSHAKE_AbsorbDomainSeparationByte(&instance, domain)) return 1;
|
46
|
+
if (TurboSHAKE_Squeeze(&instance, output, outputByteLen)) return 1;
|
47
|
+
return 0;
|
48
|
+
}
|
49
|
+
|
50
|
+
int TurboSHAKE_Initialize(TurboSHAKE_Instance *instance, unsigned int capacity)
|
51
|
+
{
|
52
|
+
if ((capacity > 512) || ((capacity % 8) != 0))
|
53
|
+
return 1;
|
54
|
+
else
|
55
|
+
return TurboSHAKE_SpongeInitialize(instance, 1600-capacity, capacity);
|
56
|
+
}
|
57
|
+
|
58
|
+
int TurboSHAKE_Absorb(TurboSHAKE_Instance *instance, const unsigned char *data, size_t dataByteLen)
|
59
|
+
{
|
60
|
+
return TurboSHAKE_SpongeAbsorb(instance, data, dataByteLen);
|
61
|
+
}
|
62
|
+
|
63
|
+
int TurboSHAKE_AbsorbDomainSeparationByte(TurboSHAKE_Instance *instance, unsigned char domain)
|
64
|
+
{
|
65
|
+
return TurboSHAKE_SpongeAbsorbLastFewBits(instance, domain);
|
66
|
+
}
|
67
|
+
|
68
|
+
int TurboSHAKE_Squeeze(TurboSHAKE_Instance *instance, unsigned char *data, size_t dataByteLen)
|
69
|
+
{
|
70
|
+
return TurboSHAKE_SpongeSqueeze(instance, data, dataByteLen);
|
71
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/*
|
2
|
+
The eXtended Keccak Code Package (XKCP)
|
3
|
+
https://github.com/XKCP/XKCP
|
4
|
+
|
5
|
+
TurboSHAKE, proposed by Guido Bertoni, Joan Daemen, Seth Hoffert, Michaël Peeters, Gilles Van Assche, Ronny Van Keer and Benoît Viguier.
|
6
|
+
|
7
|
+
Implementation by Gilles Van Assche, 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 _TurboSHAKE_h_
|
18
|
+
#define _TurboSHAKE_h_
|
19
|
+
|
20
|
+
#include <string.h>
|
21
|
+
#include "align.h"
|
22
|
+
#include "config.h"
|
23
|
+
#include "KeccakSponge.h"
|
24
|
+
|
25
|
+
#ifdef XKCP_has_KeccakP1600
|
26
|
+
#include "KeccakP-1600-SnP.h"
|
27
|
+
XKCP_DeclareSpongeStructure(TurboSHAKE, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment)
|
28
|
+
|
29
|
+
typedef TurboSHAKE_SpongeInstance TurboSHAKE_Instance;
|
30
|
+
|
31
|
+
int TurboSHAKE(unsigned int capacity, const unsigned char *input, size_t inputByteLen, unsigned char domain, unsigned char *output, size_t outputByteLen);
|
32
|
+
|
33
|
+
int TurboSHAKE_Initialize(TurboSHAKE_Instance *instance, unsigned int capacity);
|
34
|
+
|
35
|
+
#define TurboSHAKE128_Initialize(instance) \
|
36
|
+
TurboSHAKE_Initialize((instance), 256)
|
37
|
+
|
38
|
+
#define TurboSHAKE256_Initialize(instance) \
|
39
|
+
TurboSHAKE_Initialize((instance), 512)
|
40
|
+
|
41
|
+
int TurboSHAKE_Absorb(TurboSHAKE_Instance *instance, const unsigned char *data, size_t dataByteLen);
|
42
|
+
|
43
|
+
int TurboSHAKE_AbsorbDomainSeparationByte(TurboSHAKE_Instance *instance, unsigned char domain);
|
44
|
+
|
45
|
+
int TurboSHAKE_Squeeze(TurboSHAKE_Instance *instance, unsigned char *data, size_t dataByteLen);
|
46
|
+
|
47
|
+
#endif
|
48
|
+
|
49
|
+
#endif
|