sha3 0.2.2 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sha3 might be problematic. Click here for more details.

Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +232 -17
  3. data/.travis.yml +21 -12
  4. data/.yardopts +1 -1
  5. data/ChangeLog.rdoc +16 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.ci +5 -5
  8. data/LICENSE.txt +1 -1
  9. data/README.md +120 -0
  10. data/Rakefile +15 -18
  11. data/ext/sha3/KeccakF-1600-interface.h +28 -34
  12. data/ext/sha3/KeccakHash.c +80 -0
  13. data/ext/sha3/KeccakHash.h +110 -0
  14. data/ext/sha3/KeccakSponge.c +127 -201
  15. data/ext/sha3/KeccakSponge.h +74 -37
  16. data/ext/sha3/Optimized64/KeccakF-1600-64.macros +2199 -0
  17. data/ext/sha3/Optimized64/KeccakF-1600-opt64-settings.h +3 -0
  18. data/ext/sha3/Optimized64/KeccakF-1600-opt64.c +508 -0
  19. data/ext/sha3/{KeccakF-1600-unrolling.macros → Optimized64/KeccakF-1600-unrolling.macros} +16 -14
  20. data/ext/sha3/Optimized64/SnP-interface.h +47 -0
  21. data/ext/sha3/Reference/KeccakF-1600-reference.c +311 -0
  22. data/ext/sha3/Reference/KeccakF-reference.h +26 -0
  23. data/ext/sha3/Reference/SnP-FBWL-default.c +96 -0
  24. data/ext/sha3/Reference/SnP-FBWL-default.h +26 -0
  25. data/ext/sha3/Reference/SnP-interface.h +42 -0
  26. data/ext/sha3/{displayIntermediateValues.c → Reference/displayIntermediateValues.c} +52 -11
  27. data/ext/sha3/{displayIntermediateValues.h → Reference/displayIntermediateValues.h} +11 -6
  28. data/ext/sha3/SnP-Relaned.h +249 -0
  29. data/ext/sha3/brg_endian.h +0 -0
  30. data/ext/sha3/digest.c +270 -0
  31. data/ext/sha3/digest.h +48 -0
  32. data/ext/sha3/extconf.rb +16 -9
  33. data/ext/sha3/sha3.c +62 -0
  34. data/ext/sha3/sha3.h +26 -0
  35. data/lib/sha3.rb +1 -1
  36. data/lib/sha3/doc.rb +121 -0
  37. data/lib/sha3/version.rb +6 -5
  38. data/sha3.gemspec +13 -15
  39. data/spec/generate_tests.rb +22 -56
  40. data/spec/sha3_core_spec.rb +113 -133
  41. data/spec/spec_helper.rb +2 -2
  42. data/tests.sh +11 -9
  43. metadata +53 -65
  44. data/README.rdoc +0 -133
  45. data/ext/sha3/KeccakF-1600-32-rvk.macros +0 -555
  46. data/ext/sha3/KeccakF-1600-32-s1.macros +0 -1187
  47. data/ext/sha3/KeccakF-1600-32-s2.macros +0 -1187
  48. data/ext/sha3/KeccakF-1600-32.macros +0 -26
  49. data/ext/sha3/KeccakF-1600-64.macros +0 -728
  50. data/ext/sha3/KeccakF-1600-int-set.h +0 -6
  51. data/ext/sha3/KeccakF-1600-opt.c +0 -504
  52. data/ext/sha3/KeccakF-1600-opt32-settings.h +0 -4
  53. data/ext/sha3/KeccakF-1600-opt32.c-arch +0 -524
  54. data/ext/sha3/KeccakF-1600-opt64-settings.h +0 -7
  55. data/ext/sha3/KeccakF-1600-opt64.c-arch +0 -504
  56. data/ext/sha3/KeccakF-1600-reference.c-arch +0 -300
  57. data/ext/sha3/KeccakF-1600-x86-64-gas.s +0 -766
  58. data/ext/sha3/KeccakF-1600-x86-64-shld-gas.s +0 -766
  59. data/ext/sha3/KeccakNISTInterface.c +0 -81
  60. data/ext/sha3/KeccakNISTInterface.h +0 -70
  61. data/ext/sha3/_sha3.c +0 -309
  62. data/ext/sha3/_sha3.h +0 -32
