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
|
||||
@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
|
||||
|
|
Loading…
Reference in a new issue