summaryrefslogtreecommitdiff
path: root/jwt
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2020-12-16 14:24:28 -0800
committerGitHub <noreply@github.com>2020-12-16 17:24:28 -0500
commit529647ab8cfc4e05776ebd5d146db9a1f9af6ebf (patch)
tree1c9b0c5677a47acccd256d523e7846aae139f40d /jwt
parentdfbe695a92567ed19b0a6d96a89ac4cb1706d3a8 (diff)
downloadpyjwt-529647ab8cfc4e05776ebd5d146db9a1f9af6ebf.tar.gz
Remove unnecessary force_bytes() calls priot to base64url_decode() (#543)
The first line of base64url_decode() is: if isinstance(input, str): input = input.encode("ascii") It therefore accepts either str or bytes. Don't bother coercing to bytes at the call site.
Diffstat (limited to 'jwt')
-rw-r--r--jwt/algorithms.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/jwt/algorithms.py b/jwt/algorithms.py
index d4eb862..2eb090c 100644
--- a/jwt/algorithms.py
+++ b/jwt/algorithms.py
@@ -442,8 +442,8 @@ if has_crypto: # noqa: C901
if "x" not in obj or "y" not in obj:
raise InvalidKeyError("Not an Elliptic curve key")
- x = base64url_decode(force_bytes(obj.get("x")))
- y = base64url_decode(force_bytes(obj.get("y")))
+ x = base64url_decode(obj.get("x"))
+ y = base64url_decode(obj.get("y"))
curve = obj.get("crv")
if curve == "P-256":
@@ -479,7 +479,7 @@ if has_crypto: # noqa: C901
if "d" not in obj:
return public_numbers.public_key()
- d = base64url_decode(force_bytes(obj.get("d")))
+ d = base64url_decode(obj.get("d"))
if len(d) != len(x):
raise InvalidKeyError(
"D should be {} bytes for curve {}", len(x), curve