mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Update TimingAttackAgainstHash.py
This commit is contained in:
@@ -17,3 +17,14 @@ def verify1(msg, sig):
|
||||
|
||||
def verify2(msg, sig):
|
||||
return sig == sign(key, msg, hashlib.sha256) #bad
|
||||
|
||||
def constant_time_string_compare(a, b):
|
||||
if len(a) != len(b):
|
||||
return False
|
||||
|
||||
result = 0
|
||||
|
||||
for x, y in zip(a, b):
|
||||
result |= ord(x) ^ ord(y)
|
||||
|
||||
return result == 0
|
||||
|
||||
Reference in New Issue
Block a user