@@ -0,0 +1,121 @@
1
+ require 'digest'
2
+
3
+ module SHA3
4
+ # A sub-class of (MRI Ruby based) Digest::Class, it implements SHA3 (Keccak) digest algorithm.
5
+ #
6
+ # @note SHA3::Digest class provides a four sub-classes for the available hash bit lengths (types).
7
+ # You can instantiate a new instance of Digest sub-class for a given type using the following sub-classes:
8
+ #
9
+ # SHA3::Digest::SHA224([data])
10
+ # SHA3::Digest::SHA256([data])
11
+ # SHA3::Digest::SHA384([data])
12
+ # SHA3::Digest::SHA512([data])
13
+ #
14
+ # The [data] parameter is optional.
15
+ class Digest < Digest::Class
16
+ # Creates a Digest instance based on given hash bit length (type).
17
+ #
18
+ # @param type [Number, Symbol] optional parameter used to set hash bit length (type).
19
+ # Valid options are:
20
+ #
21
+ # Number: 224, 256, 384, or 512
22
+ # Symobols: :sha224, :sha256, :sha384, or :sha512
23
+ #
24
+ # Default value: 256 (bits)
25
+ # @param data [String] optional parameter used to update initial instance state.
26
+ # #
27
+ # @return [Digest] self
28
+ #
29
+ # @example
30
+ # digest = SHA3::Digest.new # => Defaults to 256 bits
31
+ # digest = SHA3::Digest.new(224) # => Initialize a new 224 bit digest instance
32
+ # digest = SHA3::Digest::SHA224 # => An alternate method for creating a digest class with 224 bit hash bit length
33
+ def initialize(type, data)
34
+ # See function: c_digest_init(...) in ext/sha3/_digest.c
35
+ end
36
+
37
+ # Updates, and recalculates Message Digest (state) with given data. If a message digest
38
+ # is to be computed from several subsequent sources, then each may be passed individually
39
+ # to the Digest instance.
40
+ #
41
+ # @param data [String] data to compute
42
+ #
43
+ # @return [Digest] self
44
+ #
45
+ # @example
46
+ # digest = SHA3::Digest::SHA256.new
47
+ # digest.update('hash me')
48
+ # digest.update('me too')
49
+ def update(data)
50
+ # See function: c_digest_update(...) in ext/sha3/_digest.c
51
+ end
52
+
53
+ # Alias for update method
54
+ alias << :update
55
+
56
+ # Resets the Digest object to initial state, abandoning computed data.
57
+ #
58
+ # @return [Digest] self
59
+ def reset
60
+ # See function: c_digest_reset(...) in ext/sha3/_digest.c
61
+ end
62
+
63
+ # Returns message digest length in bytes.
64
+ #
65
+ # @return [Number] message length in bytes.
66
+ #
67
+ # @example
68
+ # digest = SHA3::Digest::SHA256.new
69
+ # digest.length # Result => 32 (or 256 bits)
70
+ def length
71
+ # See function: c_digest_length(...) in ext/sha3/_digest.c
72
+ end
73
+
74
+ # Returns digest block length in bytes.
75
+ #
76
+ # @return [Number] digest block length in bytes.
77
+ #
78
+ # @example
79
+ # digest = SHA3::Digest::SHA384.new
80
+ # digest.block_length # Result => 104
81
+ def block_length
82
+ # See function: c_digest_block_length(...) in ext/sha3/_digest.c
83
+ end
84
+
85
+ # Returns name of initialized digest
86
+ #
87
+ # @return [String] name
88
+ def name
89
+ # See function: c_digest_name(...) in ext/sha3/_digest.c
90
+ end
91
+
92
+ # Returns computed hash value for given hash type, and data in hex (string).
93
+ #
94
+ # @param type [Number, Symbol] See {#initialize} for valid type values.
95
+ # @param data [String] data to compute hash value
96
+ #
97
+ # @return (String) computed hash as hex-encoded string
98
+ #
99
+ # @example
100
+ # SHA3::Digest.hexdigest(256, 'compute me, please')
101
+ # SHA3::Digest::SHA256.hexdigest('compute me, please') # => Alternate syntax
102
+ def self.hexdigest(type, data)
103
+ end
104
+
105
+ # Returns computed hash value for given hash type, and data in bytes.
106
+ #
107
+ # @param type [Number, Symbol] See {#initialize} for valid type values.
108
+ # @param data [String] data to compute hash value
109
+ #
110
+ # @return [String] computed hash in bytes
111
+ #
112
+ # @example
113
+ # SHA3::Digest.digest(256, 'compute me, please')
114
+ # SHA3::Digest::SHA256.digest('compute me, please') # => Alternate syntax
115
+ def self.digest(type, data)
116
+ end
117
+ end
118
+
119
+ class DigestError < StandardError
120
+ end
121
+ end
@@ -1,8 +1,9 @@
1
1
  module SHA3
2
2
  extend self
3
-
4
- # sha3 version
5
- VERSION = "0.2.2"
6
- KECCAK_VERSION = "3.2"
7
- end
8
3
 
4
+ # sha3 release version
5
+ VERSION = '1.0.2'.freeze
6
+
7
+ # keccak version number
8
+ KECCAK_VERSION = '4.0'.freeze
9
+ end
@@ -1,25 +1,23 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require File.expand_path('../lib/sha3/version', __FILE__)
1
+ require File.expand_path('lib/sha3/version', __dir__)
4
2
 
5
3
  Gem::Specification.new do |gem|
6
- gem.name = "sha3"
4
+ gem.name = 'sha3'
7
5
  gem.version = SHA3::VERSION
