radiantcms-couchrest_model 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -40,15 +40,22 @@ module ActiveSupport
|
|
40
40
|
private
|
41
41
|
# constant-time comparison algorithm to prevent timing attacks
|
42
42
|
def secure_compare(a, b)
|
43
|
-
if a.length == b.length
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
else
|
50
|
-
|
51
|
-
end
|
43
|
+
#if a.length == b.length
|
44
|
+
# result = 0
|
45
|
+
# for i in 0..(a.length - 1)
|
46
|
+
# result |= a[i] ^ b[i]
|
47
|
+
# end
|
48
|
+
# result == 0
|
49
|
+
#else
|
50
|
+
# false
|
51
|
+
#end
|
52
|
+
return false unless a.bytesize == b.bytesize
|
53
|
+
|
54
|
+
l = a.unpack "C#{a.bytesize}"
|
55
|
+
|
56
|
+
res = 0
|
57
|
+
b.each_byte { |byte| res |= byte ^ l.shift }
|
58
|
+
res == 0
|
52
59
|
end
|
53
60
|
|
54
61
|
def generate_digest(data)
|