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:
parent
b326623cef
commit
bd2df89b14
1 changed files with 6 additions and 2 deletions
|
@ -60,6 +60,7 @@ module Digest
|
||||||
@key = key.freeze
|
@key = key.freeze
|
||||||
@ipad = ipad.inject('') { |s, c| s << c.chr }.freeze
|
@ipad = ipad.inject('') { |s, c| s << c.chr }.freeze
|
||||||
@opad = opad.inject('') { |s, c| s << c.chr }.freeze
|
@opad = opad.inject('') { |s, c| s << c.chr }.freeze
|
||||||
|
@md.update(@ipad)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize_copy(other)
|
def initialize_copy(other)
|
||||||
|
@ -67,17 +68,20 @@ module Digest
|
||||||
end
|
end
|
||||||
|
|
||||||
def update(text)
|
def update(text)
|
||||||
# @md is reset when digest() returns
|
@md.update(text)
|
||||||
@md.update(@opad + @md.digest(@ipad + text))
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset
|
def reset
|
||||||
@md.reset
|
@md.reset
|
||||||
|
@md.update(@ipad)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def finish
|
def finish
|
||||||
|
d = @md.digest!
|
||||||
|
@md.update(@opad)
|
||||||
|
@md.update(d)
|
||||||
@md.digest!
|
@md.digest!
|
||||||
end
|
end
|
||||||
private :finish
|
private :finish
|
||||||
|
|
Loading…
Reference in a new issue