python3: adapt signature check for different ord() behaviour
This commit is contained in:
parent
ae15cab91e
commit
abeaccc7c1
|
@ -23,6 +23,7 @@ import random
|
|||
from django.conf import settings
|
||||
from django.utils.encoding import smart_bytes
|
||||
from django.utils.http import quote, urlencode
|
||||
from django.utils import six
|
||||
from django.utils.six.moves.urllib.parse import urlparse, urlunparse, parse_qs
|
||||
|
||||
|
||||
|
@ -97,8 +98,12 @@ def check_string(s, signature, keys, algo='sha256'):
|
|||
continue
|
||||
res = 0
|
||||
# constant time compare
|
||||
for a, b in zip(signature, signature2):
|
||||
res |= ord(a) ^ ord(b)
|
||||
if six.PY3:
|
||||
for a, b in zip(signature, signature2):
|
||||
res |= a ^ b
|
||||
else:
|
||||
for a, b in zip(signature, signature2):
|
||||
res |= ord(a) ^ ord(b)
|
||||
if res == 0:
|
||||
return True
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue