mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Compare the actual string after comparing the HMAC proccessed strings
Even that collisions are unlikely we need to make sure the two strings are equal. Timing is not important in this case because this only runs after the comparison between the SHA256 digested strings returns true.
This commit is contained in:
parent
0623b5d194
commit
f76ca450f5
1 changed files with 1 additions and 1 deletions
|
@ -24,7 +24,7 @@ module ActiveSupport
|
|||
# The values are first processed by SHA256, so that we don't leak length info
|
||||
# via timing attacks.
|
||||
def secure_compare(a, b)
|
||||
fixed_length_secure_compare(::Digest::SHA256.hexdigest(a), ::Digest::SHA256.hexdigest(b))
|
||||
fixed_length_secure_compare(::Digest::SHA256.hexdigest(a), ::Digest::SHA256.hexdigest(b)) && a == b
|
||||
end
|
||||
module_function :secure_compare
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue