summaryrefslogtreecommitdiff
path: root/ext/digest/lib
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-12-03 07:36:06 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-12-03 07:36:06 +0000
commitbd2df89b142c3a43b0f0e082a21dc7672e415b9d (patch)
treeca399d58d4fe7c1951ab72b4b50a5cda4d627aeb /ext/digest/lib
parentb326623cef742e63a076abcab010b6e2fea977a3 (diff)
* ext/digest/lib/digest/hmac.rb: Fix problems with update
timing. [Reported by: oss-ruby@technorama.net] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/digest/lib')
-rw-r--r--ext/digest/lib/digest/hmac.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/digest/lib/digest/hmac.rb b/ext/digest/lib/digest/hmac.rb
index 0aeb6a8..a0cc948 100644
--- a/ext/digest/lib/digest/hmac.rb
+++ b/ext/digest/lib/digest/hmac.rb
@@ -60,6 +60,7 @@ module Digest
@key = key.freeze
@ipad = ipad.inject('') { |s, c| s << c.chr }.freeze
@opad = opad.inject('') { |s, c| s << c.chr }.freeze
+ @md.update(@ipad)
end
def initialize_copy(other)
@@ -67,17 +68,20 @@ module Digest
end
def update(text)
- # @md is reset when digest() returns
- @md.update(@opad + @md.digest(@ipad + text))
+ @md.update(text)
self
end
def reset
@md.reset
+ @md.update(@ipad)
self
end
def finish
+ d = @md.digest!
+ @md.update(@opad)
+ @md.update(d)
@md.digest!
end
private :finish