digest-kangarootwelve 0.4.5 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.XKCP +167 -7
  3. data/README.md +24 -4
  4. data/Rakefile +6 -9
  5. data/digest-kangarootwelve.gemspec +1 -1
  6. data/ext/digest/kangarootwelve/XKCP/lib/high/KangarooTwelve/KangarooTwelve.c +32 -32
  7. data/ext/digest/kangarootwelve/XKCP/lib/high/KangarooTwelve/KangarooTwelve.h +5 -5
  8. data/ext/digest/kangarootwelve/XKCP/lib/high/Keccak/KeccakSponge.c +0 -18
  9. data/ext/digest/kangarootwelve/XKCP/lib/high/Keccak/KeccakSponge.h +0 -6
  10. data/ext/digest/kangarootwelve/XKCP/lib/high/Keccak/KeccakSponge.inc +8 -6
  11. data/ext/digest/kangarootwelve/XKCP/lib/high/TurboSHAKE/TurboSHAKE.c +71 -0
  12. data/ext/digest/kangarootwelve/XKCP/lib/high/TurboSHAKE/TurboSHAKE.h +49 -0
  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/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SIMD256.c +2 -2
  15. data/ext/digest/kangarootwelve/XKCP/lib/low/common/PlSnP-Fallback.inc +3 -2
  16. data/ext/digest/kangarootwelve/ext.c +1 -1
  17. data/ext/digest/kangarootwelve/targets/armv6/TurboSHAKE.c +1 -0
  18. data/ext/digest/kangarootwelve/targets/armv6/TurboSHAKE.h +1 -0
  19. data/ext/digest/kangarootwelve/targets/armv6m/TurboSHAKE.c +1 -0
  20. data/ext/digest/kangarootwelve/targets/armv6m/TurboSHAKE.h +1 -0
  21. data/ext/digest/kangarootwelve/targets/armv7a/TurboSHAKE.c +1 -0
  22. data/ext/digest/kangarootwelve/targets/armv7a/TurboSHAKE.h +1 -0
  23. data/ext/digest/kangarootwelve/targets/armv7m/TurboSHAKE.c +1 -0
  24. data/ext/digest/kangarootwelve/targets/armv7m/TurboSHAKE.h +1 -0
  25. data/ext/digest/kangarootwelve/targets/armv8a/TurboSHAKE.c +1 -0
  26. data/ext/digest/kangarootwelve/targets/armv8a/TurboSHAKE.h +1 -0
  27. data/ext/digest/kangarootwelve/targets/avr8/TurboSHAKE.c +1 -0
  28. data/ext/digest/kangarootwelve/targets/avr8/TurboSHAKE.h +1 -0
  29. data/ext/digest/kangarootwelve/targets/avx/TurboSHAKE.c +1 -0
  30. data/ext/digest/kangarootwelve/targets/avx/TurboSHAKE.h +1 -0
  31. data/ext/digest/kangarootwelve/targets/avx2/TurboSHAKE.c +1 -0
  32. data/ext/digest/kangarootwelve/targets/avx2/TurboSHAKE.h +1 -0
  33. data/ext/digest/kangarootwelve/targets/avx2noasm/TurboSHAKE.c +1 -0
  34. data/ext/digest/kangarootwelve/targets/avx2noasm/TurboSHAKE.h +1 -0
  35. data/ext/digest/kangarootwelve/targets/avx512/TurboSHAKE.c +1 -0
  36. data/ext/digest/kangarootwelve/targets/avx512/TurboSHAKE.h +1 -0
  37. data/ext/digest/kangarootwelve/targets/avx512noasm/TurboSHAKE.c +1 -0
  38. data/ext/digest/kangarootwelve/targets/avx512noasm/TurboSHAKE.h +1 -0
  39. data/ext/digest/kangarootwelve/targets/compact/TurboSHAKE.c +1 -0
  40. data/ext/digest/kangarootwelve/targets/compact/TurboSHAKE.h +1 -0
  41. data/ext/digest/kangarootwelve/targets/config.h +1 -0
  42. data/ext/digest/kangarootwelve/targets/generic32/TurboSHAKE.c +1 -0
  43. data/ext/digest/kangarootwelve/targets/generic32/TurboSHAKE.h +1 -0
  44. data/ext/digest/kangarootwelve/targets/generic32lc/TurboSHAKE.c +1 -0
  45. data/ext/digest/kangarootwelve/targets/generic32lc/TurboSHAKE.h +1 -0
  46. data/ext/digest/kangarootwelve/targets/generic64/TurboSHAKE.c +1 -0
  47. data/ext/digest/kangarootwelve/targets/generic64/TurboSHAKE.h +1 -0
  48. data/ext/digest/kangarootwelve/targets/generic64lc/TurboSHAKE.c +1 -0
  49. data/ext/digest/kangarootwelve/targets/generic64lc/TurboSHAKE.h +1 -0
  50. data/ext/digest/kangarootwelve/targets/reference/TurboSHAKE.c +1 -0
  51. data/ext/digest/kangarootwelve/targets/reference/TurboSHAKE.h +1 -0
  52. data/ext/digest/kangarootwelve/targets/reference32bits/TurboSHAKE.c +1 -0
  53. data/ext/digest/kangarootwelve/targets/reference32bits/TurboSHAKE.h +1 -0
  54. data/ext/digest/kangarootwelve/targets/ssse3/TurboSHAKE.c +1 -0
  55. data/ext/digest/kangarootwelve/targets/ssse3/TurboSHAKE.h +1 -0
  56. data/ext/digest/kangarootwelve/targets/xop/TurboSHAKE.c +1 -0
  57. data/ext/digest/kangarootwelve/targets/xop/TurboSHAKE.h +1 -0
  58. data/lib/digest/kangarootwelve/version.rb +1 -1
  59. metadata +53 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c8b25102cf3f6a925000487653a245a6f153de17a12319ebfd1c6c25549daf6
