diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-20 13:01:55 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-10-20 13:01:55 +0000 |
commit | 670887f5f697c57a61fa837d4cf505d3d18a0bc6 (patch) | |
tree | d49eb6fa182be04d42d1243f0781384bbc751518 | |
parent | b2c7fe1bbffe9e5fe741b7dd3725017b55250c1e (diff) | |
download | ruby-670887f5f697c57a61fa837d4cf505d3d18a0bc6.tar.gz |
* ext/digest/lib/digest/hmac.rb: Complete half-boiled updates.
* ext/digest/sha2/lib/digest/sha2.rb: Fix #initialize_clone().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ext/digest/lib/digest/hmac.rb | 17 | ||||
-rw-r--r-- | ext/digest/sha2/lib/digest/sha2.rb | 2 |
3 files changed, 16 insertions, 9 deletions
@@ -1,3 +1,9 @@ +Fri Oct 20 22:00:43 2006 Akinori MUSHA <knu@iDaemons.org> + + * ext/digest/lib/digest/hmac.rb: Complete half-boiled updates. + + * ext/digest/sha2/lib/digest/sha2.rb: Fix #initialize_clone(). + Fri Oct 20 20:28:37 2006 Akinori MUSHA <knu@iDaemons.org> * ext/digest: Prefix C constants with RUBY_ and C type names with diff --git a/ext/digest/lib/digest/hmac.rb b/ext/digest/lib/digest/hmac.rb index b542a23577..1177884184 100644 --- a/ext/digest/lib/digest/hmac.rb +++ b/ext/digest/lib/digest/hmac.rb @@ -63,22 +63,23 @@ module Digest end def initialize_copy(other) - @md = @md.new + @md = other.instance_eval { @md.clone } end def update(text) @md.reset.update(@opad + @md.digest(@ipad + text)) - self end def reset @md.reset + self end - def digest - @md.digest + def finish + @md.digest! end + private :finish def digest_length @md.digest_length @@ -89,7 +90,7 @@ module Digest end def inspect - sprintf('#<%s: key=%s, digest=%s: %s>', self.class.name, @key.inspect, @tmp_md.reset.inspect, hexdigest()); + sprintf('#<%s: key=%s, digest=%s>', self.class.name, @key.inspect, @md.inspect.sub(/^\#<(.*)>$/) { $1 }); end end end @@ -105,7 +106,7 @@ require 'test/unit' module TM_HMAC def test_s_hexdigest cases.each { |h| - digesters { |d| + digesters.each { |d| assert_equal(h[:hexdigest], Digest::HMAC.hexdigest(h[:data], h[:key], d)) } } @@ -113,7 +114,7 @@ module TM_HMAC def test_hexdigest cases.each { |h| - digesters { |d| + digesters.each { |d| hmac = Digest::HMAC.new(h[:key], d) hmac.update(h[:data]) @@ -125,7 +126,7 @@ module TM_HMAC def test_reset cases.each { |h| - digesters { |d| + digesters.each { |d| hmac = Digest::HMAC.new(h[:key], d) hmac.update("test") hmac.reset diff --git a/ext/digest/sha2/lib/digest/sha2.rb b/ext/digest/sha2/lib/digest/sha2.rb index 683b9904a3..52dd639f9b 100644 --- a/ext/digest/sha2/lib/digest/sha2.rb +++ b/ext/digest/sha2/lib/digest/sha2.rb @@ -62,7 +62,7 @@ module Digest # :nodoc: def initialize_copy(other) - @sha2 = @sha2.clone + @sha2 = other.instance_eval { @sha2.clone } end # :nodoc: |