sha3 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.rspec +3 -1
  4. data/.rubocop.yml +6 -0
  5. data/Gemfile +3 -1
  6. data/README.md +10 -7
  7. data/Rakefile +10 -37
  8. data/certs/johanns.pem +25 -0
  9. data/ext/sha3/config.h +26 -0
  10. data/ext/sha3/digest.c +6 -6
  11. data/ext/sha3/extconf.rb +40 -16
  12. data/ext/sha3/lib/common/align.h +33 -0
  13. data/ext/sha3/{brg_endian.h → lib/common/brg_endian.h} +8 -7
  14. data/ext/sha3/{KeccakHash.c → lib/high/Keccak/FIPS202/KeccakHash.c} +26 -25
  15. data/ext/sha3/{KeccakHash.h → lib/high/Keccak/FIPS202/KeccakHash.h} +34 -19
  16. data/ext/sha3/lib/high/Keccak/KeccakSponge.c +111 -0
  17. data/ext/sha3/lib/high/Keccak/KeccakSponge.h +76 -0
  18. data/ext/sha3/lib/high/Keccak/KeccakSponge.inc +316 -0
  19. data/ext/sha3/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros +748 -0
  20. data/ext/sha3/lib/low/KeccakP-1600/common/KeccakP-1600-unrolling.macros +305 -0
  21. data/ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-SnP.h +44 -0
  22. data/ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference.h +23 -0
  23. data/ext/sha3/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference32BI.c +625 -0
  24. data/ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-SnP.h +44 -0
  25. data/ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.c +444 -0
  26. data/ext/sha3/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.h +23 -0
  27. data/lib/sha3/doc.rb +4 -4
  28. data/lib/sha3/version.rb +4 -4
  29. data/lib/sha3.rb +15 -13
  30. data/sha3.gemspec +53 -22
  31. data/tests.sh +8 -7
  32. data.tar.gz.sig +0 -0
  33. metadata +100 -51
  34. metadata.gz.sig +0 -0
  35. data/.gitignore +0 -234
  36. data/.travis.yml +0 -21
  37. data/Gemfile.ci +0 -8
  38. data/ext/sha3/KeccakF-1600-interface.h +0 -40
  39. data/ext/sha3/KeccakSponge.c +0 -192
  40. data/ext/sha3/KeccakSponge.h +0 -113
  41. data/ext/sha3/Optimized64/KeccakF-1600-64.macros +0 -2199
  42. data/ext/sha3/Optimized64/KeccakF-1600-opt64-settings.h +0 -3
  43. data/ext/sha3/Optimized64/KeccakF-1600-opt64.c +0 -508
  44. data/ext/sha3/Optimized64/KeccakF-1600-unrolling.macros +0 -126
  45. data/ext/sha3/Optimized64/SnP-interface.h +0 -47
  46. data/ext/sha3/Reference/KeccakF-1600-reference.c +0 -311
  47. data/ext/sha3/Reference/KeccakF-reference.h +0 -26
  48. data/ext/sha3/Reference/SnP-FBWL-default.c +0 -96
  49. data/ext/sha3/Reference/SnP-FBWL-default.h +0 -26
  50. data/ext/sha3/Reference/SnP-interface.h +0 -42
  51. data/ext/sha3/Reference/displayIntermediateValues.c +0 -158
  52. data/ext/sha3/Reference/displayIntermediateValues.h +0 -34
  53. data/ext/sha3/SnP-Relaned.h +0 -249
  54. data/spec/generate_tests.rb +0 -49
  55. data/spec/sha3_core_spec.rb +0 -148
  56. data/spec/spec_helper.rb +0 -4