8
- gem.summary = %q{SHA3 for Ruby}
9
- gem.description = %q{SHA3 for Ruby is a native (C) implementation of Keccak (SHA3) cryptographic hashing algorithm. See https://github.com/johanns/sha3#readme for details.}
10
- gem.license = "MIT"
11
- gem.authors = ["Johanns Gregorian"]
12
- gem.email = "io+sha3@jsani.com"
13
- gem.homepage = "https://github.com/johanns/sha3#readme"
6
+ gem.summary = 'SHA3 for Ruby'
7
+ gem.description = 'SHA3 for Ruby is a native (C) FIPS 202 compliant implementation of SHA3 (Keccak) cryptographic hashing algorithm.'
8
+ gem.license = 'MIT'
9
+ gem.authors = ['Johanns Gregorian']
10
+ gem.email = 'io+sha3@jsg.io'
11
+ gem.homepage = 'https://github.com/johanns/sha3#readme'
14
12
 
15
13
  gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
17
15
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
16
  gem.require_paths = ['lib']
19
17
  gem.extensions = ['ext/sha3/extconf.rb']
20
-
21
- gem.add_development_dependency "rake-compiler"
22
- gem.add_development_dependency 'rspec', '~> 2.4'
18
+
19
+ gem.add_development_dependency 'rake-compiler', '~> 1.1'
20
+ gem.add_development_dependency 'rspec', '~> 3.3'
23
21
  gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
24
- gem.add_development_dependency 'yard', '~> 0.8'
22
+ gem.add_development_dependency 'yard', '~> 0.9'
25
23
  end
@@ -1,84 +1,50 @@
1
1
  # Based on python-sha3's / digest-sha3 test generator.
2
2
 
3
3
  FILES = [
4
- ['data/ShortMsgKAT_224.txt', 224],
5
- ['data/ShortMsgKAT_256.txt', 256],
6
- ['data/ShortMsgKAT_384.txt', 384],
7
- ['data/ShortMsgKAT_512.txt', 512],
8
- ['data/LongMsgKAT_224.txt', 224],
9
- ]
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
10
9
 
11
10
  def gen_digest_byte_tests
12
11
  FILES.each do |path, hashlen|
13
12
  name = File.basename(path).split('.')[0]
14
13
 
15
- f = File.new("sha3_digest_#{name}_spec.rb", "w")
14
+ f = File.new("sha3_digest_#{name}_spec.rb", 'w')
16
15
  f.puts(
17
- %Q{require 'spec_helper'
16
+ %{require 'spec_helper'
18
17
  require 'sha3'
19
18
 
20
19
  describe "SHA3::Digest.new(#{hashlen})" do
21
20
  it "should match byte-length test vectors (#{name})." do
22
- })
21
+ }
22
+ )
23
23
  contents = File.read(path).split('Len = ')
24
24
  contents.each do |test|
25
25
  lines = test.split("\n")
26
- if !lines.empty? && lines[0] !~ /^#/
27
- length = lines[0].to_i
28
- if length % 8 == 0 && length != 0
29
- msg_raw = [lines[1].split(' = ').last].pack("H*")
30
- md = lines[2].split(' = ').last.downcase
31
- f.puts(
32
- %Q{ SHA3::Digest.new(#{hashlen}, #{msg_raw.inspect}).hexdigest.should(eq("#{md}"))
33
- })
34
- end
35
- end
36
- end
37
- f.puts(
38
- %Q{ end
39
- end
40
- })
41
- f.close
42
- end
43
- end
26
+ next unless !lines.empty? && lines[0] !~ /^#/
44
27
 
45
- def gen_compute_bit_tests
46
- FILES.each do |path, hashlen|
47
- name = File.basename(path).split('.')[0]
28
+ length = lines[0].to_i
29
+ next unless (length % 8).zero? && length != 0
48
30
 
49
- f = File.new("sha3_compute_#{name}_spec.rb", "w")
50
- f.puts(
51
- %Q{require 'spec_helper'
52
- require 'sha3'
53
-
54
- describe "SHA3::Digest.compute(#{hashlen})" do
55
- it "should match bit-length test vectors (#{name})." do
56
- })
57
- contents = File.read(path).split('Len = ')
58
- contents.each do |test|
59
- lines = test.split("\n")
60
- if !lines.empty? && lines[0] !~ /^#/
61
- length = lines[0].to_i
62
- if length != 0
63
- msg_raw = [lines[1].split(' = ').last].pack("H*")
64
- md = lines[2].split(' = ').last.downcase
65
- f.puts(
66
- %Q{ SHA3::Digest.compute(#{hashlen}, #{msg_raw.inspect}, #{length}).unpack("H*").first.should(eq("#{md}"))
67
- })
68
- end
69
- end
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
+ )
70
37
  end
71
38
  f.puts(
72
- %Q{ end
39
+ %( end
73
40
  end
74
- })
41
+ )
42
+ )
75
43
  f.close
76
44
  end
77
45
  end
78
46
 
79
- def setup
80
-
81
- end
47
+ def setup; end
82
48
 
83
49
  gen_digest_byte_tests
84
50
  gen_compute_bit_tests
@@ -1,168 +1,148 @@
1
1
  require 'spec_helper'
2
2
  require 'sha3'
3
3
 
4
- describe SHA3 do
5
- it "should have a VERSION constant" do
6
- subject.const_get('VERSION').should_not be_empty
4
+ RSpec.describe SHA3 do
5
+ it 'should have a VERSION constant' do
6
+ expect(subject.const_get('VERSION')).not_to be_empty
7
7
  end
8
8
 
9
- it "should have a KECCAK_VERSION constant" do
10
- subject.const_get('KECCAK_VERSION').should_not be_empty
9
+ it 'should have a KECCAK_VERSION constant' do
10
+ expect(subject.const_get('KECCAK_VERSION')).not_to be_empty
11
11
  end
12
12
 
