Skip to content

Commit 3cc2e99

Browse files
committed
Merge pull request #113 from mark-adams/fix-crypto-warnings
Fixed some DeprecationWarnings related to our cryptography 0.8 upgrade
2 parents ce3e84e + 8e69483 commit 3cc2e99

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $ pip install PyJWT
1515

1616
**A Note on Dependencies**:
1717

18-
RSA and ECDSA signatures depend on the recommended `cryptography` package. If you plan on
18+
RSA and ECDSA signatures depend on the recommended `cryptography` package (0.8+). If you plan on
1919
using any of those algorithms, you'll need to install it as well.
2020

2121
```

jwt/algorithms.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@
55
from .exceptions import InvalidKeyError
66

77
try:
8-
from cryptography.hazmat.primitives import interfaces, hashes
8+
from cryptography.hazmat.primitives import hashes
99
from cryptography.hazmat.primitives.serialization import (
1010
load_pem_private_key, load_pem_public_key, load_ssh_public_key
1111
)
12+
from cryptography.hazmat.primitives.asymmetric.rsa import (
13+
RSAPrivateKey, RSAPublicKey
14+
)
15+
from cryptography.hazmat.primitives.asymmetric.ec import (
16+
EllipticCurvePrivateKey, EllipticCurvePublicKey
17+
)
1218
from cryptography.hazmat.primitives.asymmetric import ec, padding
1319
from cryptography.hazmat.backends import default_backend
1420
from cryptography.exceptions import InvalidSignature
@@ -142,8 +148,8 @@ def __init__(self, hash_alg):
142148
self.hash_alg = hash_alg()
143149

144150
def prepare_key(self, key):
145-
if isinstance(key, interfaces.RSAPrivateKey) or \
146-
isinstance(key, interfaces.RSAPublicKey):
151+
if isinstance(key, RSAPrivateKey) or \
152+
isinstance(key, RSAPublicKey):
147153
return key
148154

149155
if isinstance(key, string_types):
@@ -199,8 +205,8 @@ def __init__(self, hash_alg):
199205
self.hash_alg = hash_alg()
200206

201207
def prepare_key(self, key):
202-
if isinstance(key, interfaces.EllipticCurvePrivateKey) or \
203-
isinstance(key, interfaces.EllipticCurvePublicKey):
208+
if isinstance(key, EllipticCurvePrivateKey) or \
209+
isinstance(key, EllipticCurvePublicKey):
204210
return key
205211

206212
if isinstance(key, string_types):

0 commit comments

Comments
 (0)