@@ -1,249 +0,0 @@
1
- /*
2
- Implementation by the Keccak, Keyak and Ketje Teams, namely, Guido Bertoni,
3
- Joan Daemen, Michaël Peeters, Gilles Van Assche and Ronny Van Keer, hereby
4
- denoted as "the implementer".
5
-
6
- For more information, feedback or questions, please refer to our websites:
7
- http://keccak.noekeon.org/
8
- http://keyak.noekeon.org/
9
- http://ketje.noekeon.org/
10
-
11
- To the extent possible under law, the implementer has waived all copyright
12
- and related or neighboring rights to the source code in this file.
13
- http://creativecommons.org/publicdomain/zero/1.0/
14
- */
15
-
16
- #ifndef _SnP_Relaned_h_
17
- #define _SnP_Relaned_h_
18
-
19
- /** Function to XOR data given as bytes into the state.
20
- * The bits to modify are restricted to be consecutive and to be in the same lane.
21
- * The bit positions that are affected by this function are
22
- * from @a lanePosition*(lane size in bits) + @a offset*8
23
- * to @a lanePosition*(lane size in bits) + @a offset*8 + @a length*8.
24
- * (The bit positions, the x,y,z coordinates and their link are defined in the "Keccak reference".)
25
- * @param state Pointer to the state.
26
- * @param lanePosition Index of the lane to be modified (x+5*y,
27
- * or bit position divided by the lane size).
28
- * @param data Pointer to the input data.
29
- * @param offset Offset in bytes within the lane.
30
- * @param length Number of bytes.
31
- * @pre 0 ≤ @a lanePosition < 25
32
- * @pre 0 ≤ @a offset < (lane size in bytes)
33
- * @pre 0 ≤ @a offset + @a length ≤ (lane size in bytes)
34
- */
35
- void SnP_XORBytesInLane(void *state, unsigned int lanePosition, const unsigned char *data, unsigned int offset, unsigned int length);
36
-
37
- /** Function to XOR data given as bytes into the state.
38
- * The bits to modify are restricted to start from the bit position 0 and
39
- * to span a whole number of lanes.
40
- * @param state Pointer to the state.
41
- * @param data Pointer to the input data.
42
- * @param laneCount The number of lanes, i.e., the length of the data
43
- * divided by the lane size.
44
- * @pre 0 ≤ @a laneCount ≤ 25
45
- */
46
- void SnP_XORLanes(void *state, const unsigned char *data, unsigned int laneCount);
47
-
48
- /** Function to overwrite data given as bytes into the state.
49
- * The bits to modify are restricted to be consecutive and to be in the same lane.
50
- * The bit positions that are affected by this function are
51
- * from @a lanePosition*(lane size in bits) + @a offset*8
52
- * to @a lanePosition*(lane size in bits) + @a offset*8 + @a length*8.
53
- * (The bit positions, the x,y,z coordinates and their link are defined in the "Keccak reference".)
54
- * @param state Pointer to the state.
55
- * @param lanePosition Index of the lane to be modified (x+5*y,
56
- * or bit position divided by the lane size).
57
- * @param data Pointer to the input data.
58
- * @param offset Offset in bytes within the lane.
59
- * @param length Number of bytes.
60
- * @pre 0 ≤ @a lanePosition < 25
61
- * @pre 0 ≤ @a offset < (lane size in bytes)
62
- * @pre 0 ≤ @a offset + @a length ≤ (lane size in bytes)
63
- */
64
- void SnP_OverwriteBytesInLane(void *state, unsigned int lanePosition, const unsigned char *data, unsigned int offset, unsigned int length);
65
-
66
- /** Function to overwrite data given as bytes into the state.
67
- * The bits to modify are restricted to start from the bit position 0 and
68
- * to span a whole number of lanes.
69
- * @param state Pointer to the state.
70
- * @param data Pointer to the input data.
71
- * @param laneCount The number of lanes, i.e., the length of the data
72
- * divided by the lane size.
73
- * @pre 0 ≤ @a laneCount ≤ 25
74
- */
75
- void SnP_OverwriteLanes(void *state, const unsigned char *data, unsigned int laneCount);
76
-
77
- /** Function to retrieve data from the state into bytes.
78
- * The bits to output are restricted to be consecutive and to be in the same lane.
79
- * The bit positions that are retrieved by this function are
80
- * from @a lanePosition*(lane size in bits) + @a offset*8
81
- * to @a lanePosition*(lane size in bits) + @a offset*8 + @a length*8.
82
- * (The bit positions, the x,y,z coordinates and their link are defined in the "Keccak reference".)
83
- * @param state Pointer to the state.
84
- * @param lanePosition Index of the lane to be read (x+5*y,
85
- * or bit position divided by the lane size).
86
- * @param data Pointer to the area where to store output data.
87
- * @param offset Offset in byte within the lane.
88
- * @param length Number of bytes.
89
- * @pre 0 ≤ @a lanePosition < 25
90
- * @pre 0 ≤ @a offset < (lane size in bytes)
91
- * @pre 0 ≤ @a offset + @a length ≤ (lane size in bytes)
92
- */
93
- void SnP_ExtractBytesInLane(const void *state, unsigned int lanePosition, unsigned char *data, unsigned int offset, unsigned int length);
94
-
95
- /** Function to retrieve data from the state into bytes.
96
- * The bits to output are restricted to start from the bit position 0 and
97
- * to span a whole number of lanes.
98
- * @param state Pointer to the state.
99
- * @param data Pointer to the area where to store output data.
100
- * @param laneCount The number of lanes, i.e., the length of the data
101
- * divided by the lane size.
102
- * @pre 0 ≤ @a laneCount ≤ 25
103
- */
104
- void SnP_ExtractLanes(const void *state, unsigned char *data, unsigned int laneCount);
105
-
106
- /** Function to retrieve data from the state into bytes and
107
- * to XOR them into the output buffer.
108
- * The bits to output are restricted to be consecutive and to be in the same lane.
109
- * The bit positions that are retrieved by this function are
110
- * from @a lanePosition*(lane size in bits) + @a offset*8
111
- * to @a lanePosition*(lane size in bits) + @a offset*8 + @a length*8.
112
- * (The bit positions, the x,y,z coordinates and their link are defined in the "Keccak reference".)
113
- * @param state Pointer to the state.
114
- * @param lanePosition Index of the lane to be read (x+5*y,
115
- * or bit position divided by the lane size).
116
- * @param data Pointer to the area where to XOR output data.
117
- * @param offset Offset in byte within the lane.
118
- * @param length Number of bytes.
119
- * @pre 0 ≤ @a lanePosition < 25
120
- * @pre 0 ≤ @a offset < (lane size in bytes)
121
- * @pre 0 ≤ @a offset + @a length ≤ (lane size in bytes)
122
- */
123
- void SnP_ExtractAndXORBytesInLane(const void *state, unsigned int lanePosition, unsigned char *data, unsigned int offset, unsigned int length);
124
-
125
- /** Function to retrieve data from the state into bytes and
126
- * to XOR them into the output buffer.
127
- * The bits to output are restricted to start from the bit position 0 and
128
- * to span a whole number of lanes.
129
- * @param state Pointer to the state.
130
- * @param data Pointer to the area where to XOR output data.
131
- * @param laneCount The number of lanes, i.e., the length of the data
132
- * divided by the lane size.
133
- * @pre 0 ≤ @a laneCount ≤ 25
134
- */
135
- void SnP_ExtractAndXORLanes(const void *state, unsigned char *data, unsigned int laneCount);
136
-
137
- #define SnP_XORBytes(state, data, offset, length) \
138
- { \
139
- if ((offset) == 0) { \
140
- SnP_XORLanes(state, data, (length)/SnP_laneLengthInBytes); \
141
- SnP_XORBytesInLane(state, \
142
- (length)/SnP_laneLengthInBytes, \
143
- (data)+((length)/SnP_laneLengthInBytes)*SnP_laneLengthInBytes, \
144
- 0, \
145
- (length)%SnP_laneLengthInBytes); \
146
- } \
147
- else { \
148
- unsigned int _sizeLeft = (length); \
149
- unsigned int _lanePosition = (offset)/SnP_laneLengthInBytes; \
150
- unsigned int _offsetInLane = (offset)%SnP_laneLengthInBytes; \
151
- const unsigned char *_curData = (data); \
152
- while(_sizeLeft > 0) { \
153
- unsigned int _bytesInLane = SnP_laneLengthInBytes - _offsetInLane; \
154
- if (_bytesInLane > _sizeLeft) \
155
- _bytesInLane = _sizeLeft; \
156
- SnP_XORBytesInLane(state, _lanePosition, _curData, _offsetInLane, _bytesInLane); \
157
- _sizeLeft -= _bytesInLane; \
158
- _lanePosition++; \
159
- _offsetInLane = 0; \
160
- _curData += _bytesInLane; \
161
- } \
162
- } \
163
- }
164
-
165
- #define SnP_OverwriteBytes(state, data, offset, length) \
166
- { \
167
- if ((offset) == 0) { \
168
- SnP_OverwriteLanes(state, data, (length)/SnP_laneLengthInBytes); \
169
- SnP_OverwriteBytesInLane(state, \
170
- (length)/SnP_laneLengthInBytes, \
171
- (data)+((length)/SnP_laneLengthInBytes)*SnP_laneLengthInBytes, \
172
- 0, \
173
- (length)%SnP_laneLengthInBytes); \
174
- } \
175
- else { \
176
- unsigned int _sizeLeft = (length); \
177
- unsigned int _lanePosition = (offset)/SnP_laneLengthInBytes; \
178
- unsigned int _offsetInLane = (offset)%SnP_laneLengthInBytes; \
179
- const unsigned char *_curData = (data); \
180
- while(_sizeLeft > 0) { \
181
- unsigned int _bytesInLane = SnP_laneLengthInBytes - _offsetInLane; \
182
- if (_bytesInLane > _sizeLeft) \
183
- _bytesInLane = _sizeLeft; \
184
- SnP_OverwriteBytesInLane(state, _lanePosition, _curData, _offsetInLane, _bytesInLane); \
185
- _sizeLeft -= _bytesInLane; \
186
- _lanePosition++; \
187
- _offsetInLane = 0; \
188
- _curData += _bytesInLane; \
189
- } \
190
- } \
191
- }
192
-
193
- #define SnP_ExtractBytes(state, data, offset, length) \
194
- { \
195
- if ((offset) == 0) { \
196
- SnP_ExtractLanes(state, data, (length)/SnP_laneLengthInBytes); \
197
- SnP_ExtractBytesInLane(state, \
198
- (length)/SnP_laneLengthInBytes, \
199
- (data)+((length)/SnP_laneLengthInBytes)*SnP_laneLengthInBytes, \
200
- 0, \
201
- (length)%SnP_laneLengthInBytes); \
202
- } \
203
- else { \
204
- unsigned int _sizeLeft = (length); \
205
- unsigned int _lanePosition = (offset)/SnP_laneLengthInBytes; \
206
- unsigned int _offsetInLane = (offset)%SnP_laneLengthInBytes; \
207
- unsigned char *_curData = (data); \
208
- while(_sizeLeft > 0) { \
209
- unsigned int _bytesInLane = SnP_laneLengthInBytes - _offsetInLane; \
210
- if (_bytesInLane > _sizeLeft) \
211
- _bytesInLane = _sizeLeft; \
212
- SnP_ExtractBytesInLane(state, _lanePosition, _curData, _offsetInLane, _bytesInLane); \
213
- _sizeLeft -= _bytesInLane; \
214
- _lanePosition++; \
215
- _offsetInLane = 0; \
216
- _curData += _bytesInLane; \
217
- } \
218
- } \
219
- }
220
-
221
- #define SnP_ExtractAndXORBytes(state, data, offset, length) \
222
- { \
223
- if ((offset) == 0) { \
224
- SnP_ExtractAndXORLanes(state, data, (length)/SnP_laneLengthInBytes); \
225
- SnP_ExtractAndXORBytesInLane(state, \
226
- (length)/SnP_laneLengthInBytes, \
227
- (data)+((length)/SnP_laneLengthInBytes)*SnP_laneLengthInBytes, \
228
- 0, \
229
- (length)%SnP_laneLengthInBytes); \
230
- } \
231
- else { \
232
- unsigned int _sizeLeft = (length); \
233
- unsigned int _lanePosition = (offset)/SnP_laneLengthInBytes; \
234
- unsigned int _offsetInLane = (offset)%SnP_laneLengthInBytes; \
235
- unsigned char *_curData = (data); \
236
- while(_sizeLeft > 0) { \
237
- unsigned int _bytesInLane = SnP_laneLengthInBytes - _offsetInLane; \
238
- if (_bytesInLane > _sizeLeft) \
239
- _bytesInLane = _sizeLeft; \
240
- SnP_ExtractAndXORBytesInLane(state, _lanePosition, _curData, _offsetInLane, _bytesInLane); \
241
- _sizeLeft -= _bytesInLane; \
242
- _lanePosition++; \
243
- _offsetInLane = 0; \
244
- _curData += _bytesInLane; \
245
- } \
246
- } \
247
- }
248
-
249
- #endif
@@ -1,49 +0,0 @@
1
- # Based on python-sha3's / digest-sha3 test generator.
2
-
3
- FILES = [
4
- ['data/ShortMsgKAT_SHA3-224.txt', 224],
5
- ['data/ShortMsgKAT_SHA3-256.txt', 256],
6
- ['data/ShortMsgKAT_SHA3-384.txt', 384],
7
- ['data/ShortMsgKAT_SHA3-512.txt', 512]
8
- ].freeze
9
-
10
- def gen_digest_byte_tests
11
- FILES.each do |path, hashlen|
12
- name = File.basename(path).split('.')[0]
13
-
14
- f = File.new("sha3_digest_#{name}_spec.rb", 'w')
15
- f.puts(
16
- %{require 'spec_helper'
17
- require 'sha3'
18
-
19
- describe "SHA3::Digest.new(#{hashlen})" do
20
- it "should match byte-length test vectors (#{name})." do
21
- }
22
- )
23
- contents = File.read(path).split('Len = ')
24
- contents.each do |test|
25
- lines = test.split("\n")
26
- next unless !lines.empty? && lines[0] !~ /^#/
27
-
28
- length = lines[0].to_i
29
- next unless (length % 8).zero? && length != 0
30
-
31
- msg_raw = [lines[1].split(' = ').last].pack('H*')
32
- md = lines[2].split(' = ').last.downcase
33
- f.puts(
34
- %{ expect(SHA3::Digest.new(#{hashlen}, #{msg_raw.inspect}).hexdigest).to eq("#{md}")
35
- }
36
- )
37
- end
38
- f.puts(
39
- %( end
40
- end
41
- )
42
- )
43
- f.close
44
- end
45
- end
46
-
47
- def setup; end
48
-
49
- gen_digest_byte_tests
@@ -1,148 +0,0 @@
1
- require 'spec_helper'
2
- require 'sha3'
3
-
4
- RSpec.describe SHA3 do
5
- it 'should have a VERSION constant' do
6
- expect(subject.const_get('VERSION')).not_to be_empty
7
- end
8
-
9
- it 'should have a KECCAK_VERSION constant' do
10
- expect(subject.const_get('KECCAK_VERSION')).not_to be_empty
11
- end
12
-
13
- it 'should have Digest class' do
14
- expect(subject.const_get('Digest').is_a?(Class)).to be_truthy
15
- end
16
- end
17
-
18
- RSpec.describe SHA3::Digest do
19
- it 'should pass Digest.new() (default: :sha256) usage test' do
20
- sha = SHA3::Digest.new()
21
-
22
- expect(sha.hexdigest).to eq('a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a')
23
- expect(sha.update(['cc'].pack('H*'))).to eq('677035391cd3701293d385f037ba32796252bb7ce180b00b582dd9b20aaad7f0')
24
- expect(sha.reset).to eq('a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a')
25
-
26
- sha << (['6172f1971a6e1e4e6170afbad95d5fec99bf69b24b674bc17dd78011615e502de6f56b86b1a71d3f4348087218ac7b7d09302993be272e4a591968aef18a1262d665610d1070ee91cc8da36e1f841a69a7a682c580e836941d21d909a3afc1f0b963e1ca5ab193e124a1a53df1c587470e5881fb54dae1b0d840f0c8f9d1b04c645ba1041c7d8dbf22030a623aa15638b3d99a2c400ff76f3252079af88d2b37f35ee66c1ad7801a28d3d388ac450b97d5f0f79e4541755356b3b1a5696b023f39ab7ab5f28df4202936bc97393b93bc915cb159ea1bd7a0a414cb4b7a1ac3af68f50d79f0c9c7314e750f7d02faa58bfa'].pack('H*'))
27
-
28
- expect(sha.hexdigest).to eq('f60c53ba2132293b881f0513e7ab47fe9746ed4a6ac9cade61e6d802d5872372')
29
- expect(sha.digest_length).to eq(32)
30
- expect(sha.block_length).to eq(136)
31
- end
32
-
33
- it 'should pass Digest.new(:sha224) usage test' do
34
- sha = SHA3::Digest.new(:sha224)
35
-
36
- expect(sha.hexdigest).to eq('6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7')
37
- expect(sha.update(['cc'].pack('H*'))).to eq('df70adc49b2e76eee3a6931b93fa41841c3af2cdf5b32a18b5478c39')
38
- expect(sha.reset).to eq('6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7')
39
-
40
- sha << (['5fce8109a358570e40983e1184e541833bb9091e280f258cfb144387b05d190e431cb19baa67273ba0c58abe91308e1844dcd0b3678baa42f335f2fa05267a0240b3c718a5942b3b3e3bfa98a55c25a1466e8d7a603722cb2bbf03afa54cd769a99f310735ee5a05dae2c22d397bd95635f58c48a67f90e1b73aafcd3f82117f0166657838691005b18da6f341d6e90fc1cdb352b30fae45d348294e501b63252de14740f2b85ae5299ddec3172de8b6d0ba219a20a23bb5e10ff434d39db3f583305e9f5c039d98569e377b75a70ab837d1df269b8a4b566f40bb91b577455fd3c356c914fa06b9a7ce24c7317a172d'].pack('H*'))
41
-
42
- expect(sha.hexdigest).to eq('2ebe13f12ec43e3f6b0506d7ab216e1c311394f7c89d69a920cd00c0')
43
- expect(sha.digest_length).to eq(28)
44
- expect(sha.block_length).to eq(144)
45
- end
46
-
47
- it 'should pass Digest.new(:sha256) usage test' do
48
- sha = SHA3::Digest.new(:sha256)
49
-
50
- expect(sha.hexdigest).to eq('a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a')
51
- expect(sha.update(['cc'].pack('H*'))).to eq('677035391cd3701293d385f037ba32796252bb7ce180b00b582dd9b20aaad7f0')
52
- expect(sha.reset).to eq('a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a')
53
-
54
- sha << (['6172f1971a6e1e4e6170afbad95d5fec99bf69b24b674bc17dd78011615e502de6f56b86b1a71d3f4348087218ac7b7d09302993be272e4a591968aef18a1262d665610d1070ee91cc8da36e1f841a69a7a682c580e836941d21d909a3afc1f0b963e1ca5ab193e124a1a53df1c587470e5881fb54dae1b0d840f0c8f9d1b04c645ba1041c7d8dbf22030a623aa15638b3d99a2c400ff76f3252079af88d2b37f35ee66c1ad7801a28d3d388ac450b97d5f0f79e4541755356b3b1a5696b023f39ab7ab5f28df4202936bc97393b93bc915cb159ea1bd7a0a414cb4b7a1ac3af68f50d79f0c9c7314e750f7d02faa58bfa'].pack('H*'))
55
-
56
- expect(sha.hexdigest).to eq('f60c53ba2132293b881f0513e7ab47fe9746ed4a6ac9cade61e6d802d5872372')
57
- expect(sha.digest_length).to eq(32)
58
- expect(sha.block_length).to eq(136)
59
- end
60
-
61
- it 'should pass Digest.new(:sha384) usage test' do
62
- sha = SHA3::Digest.new(:sha384)
63
-
64
- expect(sha.hexdigest).to eq('0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004')
65
-
66
- expect(sha.update(['cc'].pack('H*'))).to eq('5ee7f374973cd4bb3dc41e3081346798497ff6e36cb9352281dfe07d07fc530ca9ad8ef7aad56ef5d41be83d5e543807')
67
- expect(sha.reset).to eq('0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004')
68
-
69
- sha << (['3b8e97c5ffc2d6a40fa7de7fcefc90f3b12c940e7ab415321e29ee692dfac799b009c99dcddb708fce5a178c5c35ee2b8617143edc4c40b4d313661f49abdd93cea79d117518805496fe6acf292c4c2a1f76b403a97d7c399daf85b46ad84e16246c67d6836757bde336c290d5d401e6c1386ab32797af6bb251e9b2d8fe754c47482b72e0b394eab76916126fd68ea7d65eb93d59f5b4c5ac40f7c3b37e7f3694f29424c24af8c8f0ef59cd9dbf1d28e0e10f799a6f78cad1d45b9db3d7dee4a7059abe99182714983b9c9d44d7f5643596d4f3'].pack('H*'))
70
-
71
- expect(sha.hexdigest).to eq('9b809198dcce24175e33098331d3a402a821ae9326e72775aae34d1a9bb53d2b57863905cfd60543bbc42b454007c315')
72
- expect(sha.digest_length).to eq(48)
73
- expect(sha.block_length).to eq(104)
74
- end
75
-
76
- it 'should pass Digest.new(:sha512) usage test' do
77
- sha = SHA3::Digest.new(:sha512)
78
-
79
- expect(sha.hexdigest).to eq('a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26')
80
- expect(sha.update(['cc'].pack('H*'))).to eq('3939fcc8b57b63612542da31a834e5dcc36e2ee0f652ac72e02624fa2e5adeecc7dd6bb3580224b4d6138706fc6e80597b528051230b00621cc2b22999eaa205')
81
- expect(sha.reset).to eq('a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26')
82
-
83
- sha << (['03d625488354df30e3f875a68edfcf340e8366a8e1ab67f9d5c5486a96829dfac0578289082b2a62117e1cf418b43b90e0adc881fc6ae8105c888e9ecd21aea1c9ae1a4038dfd17378fed71d02ae492087d7cdcd98f746855227967cb1ab4714261ee3bead3f4db118329d3ebef4bc48a875c19ba763966da0ebea800e01b2f50b00e9dd4caca6dcb314d00184ef71ea2391d760c950710db4a70f9212ffc54861f9dc752ce18867b8ad0c48df8466ef7231e7ac567f0eb55099e622ebb86cb237520190a61c66ad34f1f4e289cb3282ae3eaac6152ed24d2c92bae5a7658252a53c49b7b02dfe54fdb2e90074b6cf310ac661'].pack('H*'))
84
-
85
- expect(sha.hexdigest).to eq('1fcd1e38ab03c750366cf86dd72ec3bf22f5bbf7fea0149d31b6a67b68b537b59ba37917fd88ced9aa8d2941a65f552b7928b3785c66d640f3b74af039ed18ce')
86
- expect(sha.digest_length).to eq(64)
87
- expect(sha.block_length).to eq(72)
88
- end
89
- end
90
-
91
- RSpec.describe 'SHA3::Digest::SHAxyz' do
92
- it 'should pass Digest.SHA224() usage test' do
93
- sha = SHA3::Digest::SHA224.new()
94
-
95
- expect(sha.hexdigest).to eq('6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7')
96
- expect(sha.update(['cc'].pack('H*'))).to eq('df70adc49b2e76eee3a6931b93fa41841c3af2cdf5b32a18b5478c39')
97
- expect(sha.reset).to eq('6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7')
98
-
99
- sha << (['5fce8109a358570e40983e1184e541833bb9091e280f258cfb144387b05d190e431cb19baa67273ba0c58abe91308e1844dcd0b3678baa42f335f2fa05267a0240b3c718a5942b3b3e3bfa98a55c25a1466e8d7a603722cb2bbf03afa54cd769a99f310735ee5a05dae2c22d397bd95635f58c48a67f90e1b73aafcd3f82117f0166657838691005b18da6f341d6e90fc1cdb352b30fae45d348294e501b63252de14740f2b85ae5299ddec3172de8b6d0ba219a20a23bb5e10ff434d39db3f583305e9f5c039d98569e377b75a70ab837d1df269b8a4b566f40bb91b577455fd3c356c914fa06b9a7ce24c7317a172d'].pack("H*"))
100
-
101
- expect(sha.hexdigest).to eq('2ebe13f12ec43e3f6b0506d7ab216e1c311394f7c89d69a920cd00c0')
102
- expect(sha.digest_length).to eq(28)
103
- expect(sha.block_length).to eq(144)
104
- end
105
-
106
- it 'should pass Digest.SHA256() usage test' do
107
- sha = SHA3::Digest::SHA256.new()
108
-
109
- expect(sha.hexdigest).to eq('a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a')
110
- expect(sha.update(['cc'].pack('H*'))).to eq('677035391cd3701293d385f037ba32796252bb7ce180b00b582dd9b20aaad7f0')
111
- expect(sha.reset).to eq('a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a')
112
-
113
- sha << (['6172f1971a6e1e4e6170afbad95d5fec99bf69b24b674bc17dd78011615e502de6f56b86b1a71d3f4348087218ac7b7d09302993be272e4a591968aef18a1262d665610d1070ee91cc8da36e1f841a69a7a682c580e836941d21d909a3afc1f0b963e1ca5ab193e124a1a53df1c587470e5881fb54dae1b0d840f0c8f9d1b04c645ba1041c7d8dbf22030a623aa15638b3d99a2c400ff76f3252079af88d2b37f35ee66c1ad7801a28d3d388ac450b97d5f0f79e4541755356b3b1a5696b023f39ab7ab5f28df4202936bc97393b93bc915cb159ea1bd7a0a414cb4b7a1ac3af68f50d79f0c9c7314e750f7d02faa58bfa'].pack("H*"))
114
-
115
- expect(sha.hexdigest).to eq('f60c53ba2132293b881f0513e7ab47fe9746ed4a6ac9cade61e6d802d5872372')
116
- expect(sha.digest_length).to eq(32)
117
- expect(sha.block_length).to eq(136)
118
- end
119
-
120
- it 'should pass Digest.SHA384() usage test' do
121
- sha = SHA3::Digest::SHA384.new()
122
-
123
- expect(sha.hexdigest).to eq('0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004')
124
-
125
- expect(sha.update(['cc'].pack('H*'))).to eq('5ee7f374973cd4bb3dc41e3081346798497ff6e36cb9352281dfe07d07fc530ca9ad8ef7aad56ef5d41be83d5e543807')
126
- expect(sha.reset).to eq('0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004')
127
-
128
- sha << (['3b8e97c5ffc2d6a40fa7de7fcefc90f3b12c940e7ab415321e29ee692dfac799b009c99dcddb708fce5a178c5c35ee2b8617143edc4c40b4d313661f49abdd93cea79d117518805496fe6acf292c4c2a1f76b403a97d7c399daf85b46ad84e16246c67d6836757bde336c290d5d401e6c1386ab32797af6bb251e9b2d8fe754c47482b72e0b394eab76916126fd68ea7d65eb93d59f5b4c5ac40f7c3b37e7f3694f29424c24af8c8f0ef59cd9dbf1d28e0e10f799a6f78cad1d45b9db3d7dee4a7059abe99182714983b9c9d44d7f5643596d4f3'].pack("H*"))
129
-
130
- expect(sha.hexdigest).to eq('9b809198dcce24175e33098331d3a402a821ae9326e72775aae34d1a9bb53d2b57863905cfd60543bbc42b454007c315')
131
- expect(sha.digest_length).to eq(48)
132
- expect(sha.block_length).to eq(104)
133
- end
134
-
135
- it 'should pass Digest.SHA512() usage test' do
136
- sha = SHA3::Digest::SHA512.new()
137
-
138
- expect(sha.hexdigest).to eq('a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26')
139
- expect(sha.update(['cc'].pack('H*'))).to eq('3939fcc8b57b63612542da31a834e5dcc36e2ee0f652ac72e02624fa2e5adeecc7dd6bb3580224b4d6138706fc6e80597b528051230b00621cc2b22999eaa205')
140
- expect(sha.reset).to eq('a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26')
141
-
142
- sha << (['03d625488354df30e3f875a68edfcf340e8366a8e1ab67f9d5c5486a96829dfac0578289082b2a62117e1cf418b43b90e0adc881fc6ae8105c888e9ecd21aea1c9ae1a4038dfd17378fed71d02ae492087d7cdcd98f746855227967cb1ab4714261ee3bead3f4db118329d3ebef4bc48a875c19ba763966da0ebea800e01b2f50b00e9dd4caca6dcb314d00184ef71ea2391d760c950710db4a70f9212ffc54861f9dc752ce18867b8ad0c48df8466ef7231e7ac567f0eb55099e622ebb86cb237520190a61c66ad34f1f4e289cb3282ae3eaac6152ed24d2c92bae5a7658252a53c49b7b02dfe54fdb2e90074b6cf310ac661'].pack("H*"))
143
-
144
- expect(sha.hexdigest).to eq('1fcd1e38ab03c750366cf86dd72ec3bf22f5bbf7fea0149d31b6a67b68b537b59ba37917fd88ced9aa8d2941a65f552b7928b3785c66d640f3b74af039ed18ce')
145
- expect(sha.digest_length).to eq(64)
146
- expect(sha.block_length).to eq(72)
147
- end
148
- end
data/spec/spec_helper.rb DELETED
@@ -1,4 +0,0 @@
1
- gem 'rspec'
2
-
3
- require 'rspec'
4
- require 'sha3/version'