Skip to content

Commit

Permalink
Merge pull request #113 from mark-adams/fix-crypto-warnings
Browse files Browse the repository at this point in the history
Fixed some DeprecationWarnings related to our cryptography 0.8 upgrade
  • Loading branch information
jpadilla committed Mar 18, 2015
2 parents ce3e84e + 8e69483 commit 3cc2e99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

```
Expand Down
16 changes: 11 additions & 5 deletions jwt/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
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
Expand Down Expand Up @@ -142,8 +148,8 @@ def __init__(self, hash_alg):
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):
Expand Down Expand Up @@ -199,8 +205,8 @@ def __init__(self, hash_alg):
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):
Expand Down

0 comments on commit 3cc2e99

Please sign in to comment.