diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | jwt/algorithms.py | 16 |
2 files changed, 12 insertions, 6 deletions
@@ -15,7 +15,7 @@ $ pip install PyJWT **A Note on Dependencies**: -RSA and ECDSA signatures depend on the recommended `cryptography` package. If you plan on +RSA and ECDSA signatures depend on the recommended `cryptography` package (0.8+). If you plan on using any of those algorithms, you'll need to install it as well. ``` diff --git a/jwt/algorithms.py b/jwt/algorithms.py index 4a40cfb..cda7b19 100644 --- a/jwt/algorithms.py +++ b/jwt/algorithms.py @@ -5,10 +5,16 @@ from .compat import constant_time_compare, string_types, text_type from .exceptions import InvalidKeyError try: - from cryptography.hazmat.primitives import interfaces, hashes + from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.serialization import ( load_pem_private_key, load_pem_public_key, load_ssh_public_key ) + from cryptography.hazmat.primitives.asymmetric.rsa import ( + RSAPrivateKey, RSAPublicKey + ) + from cryptography.hazmat.primitives.asymmetric.ec import ( + EllipticCurvePrivateKey, EllipticCurvePublicKey + ) from cryptography.hazmat.primitives.asymmetric import ec, padding from cryptography.hazmat.backends import default_backend from cryptography.exceptions import InvalidSignature @@ -142,8 +148,8 @@ if has_crypto: self.hash_alg = hash_alg() def prepare_key(self, key): - if isinstance(key, interfaces.RSAPrivateKey) or \ - isinstance(key, interfaces.RSAPublicKey): + if isinstance(key, RSAPrivateKey) or \ + isinstance(key, RSAPublicKey): return key if isinstance(key, string_types): @@ -199,8 +205,8 @@ if has_crypto: self.hash_alg = hash_alg() def prepare_key(self, key): - if isinstance(key, interfaces.EllipticCurvePrivateKey) or \ - isinstance(key, interfaces.EllipticCurvePublicKey): + if isinstance(key, EllipticCurvePrivateKey) or \ + isinstance(key, EllipticCurvePublicKey): return key if isinstance(key, string_types): |