summaryrefslogtreecommitdiff
path: root/ext/digest/lib/digest/hmac.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/digest/lib/digest/hmac.rb')
-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 0aeb6a8b48..a0cc948a6c 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