4
- data.tar.gz: 12d05f0e8b6927105aebc1feffb5bb68482f9235fa6afcee2265b4eeba54cdb2
3
+ metadata.gz: 88387c3d71dddd53f518435cda9fe7ef93873c78aee3524fa379316ede192b67
4
+ data.tar.gz: 51dbf805b8f5f358626f461e5bd0fbc4a32e5608e467d2686a36805ad2c035fc
5
5
  SHA512:
6
- metadata.gz: f3e2047eb8379800ba6fe5bd2b4af801ea3a64e1d62581dd9f0267e2d0ee87c5e963e1e2874d5b57f99c4e5f007fb07fe8749ce3ea452482ea076964e213af6f
7
- data.tar.gz: 9af6b30aef3113ad635cb870628adce507728d684de587d54fb0c14a96d9e0ee1aa984a4cdf32fd18fa50ed1bd1df2711e166c65c656ebc1391963d36b44685f
6
+ metadata.gz: 43d2fefcbc944133c1a16d658591f5e5ab631fa869e51351aa16aac750e2365880f2f8f7db0e5a0ccc18dcd355f22ec233bd8b4021632f98d7cdc5f26bc3b76e
7
+ data.tar.gz: 2034731d336c5fb34270abc4becd1be7e8182a2f87c4508cfbca5633ff25ed2b3db1f66245833d7aef3ccd6225b8328af30d43bda4559cc64fadd65c1bfc086c
data/LICENSE.XKCP CHANGED
@@ -1,9 +1,169 @@
1
- # Under which license is the XKCP distributed?
1
+ The redistribution and use of this software (with or without changes) is allowed without the payment of fees or royalties provided that the terms of the licenses of the different source files used is respected. Most of the source and header files in the XKCP are released to the public domain and associated to the CC0 (http://creativecommons.org/publicdomain/zero/1.0/) deed, but there are exceptions.
2
2
 
3
- Most of the source and header files in the XKCP are released to the **public domain** and associated to the [CC0](http://creativecommons.org/publicdomain/zero/1.0/) deed. The exceptions are the following:
3
+ In general, the redistribution of this software should include a copy of this file. However, if only a part of the software is redistributed or used, the portions that are no longer relevant may be removed. Hints are given below whether a file is used in libXKCP, UnitTests, Benchmarks or KeccakSum.
4
4
 
5
- * [`lib/common/brg_endian.h`](lib/common/brg_endian.h) is copyrighted by Brian Gladman and comes with a BSD 3-clause license;
6
- * [`tests/UnitTests/genKAT.c`](tests/UnitTests/genKAT.c) is based on [SHA-3 contest's code by Larry Bassham, NIST](http://csrc.nist.gov/groups/ST/hash/sha-3/documents/KAT1.zip), which he licensed under a BSD 3-clause license;
7
- * [`tests/UnitTests/timing.h`](tests/UnitTests/timing.h) is adapted from Google Benchmark and is licensed under the Apache License, Version 2.0;
8
- * [`KeccakP-1600-AVX2.s`](lib/low/KeccakP-1600/AVX2/KeccakP-1600-AVX2.s) is licensed under the [CRYPTOGAMS license](http://www.openssl.org/~appro/cryptogams/) (BSD-like);
9
- * [`support/Kernel-PMU/enable_arm_pmu.c`](support/Kernel-PMU/enable_arm_pmu.c) is licensed under the GNU General Public License by Bruno Pairault.
5
+
6
+ For XKCP/lib/common/brg_endian.h (used in libXKCP, UnitTests, Benchmarks and KeccakSum):
7
+
8
+ ---------------------------------------------------------------------------
9
+ Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
10
+
11
+ LICENSE TERMS
12
+
13
+ The redistribution and use of this software (with or without changes)
14
+ is allowed without the payment of fees or royalties provided that:
15
+
16
+ 1. source code distributions include the above copyright notice, this
17
+ list of conditions and the following disclaimer;
18
+
19
+ 2. binary distributions include the above copyright notice, this list
20
+ of conditions and the following disclaimer in their documentation;
21
+
22
+ 3. the name of the copyright holder is not used to endorse products
23
+ built using this software without specific written permission.
24
+
25
+ DISCLAIMER
26
+
27
+ This software is provided 'as is' with no explicit or implied warranties
28
+ in respect of its properties, including, but not limited to, correctness
29
+ and/or fitness for purpose.
30
+ ---------------------------------------------------------------------------
31
+
32
+
33
+ For XKCP/lib/low/KeccakP-1600/AVX2/KeccakP-1600-AVX2.s and XKCP/lib/low/KeccakP-1600/AVX512/KeccakP-1600-AVX512.s (potentially used in libXKCP, UnitTests, Benchmarks and KeccakSum, depending on the target platform):
34
+
35
+ Copyright (c) 2006-2017, CRYPTOGAMS by <appro@openssl.org>
36
+ All rights reserved.
37
+
38
+ Redistribution and use in source and binary forms, with or without
39
+ modification, are permitted provided that the following conditions
40
+ are met:
41
+
42
+ * Redistributions of source code must retain copyright notices,
43
+ this list of conditions and the following disclaimer.
44
+
45
+ * Redistributions in binary form must reproduce the above
46
+ copyright notice, this list of conditions and the following
47
+ disclaimer in the documentation and/or other materials
48
+ provided with the distribution.
49
+
50
+ * Neither the name of the CRYPTOGAMS nor the names of its
51
+ copyright holder and contributors may be used to endorse or
52
+ promote products derived from this software without specific
53
+ prior written permission.
54
+
55
+ ALTERNATIVELY, provided that this notice is retained in full, this
56
+ product may be distributed under the terms of the GNU General Public
57
+ License (GPL), in which case the provisions of the GPL apply INSTEAD OF
58
+ those given above.
59
+
60
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
61
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
62
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
63
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
64
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
65
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
66
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
67
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
68
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
69
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
70
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
71
+
72
+
73
+ For XKCP/Standalone/CompactFIPS202/C/genKAT.c, XKCP/tests/UnitTests/genKAT.c and XKCP/tests/UnitTests/genKAT.h (used only in UnitTests):
74
+
75
+ Copyright (c) 2008, Lawrence E. Bassham, National Institute of Standards and Technology (NIST),
76
+ for the original version (available at http://csrc.nist.gov/groups/ST/hash/sha-3/documents/KAT1.zip)
77
+
78
+ All rights reserved.
79
+
80
+ Redistribution and use in source and binary forms, with or without
81
+ modification, are permitted provided that the following conditions are met:
82
+ * Redistributions of source code must retain the above copyright
83
+ notice, this list of conditions and the following disclaimer.
84
+ * Redistributions in binary form must reproduce the above copyright
85
+ notice, this list of conditions and the following disclaimer in the
86
+ documentation and/or other materials provided with the distribution.
87
+ * Neither the name of the NIST nor the
88
+ names of its contributors may be used to endorse or promote products
89
+ derived from this software without specific prior written permission.
90
+
91
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
92
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
93
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
94
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
95
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
96
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
97
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
98
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
99
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
100
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
101
+
102
+
103
+ For XKCP/support/Kernel-PMU/enable_arm_pmu.c (*not* used in libXKCP, UnitTests, Benchmarks nor KeccakSum):
104
+
105
+ Kernel-PMU
106
+ Enabling user-mode access to the performance monitor unit (PMU) on ARMv8 Aarch64 and ARMv7
107
+ Copyright (C) 2019 Bruno Pairault
108
+
109
+ This program is free software: you can redistribute it and/or modify
110
+ it under the terms of the GNU General Public License as published by
111
+ the Free Software Foundation, either version 3 of the License, or
112
+ (at your option) any later version.
113
+
114
+ This program is distributed in the hope that it will be useful,
115
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
116
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
117
+ GNU General Public License for more details.
118
+
119
+ You should have received a copy of the GNU General Public License
120
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
121
+
122
+
123
+ For XKCP/tests/Benchmarks/timing.h (used only in Benchmarks):
124
+
125
+ Copyright 2020 Google Inc.
126
+
127
+ Licensed under the Apache License, Version 2.0 (the "License");
128
+ you may not use this file except in compliance with the License.
129
+ You may obtain a copy of the License at
130
+
131
+ http://www.apache.org/licenses/LICENSE-2.0
132
+
133
+ Unless required by applicable law or agreed to in writing, software
134
+ distributed under the License is distributed on an "AS IS" BASIS,
135
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
136
+ See the License for the specific language governing permissions and
137
+ limitations under the License.
138
+
139
+
140
+ For XKCP/tests/NIST_LWC/genkat_aead_c89.c, XKCP/tests/NIST_LWC/genkat_aead.c, XKCP/tests/NIST_LWC/genkat_hash_c89.c and XKCP/tests/NIST_LWC/genkat_hash.c (*not* used in libXKCP, UnitTests, Benchmarks nor KeccakSum):
141
+
142
+ NIST-developed software is provided by NIST as a public service.
143
+ You may use, copy and distribute copies of the software in any medium,
144
+ provided that you keep intact this entire notice. You may improve,
145
+ modify and create derivative works of the software or any portion of
146
+ the software, and you may copy and distribute such modifications or
147
+ works. Modified works should carry a notice stating that you changed
148
+ the software and should note the date and nature of any such change.
149
+ Please explicitly acknowledge the National Institute of Standards and
150
+ Technology as the source of the software.
151
+
152
+ NIST-developed software is expressly provided "AS IS." NIST MAKES NO
153
+ WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION
154
+ OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY,
155
+ FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST
156
+ NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE
157
+ UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST
158
+ DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE
159
+ OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY,
160
+ RELIABILITY, OR USEFULNESS OF THE SOFTWARE.
161
+
162
+ You are solely responsible for determining the appropriateness of using and
163
+ distributing the software and you assume all risks associated with its use,
164
+ including but not limited to the risks and costs of program errors, compliance
165
+ with applicable laws, damage to or loss of data, programs or equipment, and
166
+ the unavailability or interruption of operation. This software is not intended
167
+ to be used in any situation where a failure could cause risk of injury or
168
+ damage to property. The software developed by NIST employees is not subject to
169
+ copyright protection within the United States.
data/README.md CHANGED
@@ -55,18 +55,35 @@ using a not so commonly used target. Here's one way to test it:
55
55
  bundle
56
56
  rake test
57
57
 
58
- To know the right value of GEM_DIR, try running `gem info digest-kangarootwelve`.
58
+ To know the right value of GEM_DIR, try running
59
+ `gem info digest-kangarootwelve`.
59
60
 
60
61
  ## Installing in Gentoo
61
62
 
62
- The library can also be globally installed in Gentoo using `layman`:
63
+ The library can also be globally installed in Gentoo using `layman` or
64
+ `eselect-repository`:
63
65
 
64
66
  # Fetch remote list of overlays, and add 'konsolebox' overlay.
65
67
  layman -f && layman -a konsolebox
66
68
 
69
+ # Or enable repo through eselect-repository.
70
+ eselect repository enable konsolebox
71
+ emaint sync --repo konsolebox
72
+
67
73
  # Unmask unstable keyword.
68
74
  echo 'dev-ruby/digest-kangarootwelve' > /etc/portage/package.accept_keywords/dev-ruby.digest-kangarootwelve
69
75
 
76
+ # Optionally specify a different build target that works better in the
77
+ # machine. This may need additional CFLAGS options like -march=native set
78
+ # in the environment. The default build target `compact` should also be
79
+ # disabled.
80
+ echo 'dev-ruby/digest-kangarootwelve target_avx512 -target_compact' > /etc/portage/package.use/dev-ruby.digest-kangarootwelve
81
+
82
+ # To enable testing, FEATURES=test should be set in the environment, and
83
+ # test use flag should also be enabled.
84
+ printf '%s\n' 'FEATURES="${FEATURES-} test"' 'USE="${USE-} test"' > /etc/portage/env/test
85
+ echo 'dev-ruby/digest-kangarootwelve test' > /etc/portage/package.env/dev-ruby.digest-kangarootwelve
86
+
70
87
  # Merge package.
71
88
  emerge dev-ruby/digest-kangarootwelve
72
89
 
@@ -81,7 +98,7 @@ The gem can also be tested from source using the following commands:
81
98
  cd digest-kangarootwelve-ruby
82
99
 
83
100
  # Optionally checkout a tagged version.
84
- git checkout v0.4.0
101
+ git checkout v0.4.7
85
102
 
86
103
  # Run bundle
87
104
  bundle
@@ -97,7 +114,8 @@ The gem can also be tested from source using the following commands:
97
114
  Targets like AVX2 may fail to build unless an explicit `CFLAGS` with proper
98
115
  architecture-related options is specified.
99
116
 
100
- Specifying a `CFLAGS` can be done by using the `--with-cflags` option. For example:
117
+ Specifying a `CFLAGS` can be done by using the `--with-cflags` option. For
118
+ example:
101
119
 
102
120
  rake -- --with-target=avx2 --with-cflags="-march=native"
103
121
 
@@ -113,6 +131,8 @@ so please test the resulting runtime thoroughly.
113
131
 
114
132
  ## Example Usage
115
133
 
134
+ require 'digest/kangarootwelve'
135
+
116
136
  Digest::KangarooTwelve[32].digest("abc")
117
137
  => "\xAB\x17O2\x8CU\xA5Q\v\v \x97\x91\xBF\x8B`\xE8\x01\xA7\xCF\xC2\xAAB\x04-\xCB\x8FT\x7F\xBE:}"
118
138
 
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ end
20
20
 
21
21
  desc "Initialize and update XKCP submodule"
22
22
  task :initialize_xkcp => ".git" do |t|
23
- puts "Initializing and updating XKCP submodule"
23
+ puts "Initializing and updating XKCP submodule."
24
24
  system "git submodule init && git submodule update -f"
25
25
  end
26
26
 
@@ -30,16 +30,13 @@ file "XKCP/README.markdown" => :initialize_xkcp
30
30
  # import_xkcp_license
31
31
 
32
32
  task :import_xkcp_license do
33
- Rake::Task["XKCP/README.markdown"].invoke
34
- puts "Extracting XKCP license from \"XKCP/README.markdown\" and saving it to \"LICENSE.XKCP\"."
35
- license = File.binread("XKCP/README.markdown")
36
- .scan(/# Under which license is the XKCP.*?(?=^#)/m).first
37
- raise "No license extracted" unless license
38
- File.binwrite("LICENSE.XKCP", license.strip + "\n")
33
+ Rake::Task["XKCP/LICENSE"].invoke
34
+ puts "Importing XKCP/LICENSE as LICENSE.XKCP."
35
+ File.binwrite("LICENSE.XKCP", File.binread("XKCP/LICENSE"))
39
36
  end.instance_eval do
40
37
  def needed?
41
- !File.exist?("LICENSE.XKCP") || File.exist?("XKCP/README.markdown") &&
42
- File.mtime("LICENSE.XKCP") < File.mtime("XKCP/README.markdown")
38
+ !File.exist?("LICENSE.XKCP") || File.exist?("XKCP/LICENSE") &&
39
+ File.mtime("LICENSE.XKCP") < File.mtime("XKCP/LICENSE")
43
40
  end
44
41
  end
45
42
 
@@ -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
@@ -161,7 +161,7 @@ int SpongeAbsorb(SpongeInstance *instance, const unsigned char *data, size_t dat
161
161
  i = 0;
162
162
  curData = data;
163
163
  while(i < dataByteLen) {
164
- if ((instance->byteIOIndex == 0) && (dataByteLen >= (i + rateInBytes))) {
164
+ if ((instance->byteIOIndex == 0) && (dataByteLen-i >= rateInBytes)) {
165
165
  #ifdef SnP_FastLoop_Absorb
166
166
  /* processing full blocks first */
167
167
  if ((rateInBytes % (SnP_width/200)) == 0) {
@@ -187,9 +187,10 @@ int SpongeAbsorb(SpongeInstance *instance, const unsigned char *data, size_t dat
187
187
  }
188
188
  else {
189
189
  /* normal lane: using the message queue */
190
- partialBlock = (unsigned int)(dataByteLen - i);
191
- if (partialBlock+instance->byteIOIndex > rateInBytes)
190
+ if (dataByteLen-i > rateInBytes-instance->byteIOIndex)
192
191
  partialBlock = rateInBytes-instance->byteIOIndex;
192
+ else
193
+ partialBlock = (unsigned int)(dataByteLen - i);
193
194
  #ifdef KeccakReference
194
195
  displayBytes(1, "Block to be absorbed (part)", curData, partialBlock);
195
196
  #endif
@@ -264,7 +265,7 @@ int SpongeSqueeze(SpongeInstance *instance, unsigned char *data, size_t dataByte
264
265
  i = 0;
265
266
  curData = data;
266
267
  while(i < dataByteLen) {
267
- if ((instance->byteIOIndex == rateInBytes) && (dataByteLen >= (i + rateInBytes))) {
268
+ if ((instance->byteIOIndex == rateInBytes) && (dataByteLen-i >= rateInBytes)) {
268
269
  for(j=dataByteLen-i; j>=rateInBytes; j-=rateInBytes) {
269
270
  SnP_Permute(instance->state);
270
271
  SnP_ExtractBytes(instance->state, curData, 0, rateInBytes);
@@ -281,9 +282,10 @@ int SpongeSqueeze(SpongeInstance *instance, unsigned char *data, size_t dataByte
281
282
  SnP_Permute(instance->state);
282
283
  instance->byteIOIndex = 0;
283
284
  }
284
- partialBlock = (unsigned int)(dataByteLen - i);
285
- if (partialBlock+instance->byteIOIndex > rateInBytes)
285
+ if (dataByteLen-i > rateInBytes-instance->byteIOIndex)
286
286
  partialBlock = rateInBytes-instance->byteIOIndex;
287
+ else
288
+ partialBlock = (unsigned int)(dataByteLen - i);
287
289
  i += partialBlock;
288
290
 
289
291
  SnP_ExtractBytes(instance->state, curData, instance->byteIOIndex, partialBlock);