@ -271,7 +271,7 @@ function validate_value(expected_field, cookie)
end
end
-- Lua hashes strings, so these comparisons are time invariant.
-- Lua hashes strings, so these comparisons are time invariant.
if hmac ~= crypto.hmac . digest ( " sha1 " , field .. " | " .. value .. " | " .. tostring ( expiration ) .. " | " .. salt , secret ) then
if hmac ~= crypto.hmac . digest ( " sha256 " , field .. " | " .. value .. " | " .. tostring ( expiration ) .. " | " .. salt , secret ) then
return nil
return nil
end
end
@ -296,7 +296,7 @@ function secure_value(field, value, expiration)
value = url_encode ( value )
value = url_encode ( value )
field = url_encode ( field )
field = url_encode ( field )
authstr = field .. " | " .. value .. " | " .. tostring ( expiration ) .. " | " .. salt
authstr = field .. " | " .. value .. " | " .. tostring ( expiration ) .. " | " .. salt
authstr = authstr .. " | " .. crypto.hmac . digest ( " sha1 " , authstr , secret )
authstr = authstr .. " | " .. crypto.hmac . digest ( " sha256 " , authstr , secret )
return authstr
return authstr
end
end