13
- it "should have Digest class" do
14
- subject.const_get('Digest').is_a?(Class).should be_true
15
- end
13
+ it 'should have Digest class' do
14
+ expect(subject.const_get('Digest').is_a?(Class)).to be_truthy
15
+ end
16
16
  end
17
17
 
18
- describe SHA3::Digest do
19
- it "should pass Digest.new() (default: :sha256) usage test" do
18
+ RSpec.describe SHA3::Digest do
19
+ it 'should pass Digest.new() (default: :sha256) usage test' do
20
20
  sha = SHA3::Digest.new()
21
- sha.hexdigest.should eq("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
22
- sha.update(["cc"].pack("H*")).hexdigest.should eq("eead6dbfc7340a56caedc044696a168870549a6a7f6f56961e84a54bd9970b8a")
23
- sha.reset.hexdigest.should eq("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
24
- sha << (["6172f1971a6e1e4e6170afbad95d5fec99bf69b24b674bc17dd78011615e502de6f56b86b1a71d3f4348087218ac7b7d09302993be272e4a591968aef18a1262d665610d1070ee91cc8da36e1f841a69a7a682c580e836941d21d909a3afc1f0b963e1ca5ab193e124a1a53df1c587470e5881fb54dae1b0d840f0c8f9d1b04c645ba1041c7d8dbf22030a623aa15638b3d99a2c400ff76f3252079af88d2b37f35ee66c1ad7801a28d3d388ac450b97d5f0f79e4541755356b3b1a5696b023f39ab7ab5f28df4202936bc97393b93bc915cb159ea1bd7a0a414cb4b7a1ac3af68f50d79f0c9c7314e750f7d02faa58bfa"].pack("H*"))
25
- sha.hexdigest.should(eq("4ea524e705020284b18284e34683725590e1ee565a6ff598ed4d42b1c987471e"))
26
- sha.digest_length.should(eq(32))
27
- sha.block_length.should(eq(136))
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)
28
31
  end
29
32
 
30
- it "should pass Digest.new(:sha224) usage test" do
33
+ it 'should pass Digest.new(:sha224) usage test' do
31
34
  sha = SHA3::Digest.new(:sha224)
32
- sha.hexdigest.should eq("f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd")
33
- sha.update(["cc"].pack("H*")).hexdigest.should eq("a9cab59eb40a10b246290f2d6086e32e3689faf1d26b470c899f2802")
34
- sha.reset.hexdigest.should eq("f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd")
35
- sha << (["5fce8109a358570e40983e1184e541833bb9091e280f258cfb144387b05d190e431cb19baa67273ba0c58abe91308e1844dcd0b3678baa42f335f2fa05267a0240b3c718a5942b3b3e3bfa98a55c25a1466e8d7a603722cb2bbf03afa54cd769a99f310735ee5a05dae2c22d397bd95635f58c48a67f90e1b73aafcd3f82117f0166657838691005b18da6f341d6e90fc1cdb352b30fae45d348294e501b63252de14740f2b85ae5299ddec3172de8b6d0ba219a20a23bb5e10ff434d39db3f583305e9f5c039d98569e377b75a70ab837d1df269b8a4b566f40bb91b577455fd3c356c914fa06b9a7ce24c7317a172d"].pack("H*"))
36
- sha.hexdigest.should(eq("db85af5cfce746240e6d44e73cef66a72ce5968284d35ffef7fbff6c"))
37
- sha.digest_length.should(eq(28))
38
- sha.block_length.should(eq(144))
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)
39
45
  end
40
46
 
41
- it "should pass Digest.new(:sha256) usage test" do
47
+ it 'should pass Digest.new(:sha256) usage test' do
42
48
  sha = SHA3::Digest.new(:sha256)
43
- sha.hexdigest.should eq("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
44
- sha.update(["cc"].pack("H*")).hexdigest.should eq("eead6dbfc7340a56caedc044696a168870549a6a7f6f56961e84a54bd9970b8a")
45
- sha.reset.hexdigest.should eq("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
46
- sha << (["6172f1971a6e1e4e6170afbad95d5fec99bf69b24b674bc17dd78011615e502de6f56b86b1a71d3f4348087218ac7b7d09302993be272e4a591968aef18a1262d665610d1070ee91cc8da36e1f841a69a7a682c580e836941d21d909a3afc1f0b963e1ca5ab193e124a1a53df1c587470e5881fb54dae1b0d840f0c8f9d1b04c645ba1041c7d8dbf22030a623aa15638b3d99a2c400ff76f3252079af88d2b37f35ee66c1ad7801a28d3d388ac450b97d5f0f79e4541755356b3b1a5696b023f39ab7ab5f28df4202936bc97393b93bc915cb159ea1bd7a0a414cb4b7a1ac3af68f50d79f0c9c7314e750f7d02faa58bfa"].pack("H*"))
47
- sha.hexdigest.should(eq("4ea524e705020284b18284e34683725590e1ee565a6ff598ed4d42b1c987471e"))
48
- sha.digest_length.should(eq(32))
49
- sha.block_length.should(eq(136))
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)
50
59
  end
51
-
52
- it "should pass Digest.new(:sha384) usage test" do
60
+
61
+ it 'should pass Digest.new(:sha384) usage test' do
53
62
  sha = SHA3::Digest.new(:sha384)
54
- sha.hexdigest.should eq("2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff")
55
- sha.update(["cc"].pack("H*")).hexdigest.should eq("1b84e62a46e5a201861754af5dc95c4a1a69caf4a796ae405680161e29572641f5fa1e8641d7958336ee7b11c58f73e9")
56
- sha.reset.hexdigest.should eq("2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff")
57
- sha << (["3b8e97c5ffc2d6a40fa7de7fcefc90f3b12c940e7ab415321e29ee692dfac799b009c99dcddb708fce5a178c5c35ee2b8617143edc4c40b4d313661f49abdd93cea79d117518805496fe6acf292c4c2a1f76b403a97d7c399daf85b46ad84e16246c67d6836757bde336c290d5d401e6c1386ab32797af6bb251e9b2d8fe754c47482b72e0b394eab76916126fd68ea7d65eb93d59f5b4c5ac40f7c3b37e7f3694f29424c24af8c8f0ef59cd9dbf1d28e0e10f799a6f78cad1d45b9db3d7dee4a7059abe99182714983b9c9d44d7f5643596d4f3"].pack("H*"))
58
- sha.hexdigest.should(eq("9172aad6c15b4dcd79bbd84fad0601119d8b4e3afed17b594ff38424157985ee27b65826b9905486e767e85aa031e07b"))
59
- sha.digest_length.should(eq(48))
60
- sha.block_length.should(eq(104))
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)
61
74
  end
62
75
 
63
- it "should pass Digest.new(:sha512) usage test" do
76
+ it 'should pass Digest.new(:sha512) usage test' do
64
77
  sha = SHA3::Digest.new(:sha512)
65
- sha.hexdigest.should eq("0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e")
66
- sha.update(["cc"].pack("H*")).hexdigest.should eq("8630c13cbd066ea74bbe7fe468fec1dee10edc1254fb4c1b7c5fd69b646e44160b8ce01d05a0908ca790dfb080f4b513bc3b6225ece7a810371441a5ac666eb9")
67
- sha.reset.hexdigest.should eq("0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e")
68
- sha << (["03d625488354df30e3f875a68edfcf340e8366a8e1ab67f9d5c5486a96829dfac0578289082b2a62117e1cf418b43b90e0adc881fc6ae8105c888e9ecd21aea1c9ae1a4038dfd17378fed71d02ae492087d7cdcd98f746855227967cb1ab4714261ee3bead3f4db118329d3ebef4bc48a875c19ba763966da0ebea800e01b2f50b00e9dd4caca6dcb314d00184ef71ea2391d760c950710db4a70f9212ffc54861f9dc752ce18867b8ad0c48df8466ef7231e7ac567f0eb55099e622ebb86cb237520190a61c66ad34f1f4e289cb3282ae3eaac6152ed24d2c92bae5a7658252a53c49b7b02dfe54fdb2e90074b6cf310ac661"].pack("H*"))
69
- sha.hexdigest.should(eq("13a592b73ede487036c8816bd6fc6cdc04dc6133409a6ee990584160518f9ef573264cf04d38a3ba75d150f4f026f6df8936e13c8f4f3ecc9ecbc43fdfc488a4"))
70
- sha.digest_length.should(eq(64))
71
- sha.block_length.should(eq(72))
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)
72
88
  end
73
-
74
- it "should pass Digest.SHA224() usage test" do
89
+ end
90
+
91
+ RSpec.describe 'SHA3::Digest::SHAxyz' do
92
+ it 'should pass Digest.SHA224() usage test' do
75
93
  sha = SHA3::Digest::SHA224.new()
76
- sha.hexdigest.should eq("f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd")
77
- sha.update(["cc"].pack("H*")).hexdigest.should eq("a9cab59eb40a10b246290f2d6086e32e3689faf1d26b470c899f2802")
78
- sha.reset.hexdigest.should eq("f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd")
79
- sha << (["5fce8109a358570e40983e1184e541833bb9091e280f258cfb144387b05d190e431cb19baa67273ba0c58abe91308e1844dcd0b3678baa42f335f2fa05267a0240b3c718a5942b3b3e3bfa98a55c25a1466e8d7a603722cb2bbf03afa54cd769a99f310735ee5a05dae2c22d397bd95635f58c48a67f90e1b73aafcd3f82117f0166657838691005b18da6f341d6e90fc1cdb352b30fae45d348294e501b63252de14740f2b85ae5299ddec3172de8b6d0ba219a20a23bb5e10ff434d39db3f583305e9f5c039d98569e377b75a70ab837d1df269b8a4b566f40bb91b577455fd3c356c914fa06b9a7ce24c7317a172d"].pack("H*"))
80
- sha.hexdigest.should(eq("db85af5cfce746240e6d44e73cef66a72ce5968284d35ffef7fbff6c"))
81
- sha.digest_length.should(eq(28))
82
- sha.block_length.should(eq(144))
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)
83
104
  end
84
105
 
85
- it "should pass Digest.SHA256() usage test" do
106
+ it 'should pass Digest.SHA256() usage test' do
86
107
  sha = SHA3::Digest::SHA256.new()
