brianloveswords / python-jws

python implementation of JSON Web Signatures
57 stars 35 forks source link

Fix constant time comparison #20

Open williamgibb opened 8 years ago

williamgibb commented 8 years ago

Update utils.py to define two different constant time comparisons; one which is appropriate for use w/ Python2 and one which is appropriate for use with Python3. Unit tests were previously failing on python3, and no longer fail with this update.

The algorithm is the same between the two of them, differing in the use of ord(), which fails on ints which are present in python3 when iterating over the bytes class. This fixes #19.