summaryrefslogtreecommitdiff
path: root/jwt/algorithms.py
diff options
context:
space:
mode:
authorMark Adams <mark@markadams.me>2017-03-14 07:33:57 -0500
committerMark Adams <mark@markadams.me>2017-03-14 07:44:18 -0500
commit1710c1524c69c39dfece7a24b87179be5eeff217 (patch)
treecd292df6687973ce1c63b4ed517c0884e7557824 /jwt/algorithms.py
parent299d196383836e1f804ef4441365a94862e08abe (diff)
downloadpyjwt-1710c1524c69c39dfece7a24b87179be5eeff217.tar.gz
Add support for public keys in OpenSSH (RFC 4253) format.
Cryptography previously lacked support for ECDSA keys in RFC 4253 format. Now that they have support for those keys, we should take advantage of it and support them in PyJWT. Implements #243.
Diffstat (limited to 'jwt/algorithms.py')
-rw-r--r--jwt/algorithms.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/jwt/algorithms.py b/jwt/algorithms.py
index 2fe1883..f6d990a 100644
--- a/jwt/algorithms.py
+++ b/jwt/algorithms.py
@@ -356,7 +356,10 @@ if has_crypto:
# a Signing Key or a Verifying Key, so we try
# the Verifying Key first.
try:
- key = load_pem_public_key(key, backend=default_backend())
+ if key.startswith(b'ecdsa-sha2-'):
+ key = load_ssh_public_key(key, backend=default_backend())
+ else:
+ key = load_pem_public_key(key, backend=default_backend())
except ValueError:
key = load_pem_private_key(key, password=None, backend=default_backend())