87
- sha.hexdigest.should eq("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
88
- sha.update(["cc"].pack("H*")).hexdigest.should eq("eead6dbfc7340a56caedc044696a168870549a6a7f6f56961e84a54bd9970b8a")
89
- sha.reset.hexdigest.should eq("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
90
- sha << (["6172f1971a6e1e4e6170afbad95d5fec99bf69b24b674bc17dd78011615e502de6f56b86b1a71d3f4348087218ac7b7d09302993be272e4a591968aef18a1262d665610d1070ee91cc8da36e1f841a69a7a682c580e836941d21d909a3afc1f0b963e1ca5ab193e124a1a53df1c587470e5881fb54dae1b0d840f0c8f9d1b04c645ba1041c7d8dbf22030a623aa15638b3d99a2c400ff76f3252079af88d2b37f35ee66c1ad7801a28d3d388ac450b97d5f0f79e4541755356b3b1a5696b023f39ab7ab5f28df4202936bc97393b93bc915cb159ea1bd7a0a414cb4b7a1ac3af68f50d79f0c9c7314e750f7d02faa58bfa"].pack("H*"))
91
- sha.hexdigest.should(eq("4ea524e705020284b18284e34683725590e1ee565a6ff598ed4d42b1c987471e"))
92
- sha.digest_length.should(eq(32))
93
- sha.block_length.should(eq(136))
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)
94
118
  end
95
-
96
- it "should pass Digest.SHA384() usage test" do
119
+
120
+ it 'should pass Digest.SHA384() usage test' do
97
121
  sha = SHA3::Digest::SHA384.new()
98
- sha.hexdigest.should eq("2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff")
99
- sha.update(["cc"].pack("H*")).hexdigest.should eq("1b84e62a46e5a201861754af5dc95c4a1a69caf4a796ae405680161e29572641f5fa1e8641d7958336ee7b11c58f73e9")
100
- sha.reset.hexdigest.should eq("2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff")
101
- sha << (["3b8e97c5ffc2d6a40fa7de7fcefc90f3b12c940e7ab415321e29ee692dfac799b009c99dcddb708fce5a178c5c35ee2b8617143edc4c40b4d313661f49abdd93cea79d117518805496fe6acf292c4c2a1f76b403a97d7c399daf85b46ad84e16246c67d6836757bde336c290d5d401e6c1386ab32797af6bb251e9b2d8fe754c47482b72e0b394eab76916126fd68ea7d65eb93d59f5b4c5ac40f7c3b37e7f3694f29424c24af8c8f0ef59cd9dbf1d28e0e10f799a6f78cad1d45b9db3d7dee4a7059abe99182714983b9c9d44d7f5643596d4f3"].pack("H*"))
102
- sha.hexdigest.should(eq("9172aad6c15b4dcd79bbd84fad0601119d8b4e3afed17b594ff38424157985ee27b65826b9905486e767e85aa031e07b"))
103
- sha.digest_length.should(eq(48))
104
- sha.block_length.should(eq(104))
105
- end
106
122
 
107
- it "should pass Digest.SHA512() usage test" do
108
- sha = SHA3::Digest::SHA512.new()
109
- sha.hexdigest.should eq("0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e")
110
- sha.update(["cc"].pack("H*")).hexdigest.should eq("8630c13cbd066ea74bbe7fe468fec1dee10edc1254fb4c1b7c5fd69b646e44160b8ce01d05a0908ca790dfb080f4b513bc3b6225ece7a810371441a5ac666eb9")
111
- sha.reset.hexdigest.should eq("0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e")
112
- sha << (["03d625488354df30e3f875a68edfcf340e8366a8e1ab67f9d5c5486a96829dfac0578289082b2a62117e1cf418b43b90e0adc881fc6ae8105c888e9ecd21aea1c9ae1a4038dfd17378fed71d02ae492087d7cdcd98f746855227967cb1ab4714261ee3bead3f4db118329d3ebef4bc48a875c19ba763966da0ebea800e01b2f50b00e9dd4caca6dcb314d00184ef71ea2391d760c950710db4a70f9212ffc54861f9dc752ce18867b8ad0c48df8466ef7231e7ac567f0eb55099e622ebb86cb237520190a61c66ad34f1f4e289cb3282ae3eaac6152ed24d2c92bae5a7658252a53c49b7b02dfe54fdb2e90074b6cf310ac661"].pack("H*"))
113
- sha.hexdigest.should(eq("13a592b73ede487036c8816bd6fc6cdc04dc6133409a6ee990584160518f9ef573264cf04d38a3ba75d150f4f026f6df8936e13c8f4f3ecc9ecbc43fdfc488a4"))
114
- sha.digest_length.should(eq(64))
115
- sha.block_length.should(eq(72))
116
- end
123
+ expect(sha.hexdigest).to eq('0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004')
117
124
 
118
- end
125
+ expect(sha.update(['cc'].pack('H*'))).to eq('5ee7f374973cd4bb3dc41e3081346798497ff6e36cb9352281dfe07d07fc530ca9ad8ef7aad56ef5d41be83d5e543807')
126
+ expect(sha.reset).to eq('0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004')
119
127
 
120
- describe "SHA3::Digest.compute" do
121
- it "should match SHA3-224 test vectors (subset)" do
122
- SHA3::Digest.compute(:sha224, ["00"].pack("H*"), 0).unpack("H*").first.should(eq("f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd"))
123
- SHA3::Digest.compute(:sha224, ["00"].pack("H*"), 1).unpack("H*").first.should(eq("860e3ec314c5cbf19c1a4314e9ea8cb85cecd18bd850b42f5c6f2a07"))
124
- SHA3::Digest.compute(:sha224, ["c0"].pack("H*"), 2).unpack("H*").first.should(eq("6b22cddbd1366f7b8db2026aee8a0afa86b323aed7aa270ad928d1c5"))
125
- SHA3::Digest.compute(:sha224, ["c0"].pack("H*"), 3).unpack("H*").first.should(eq("2b695a6fd92a2b3f3ce9cfca617d22c9bb52815dd59a9719b01bad25"))
126
- SHA3::Digest.compute(:sha224, ["80"].pack("H*"), 4).unpack("H*").first.should(eq("bfa0740d2f2edcdee2db3f66f04fb8179967d3fb5981644d9d084bd7"))
127
- SHA3::Digest.compute(:sha224, ["48"].pack("H*"), 5).unpack("H*").first.should(eq("e4384016d64610d75e0a5d73821a02d524f847a25a571b5940cd6450"))
128
- SHA3::Digest.compute(:sha224, ["50"].pack("H*"), 6).unpack("H*").first.should(eq("a0fb02f1d41bc09cc4b3e85b15be85e3b3c2d43eb36dd616c640d7ca"))
129
- SHA3::Digest.compute(:sha224, ["98"].pack("H*"), 7).unpack("H*").first.should(eq("c00ecd3072762c82d08f8f76fecf38be23075f9c5663d06a9184bd0b"))
130
- SHA3::Digest.compute(:sha224, ["cc"].pack("H*"), 8).unpack("H*").first.should(eq("a9cab59eb40a10b246290f2d6086e32e3689faf1d26b470c899f2802"))
131
- end
132
-
133
- it "should match SHA3-256 test vectors (subset)" do
134
- SHA3::Digest.compute(:sha256, ["00"].pack("H*"), 0).unpack("H*").first.should(eq("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"))
135
- SHA3::Digest.compute(:sha256, ["00"].pack("H*"), 1).unpack("H*").first.should(eq("c3e5cb55999eeff4e07b7effec77582d0a5a11a94fc268a872493099273992e1"))
136
- SHA3::Digest.compute(:sha256, ["c0"].pack("H*"), 2).unpack("H*").first.should(eq("3a1108d4a90a31b85a10bdce77f4bfbdcc5b1d70dd405686f8bbde834aa1a410"))
137
- SHA3::Digest.compute(:sha256, ["c0"].pack("H*"), 3).unpack("H*").first.should(eq("7384d12118da4ad51a519806e2529fb2548b5dce2a87122b8507f71a28a35deb"))
138
- SHA3::Digest.compute(:sha256, ["80"].pack("H*"), 4).unpack("H*").first.should(eq("53e5e48805ae70306bf9ddc26e9ee2db87afe95ef0bfb9f9c44211be11a4c810"))
139
- SHA3::Digest.compute(:sha256, ["48"].pack("H*"), 5).unpack("H*").first.should(eq("c341f676da4d10d32d9dad5140d497fecfe9565c79f4f5aa7f1d3c36b290fe3b"))
140
- SHA3::Digest.compute(:sha256, ["50"].pack("H*"), 6).unpack("H*").first.should(eq("80b7ed96c53f37ebd0a0f2f7c63b0b35480f57215ab8c5fdf9f5f6e989a53366"))
141
- SHA3::Digest.compute(:sha256, ["98"].pack("H*"), 7).unpack("H*").first.should(eq("aca86ee608e0a6e31c0173f2eedee26c527f108f7f11a19a2e4327116485414c"))
142
- SHA3::Digest.compute(:sha256, ["cc"].pack("H*"), 8).unpack("H*").first.should(eq("eead6dbfc7340a56caedc044696a168870549a6a7f6f56961e84a54bd9970b8a"))
143
- end
128
+ sha << (['3b8e97c5ffc2d6a40fa7de7fcefc90f3b12c940e7ab415321e29ee692dfac799b009c99dcddb708fce5a178c5c35ee2b8617143edc4c40b4d313661f49abdd93cea79d117518805496fe6acf292c4c2a1f76b403a97d7c399daf85b46ad84e16246c67d6836757bde336c290d5d401e6c1386ab32797af6bb251e9b2d8fe754c47482b72e0b394eab76916126fd68ea7d65eb93d59f5b4c5ac40f7c3b37e7f3694f29424c24af8c8f0ef59cd9dbf1d28e0e10f799a6f78cad1d45b9db3d7dee4a7059abe99182714983b9c9d44d7f5643596d4f3'].pack("H*"))
144
129
 
145
- it "should match SHA3-384 test vectors (subset)" do
146
- SHA3::Digest.compute(:sha384, ["00"].pack("H*"), 0).unpack("H*").first.should(eq("2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff"))
147
- SHA3::Digest.compute(:sha384, ["00"].pack("H*"), 1).unpack("H*").first.should(eq("4c6d164043571a32e169a527ca3503ea391bf91f22287215df75ea243d53a0d042bc66efe2956d8606a24f39e255a081"))
148
- SHA3::Digest.compute(:sha384, ["c0"].pack("H*"), 2).unpack("H*").first.should(eq("c7058511440be5d4f5688ef721000e91244ad6d10fee477dccb84e8b84db897f51db533e49964b18e5e362e5fd569e19"))
149
- SHA3::Digest.compute(:sha384, ["c0"].pack("H*"), 3).unpack("H*").first.should(eq("3c297324d6f43be6a5b784c25b559910b6f79ef3c74db21575325cc9c917d935d8c3d6a9aa34f9fc65f1e9c39abc83ab"))
150
- SHA3::Digest.compute(:sha384, ["80"].pack("H*"), 4).unpack("H*").first.should(eq("b43af6ccf78fc5cab63eb7cda68fd89e95c506eea63c131a82f9d9a1798002bb40d3b78473c3a66456034720ba8142e2"))
151
- SHA3::Digest.compute(:sha384, ["48"].pack("H*"), 5).unpack("H*").first.should(eq("6877f31b109ebc6ddab14087739d7702f7e2aa2dd9d54b3b9c04749cb1adea194a52496dc78adcee84e705621f0564cc"))
152
- SHA3::Digest.compute(:sha384, ["50"].pack("H*"), 6).unpack("H*").first.should(eq("b7136d3ef3112a47c1c59c5fab6a40c6ecd7cc89e400dc2efae388dec1028985e138a2b2f54683a8814ef3c1ba28ea9c"))
153
- SHA3::Digest.compute(:sha384, ["98"].pack("H*"), 7).unpack("H*").first.should(eq("748de17dccb6b3fbaa1c938f5a3167244c83683105d45d429f0b40b31d9317860529ea54bfde1521423ceda9debd9d73"))
154
- SHA3::Digest.compute(:sha384, ["cc"].pack("H*"), 8).unpack("H*").first.should(eq("1b84e62a46e5a201861754af5dc95c4a1a69caf4a796ae405680161e29572641f5fa1e8641d7958336ee7b11c58f73e9"))
130
+ expect(sha.hexdigest).to eq('9b809198dcce24175e33098331d3a402a821ae9326e72775aae34d1a9bb53d2b57863905cfd60543bbc42b454007c315')
131
+ expect(sha.digest_length).to eq(48)
132
+ expect(sha.block_length).to eq(104)
155
133
  end
156
134
 
157
- it "should match SHA3-512 test vectors (subset)" do
158
- SHA3::Digest.compute(:sha512, ["00"].pack("H*"), 0).unpack("H*").first.should(eq("0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e"))
159
- SHA3::Digest.compute(:sha512, ["00"].pack("H*"), 1).unpack("H*").first.should(eq("7d9025bb145a0814083e934baa80ede67322651de52062bf9eb93623c37efc74c62240cf8539107f9210c1e1126f79cbaeda6b82b4a8ce6821589c403fa76b9a"))
160
- SHA3::Digest.compute(:sha512, ["c0"].pack("H*"), 2).unpack("H*").first.should(eq("0ae7dac687c3525d5c2a6c4119ea3968d43dfe69c2407a44d3de6b804d784530462440e4881fd42785e1cb69af4f036d96d8ff1ee35d9b3fa4a2859f592fb2dc"))
161
- SHA3::Digest.compute(:sha512, ["c0"].pack("H*"), 3).unpack("H*").first.should(eq("5a844de7d6b8be77bec55021c9bfa375c4b97d79633c7ea4e7e2bc4c64ac6349d3a0142aaa50c2118b1d94af9a5b804af94f259b2d06c3f4a4997afb8f787f6b"))
162
- SHA3::Digest.compute(:sha512, ["80"].pack("H*"), 4).unpack("H*").first.should(eq("b9f236b9c7ca24fe356e9375b34831b0054d4ab5cfb9e326c9e411c1805b3adb36e7d6ceccac123f27638fad3f34c48f8813a338cd53824d19bc14f6eac218b6"))
163
- SHA3::Digest.compute(:sha512, ["48"].pack("H*"), 5).unpack("H*").first.should(eq("88cd5e4ab2b5cc16cf48e87b1ee3ee1fc5b1ea98142e02346429e5c8f18b570120a04040cdab16643bfd70d31ab3fd6fc360955ab4f6a9494f4fdfaa9b6576b2"))
164
- SHA3::Digest.compute(:sha512, ["50"].pack("H*"), 6).unpack("H*").first.should(eq("5c69cfb002435d627390c62f2e7e74a688e537ea1dac71d97f6d99bccb64fda7d45a8e6b9dac199b78c4a3b59b04c8f1354b8d15b01db520932f1544dfbf757b"))
165
- SHA3::Digest.compute(:sha512, ["98"].pack("H*"), 7).unpack("H*").first.should(eq("90e09885b5f8b9192e8380522f96d6c1c6d407aa9b73cb07ad8b84c310f08adad507b63c2c041f00119062d63421ffb51e81d39db17a022730a03d6feecbcf0b"))
166
- SHA3::Digest.compute(:sha512, ["cc"].pack("H*"), 8).unpack("H*").first.should(eq("8630c13cbd066ea74bbe7fe468fec1dee10edc1254fb4c1b7c5fd69b646e44160b8ce01d05a0908ca790dfb080f4b513bc3b6225ece7a810371441a5ac666eb9"))
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)
167
147
  end
168
- end
148
+ end