summaryrefslogtreecommitdiff
path: root/jwt/utils.py
diff options
context:
space:
mode:
authorMark Adams <mark@markadams.me>2015-01-18 10:36:09 -0600
committerMark Adams <mark@markadams.me>2015-01-18 10:36:34 -0600
commit8e2adaefbf9e92e128ea034d6c5ab52dc1053047 (patch)
treeee8fe3b17bb5dabba448b52420f0c4caa1c7bb0e /jwt/utils.py
parente49582f6d1bad64d3bf5260049aab4eb08a94e70 (diff)
downloadpyjwt-8e2adaefbf9e92e128ea034d6c5ab52dc1053047.tar.gz
Fixed a couple of anomalies after the last rebase.
Diffstat (limited to 'jwt/utils.py')
-rw-r--r--jwt/utils.py27
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