-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
The constant time function from django source code fails on python3
D:\TEMP\python-jws>python3 -m unittest --verbose jws.tests.TestJWS_hmac
test_invalid_hmac (jws.tests.TestJWS_hmac) ... ok
test_valid_hmac256 (jws.tests.TestJWS_hmac) ... ERROR
test_valid_hmac384 (jws.tests.TestJWS_hmac) ... ERROR
test_valid_hmac512 (jws.tests.TestJWS_hmac) ... ERROR
======================================================================
ERROR: test_valid_hmac256 (jws.tests.TestJWS_hmac)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\TEMP\python-jws\jws\tests.py", line 128, in test_valid_hmac256
self.assertTrue(jws.verify(header, self.payload, sig, 'secret'))
File "C:\TEMP\python-jws\jws\__init__.py", line 48, in verify
return verifier(_signing_input(head, payload, is_json), signature, key)
File "C:\TEMP\python-jws\jws\algos.py", line 46, in verify
if not constant_time_compare(self.sign(msg, key), crypto):
File "C:\TEMP\python-jws\jws\utils.py", line 54, in constant_time_compare
result |= ord(x) ^ ord(y)
TypeError: ord() expected string of length 1, but int found
======================================================================
ERROR: test_valid_hmac384 (jws.tests.TestJWS_hmac)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\TEMP\python-jws\jws\tests.py", line 134, in test_valid_hmac384
self.assertTrue(jws.verify(header, self.payload, sig, 'secret'))
File "C:\TEMP\python-jws\jws\__init__.py", line 48, in verify
return verifier(_signing_input(head, payload, is_json), signature, key)
File "C:\TEMP\python-jws\jws\algos.py", line 46, in verify
if not constant_time_compare(self.sign(msg, key), crypto):
File "C:\TEMP\python-jws\jws\utils.py", line 54, in constant_time_compare
result |= ord(x) ^ ord(y)
TypeError: ord() expected string of length 1, but int found
======================================================================
ERROR: test_valid_hmac512 (jws.tests.TestJWS_hmac)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\TEMP\python-jws\jws\tests.py", line 140, in test_valid_hmac512
self.assertTrue(jws.verify(header, self.payload, sig, 'secret'))
File "C:\TEMP\python-jws\jws\__init__.py", line 48, in verify
return verifier(_signing_input(head, payload, is_json), signature, key)
File "C:\TEMP\python-jws\jws\algos.py", line 46, in verify
if not constant_time_compare(self.sign(msg, key), crypto):
File "C:\TEMP\python-jws\jws\utils.py", line 54, in constant_time_compare
result |= ord(x) ^ ord(y)
TypeError: ord() expected string of length 1, but int found
----------------------------------------------------------------------
Ran 4 tests in 0.031s
Metadata
Metadata
Assignees
Labels
No labels