1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
knu 2006-12-03 07:36:06 +00:00
parent b326623cef
commit bd2df89b14

View file

@ -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