Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5cbebe0

Browse files
authored
Merge pull request #178 from bdraco/avoid_loading_ecdsa
Avoid loading python-ecdsa when using the cryptography backend
2 parents b4d4385 + d0a6268 commit 5cbebe0

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

jose/backends/cryptography_backend.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44

55
import six
66

7-
try:
8-
from ecdsa import SigningKey as EcdsaSigningKey, VerifyingKey as EcdsaVerifyingKey
9-
except ImportError:
10-
EcdsaSigningKey = EcdsaVerifyingKey = None
11-
127
from jose.backends.base import Key
138
from jose.utils import base64_to_long, long_to_base64
149
from jose.constants import ALGORITHMS
@@ -46,7 +41,7 @@ def __init__(self, key, algorithm, cryptography_backend=default_backend):
4641
self.prepared_key = key
4742
return
4843

49-
if None not in (EcdsaSigningKey, EcdsaVerifyingKey) and isinstance(key, (EcdsaSigningKey, EcdsaVerifyingKey)):
44+
if hasattr(key, 'to_pem'):
5045
# convert to PEM and let cryptography below load it as PEM
5146
key = key.to_pem().decode('utf-8')
5247

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pycryptodome
22
six
33
rsa
4-
ecdsa
4+
ecdsa<0.15
55
pyasn1

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _cryptography_version():
3838
'pycrypto': ['pycrypto >=2.6.0, <2.7.0'] + pyasn1,
3939
'pycryptodome': ['pycryptodome >=3.3.1, <4.0.0'] + pyasn1,
4040
}
41-
legacy_backend_requires = ['ecdsa <1.0', 'rsa'] + pyasn1
41+
legacy_backend_requires = ['ecdsa <0.15', 'rsa'] + pyasn1
4242
install_requires = ['six <2.0']
4343

4444
# TODO: work this into the extras selection instead.

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ deps =
2121
pytest
2222
pytest-cov
2323
pytest-runner
24+
-r{toxinidir}/requirements.txt
25+
2426
commands_pre =
2527
# Remove the python-rsa and python-ecdsa backends
2628
only: pip uninstall -y ecdsa rsa

0 commit comments

Comments
 (0)