diff options
author | Mark Adams <mark@markadams.me> | 2015-01-18 10:36:09 -0600 |
---|---|---|
committer | Mark Adams <mark@markadams.me> | 2015-01-18 10:36:34 -0600 |
commit | 8e2adaefbf9e92e128ea034d6c5ab52dc1053047 (patch) | |
tree | ee8fe3b17bb5dabba448b52420f0c4caa1c7bb0e /jwt/utils.py | |
parent | e49582f6d1bad64d3bf5260049aab4eb08a94e70 (diff) | |
download | pyjwt-8e2adaefbf9e92e128ea034d6c5ab52dc1053047.tar.gz |
Fixed a couple of anomalies after the last rebase.
Diffstat (limited to 'jwt/utils.py')
-rw-r--r-- | jwt/utils.py | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/jwt/utils.py b/jwt/utils.py index 6e3cfb9..e6c1ef3 100644 --- a/jwt/utils.py +++ b/jwt/utils.py @@ -1,6 +1,4 @@ import base64 -import hmac -import sys def base64url_decode(input): @@ -14,28 +12,3 @@ def base64url_decode(input): def base64url_encode(input): return base64.urlsafe_b64encode(input).replace(b'=', b'') - -try: - constant_time_compare = hmac.compare_digest -except AttributeError: - # Fallback for Python < 2.7.7 and Python < 3.3 - def constant_time_compare(val1, val2): - """ - Returns True if the two strings are equal, False otherwise. - - The time taken is independent of the number of characters that match. - """ - if len(val1) != len(val2): - return False - - result = 0 - - if sys.version_info >= (3, 0, 0): - # Bytes are numbers - for x, y in zip(val1, val2): - result |= x ^ y - else: - for x, y in zip(val1, val2): - result |= ord(x) ^ ord(y) - - return result == 0 |