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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/digest-kangarootwelve.gemspec +1 -1
  4. data/ext/digest/kangarootwelve/.sitearchdir.-.digest.time +0 -0
  5. data/ext/digest/kangarootwelve/XKCP/lib/high/KangarooTwelve/KangarooTwelve.c +32 -32
  6. data/ext/digest/kangarootwelve/XKCP/lib/high/KangarooTwelve/KangarooTwelve.h +5 -5
  7. data/ext/digest/kangarootwelve/XKCP/lib/high/Keccak/KeccakSponge.c +0 -18
  8. data/ext/digest/kangarootwelve/XKCP/lib/high/Keccak/KeccakSponge.h +0 -6
  9. data/ext/digest/kangarootwelve/XKCP/lib/high/TurboSHAKE/TurboSHAKE.c +71 -0
  10. data/ext/digest/kangarootwelve/XKCP/lib/high/TurboSHAKE/TurboSHAKE.h +49 -0
  11. data/ext/digest/kangarootwelve/XKCP/lib/low/KeccakP-1600/AVX2/KeccakP-1600-AVX2.s +0 -52
  12. data/ext/digest/kangarootwelve/XKCP/lib/low/KeccakP-1600/AVX512/KeccakP-1600-AVX512.s +0 -48
  13. data/ext/digest/kangarootwelve/XKCP/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros +19 -9
  14. data/ext/digest/kangarootwelve/XKCP/lib/low/common/PlSnP-Fallback.inc +3 -2
  15. data/ext/digest/kangarootwelve/ext.c +3 -1
  16. data/ext/digest/kangarootwelve/targets/armv6/TurboSHAKE.c +1 -0
  17. data/ext/digest/kangarootwelve/targets/armv6/TurboSHAKE.h +1 -0
  18. data/ext/digest/kangarootwelve/targets/armv6m/TurboSHAKE.c +1 -0
  19. data/ext/digest/kangarootwelve/targets/armv6m/TurboSHAKE.h +1 -0
  20. data/ext/digest/kangarootwelve/targets/armv7a/TurboSHAKE.c +1 -0
  21. data/ext/digest/kangarootwelve/targets/armv7a/TurboSHAKE.h +1 -0
  22. data/ext/digest/kangarootwelve/targets/armv7m/TurboSHAKE.c +1 -0
  23. data/ext/digest/kangarootwelve/targets/armv7m/TurboSHAKE.h +1 -0
  24. data/ext/digest/kangarootwelve/targets/armv8a/TurboSHAKE.c +1 -0
  25. data/ext/digest/kangarootwelve/targets/armv8a/TurboSHAKE.h +1 -0
  26. data/ext/digest/kangarootwelve/targets/avr8/TurboSHAKE.c +1 -0
  27. data/ext/digest/kangarootwelve/targets/avr8/TurboSHAKE.h +1 -0
  28. data/ext/digest/kangarootwelve/targets/avx/TurboSHAKE.c +1 -0
  29. data/ext/digest/kangarootwelve/targets/avx/TurboSHAKE.h +1 -0
  30. data/ext/digest/kangarootwelve/targets/avx2/TurboSHAKE.c +1 -0
  31. data/ext/digest/kangarootwelve/targets/avx2/TurboSHAKE.h +1 -0
  32. data/ext/digest/kangarootwelve/targets/avx2noasm/TurboSHAKE.c +1 -0
  33. data/ext/digest/kangarootwelve/targets/avx2noasm/TurboSHAKE.h +1 -0
  34. data/ext/digest/kangarootwelve/targets/avx512/TurboSHAKE.c +1 -0
  35. data/ext/digest/kangarootwelve/targets/avx512/TurboSHAKE.h +1 -0
  36. data/ext/digest/kangarootwelve/targets/avx512noasm/TurboSHAKE.c +1 -0
  37. data/ext/digest/kangarootwelve/targets/avx512noasm/TurboSHAKE.h +1 -0
  38. data/ext/digest/kangarootwelve/targets/compact/TurboSHAKE.c +1 -0
  39. data/ext/digest/kangarootwelve/targets/compact/TurboSHAKE.h +1 -0
  40. data/ext/digest/kangarootwelve/targets/config.h +1 -0
  41. data/ext/digest/kangarootwelve/targets/generic32/TurboSHAKE.c +1 -0
  42. data/ext/digest/kangarootwelve/targets/generic32/TurboSHAKE.h +1 -0
  43. data/ext/digest/kangarootwelve/targets/generic32lc/TurboSHAKE.c +1 -0
  44. data/ext/digest/kangarootwelve/targets/generic32lc/TurboSHAKE.h +1 -0
  45. data/ext/digest/kangarootwelve/targets/generic64/TurboSHAKE.c +1 -0
  46. data/ext/digest/kangarootwelve/targets/generic64/TurboSHAKE.h +1 -0
  47. data/ext/digest/kangarootwelve/targets/generic64lc/TurboSHAKE.c +1 -0
  48. data/ext/digest/kangarootwelve/targets/generic64lc/TurboSHAKE.h +1 -0
  49. data/ext/digest/kangarootwelve/targets/reference/TurboSHAKE.c +1 -0
  50. data/ext/digest/kangarootwelve/targets/reference/TurboSHAKE.h +1 -0
  51. data/ext/digest/kangarootwelve/targets/reference32bits/TurboSHAKE.c +1 -0
  52. data/ext/digest/kangarootwelve/targets/reference32bits/TurboSHAKE.h +1 -0
  53. data/ext/digest/kangarootwelve/targets/ssse3/TurboSHAKE.c +1 -0
  54. data/ext/digest/kangarootwelve/targets/ssse3/TurboSHAKE.h +1 -0
  55. data/ext/digest/kangarootwelve/targets/xop/TurboSHAKE.c +1 -0
  56. data/ext/digest/kangarootwelve/targets/xop/TurboSHAKE.h +1 -0
  57. data/lib/digest/kangarootwelve/version.rb +1 -1
  58. metadata +54 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffce05a13297d1397e3fa033be301d33d248b104099103ed42e902b464407068
4
- data.tar.gz: fb12f02a91f041ac83f467fe9d0d75db8bc898629aa533fb7386233be711f67f
3
+ metadata.gz: 6a6cfce02fd762e9a160af1eec3255d54ed7dd489f10de784965377ae0d60998
4
+ data.tar.gz: 2d6f2ee7d596ea64c777af39cad590e3db405eadb2b2ffe03e1827c88741b114
5
5
  SHA512:
6
- metadata.gz: 955f7967d601bdd35be2ac94c83348fab2fd12a1494f2f725dcba14726618da1d67505dc5008fd5512b55ee99c8d8eecf9a165ddd6a89e247d44ab1307ca230a
7
- data.tar.gz: ae1c8fa1b95804f6a4bd32b827bc6bf4d1a82c441a0dc277a870953d0e31c2872b9c6f3fcde66e059f0e8162b1f04f4bad3f94e00b4552f291b104cd962d17bc
6
+ metadata.gz: 7484d076de7e4d1a12604b6a5c48f277c60d3543a83b88aa98fa1b43fb6b4d66315b77978183ef6993e6cfaf512fbfaaf865cb2e470c638cb273747ee4799139
7
+ data.tar.gz: 7f6b97d95218498100afe513d254307ce5dad1cb3d8a0fb419cab422e53909e67d37b2f87a38fb6093ff4c6f0db9de3f72c8c38799d9fadcfefb03e34ece5e2d
data/README.md CHANGED
@@ -98,7 +98,7 @@ The gem can also be tested from source using the following commands:
98
98
  cd digest-kangarootwelve-ruby
99
99
 
100
100
  # Optionally checkout a tagged version.
101
- git checkout v0.4.6
101
+ git checkout v0.4.8
102
102
 
103
103
  # Run bundle
104
104
  bundle
@@ -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.0"
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"
@@ -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 (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
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 (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
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 (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
109
+ if (TurboSHAKE_Absorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
110
110
  }
111
111
 
112
- static unsigned int right_encode( unsigned char * encbuf, size_t value )
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 ( v = value, n = 0; v && (n < sizeof(size_t)); ++n, v >>= 8 )
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 KeccakWidth1600_12rounds_SpongeInitialize(&ktInstance->finalNode, rate, capacity);
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 ( ktInstance->blockNumber == 0 ) {
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 (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, input, len) != 0)
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 (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, &padding, 1) != 0)
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 (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->queueNode, input, len) != 0)
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 (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->queueNode, suffixLeaf) != 0)
169
+ if (TurboSHAKE_AbsorbDomainSeparationByte(&ktInstance->queueNode, suffixLeaf) != 0)
170
170
  return 1;
171
- if (KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
171
+ if (TurboSHAKE_Squeeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
172
172
  return 1;
173
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
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
- #endif
206
+ #endif
207
207
 
208
208
  while ( inLen > 0 ) {
209
209
  unsigned int len = (inLen < chunkSize) ? (unsigned int)inLen : chunkSize;
210
- if (KeccakWidth1600_12rounds_SpongeInitialize(&ktInstance->queueNode, rate, capacity) != 0)
210
+ if (TurboSHAKE128_Initialize(&ktInstance->queueNode) != 0)
211
211
  return 1;
212
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->queueNode, input, len) != 0)
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 (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->queueNode, suffixLeaf) != 0)
219
+ if (TurboSHAKE_AbsorbDomainSeparationByte(&ktInstance->queueNode, suffixLeaf) != 0)
220
220
  return 1;
221
- if (KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
221
+ if (TurboSHAKE_Squeeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
222
222
  return 1;
223
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
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 ( ktInstance->blockNumber == 0 ) {
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 ( ktInstance->queueAbsorbedLen != 0 ) {
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 (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->queueNode, suffixLeaf) != 0)
258
+ if (TurboSHAKE_AbsorbDomainSeparationByte(&ktInstance->queueNode, suffixLeaf) != 0)
259
259
  return 1;
260
- if (KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
260
+ if (TurboSHAKE_Squeeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
261
261
  return 1;
262
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
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 (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, encbuf, n) != 0)
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 (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->finalNode, padding) != 0)
273
+ if (TurboSHAKE_AbsorbDomainSeparationByte(&ktInstance->finalNode, padding) != 0)
274
274
  return 1;
275
- if ( ktInstance->fixedOutputLength != 0 ) {
275
+ if (ktInstance->fixedOutputLength != 0) {
276
276
  ktInstance->phase = FINAL;
277
- return KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->finalNode, output, ktInstance->fixedOutputLength);
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 KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->finalNode, output, outputLen);
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 "KeccakSponge.h"
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
- KeccakWidth1600_12rounds_SpongeInstance queueNode;
32
- KeccakWidth1600_12rounds_SpongeInstance finalNode;
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