Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid loading python-ecdsa when using the cryptography backend #178

Merged
merged 3 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions jose/backends/cryptography_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

import six

try:
from ecdsa import SigningKey as EcdsaSigningKey, VerifyingKey as EcdsaVerifyingKey
except ImportError:
EcdsaSigningKey = EcdsaVerifyingKey = None

from jose.backends.base import Key
from jose.utils import base64_to_long, long_to_base64
from jose.constants import ALGORITHMS
Expand Down Expand Up @@ -46,7 +41,7 @@ def __init__(self, key, algorithm, cryptography_backend=default_backend):
self.prepared_key = key
return

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

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pycryptodome
six
rsa
ecdsa
ecdsa<0.15
pyasn1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _cryptography_version():
'pycrypto': ['pycrypto >=2.6.0, <2.7.0'] + pyasn1,
'pycryptodome': ['pycryptodome >=3.3.1, <4.0.0'] + pyasn1,
}
legacy_backend_requires = ['ecdsa <1.0', 'rsa'] + pyasn1
legacy_backend_requires = ['ecdsa <0.15', 'rsa'] + pyasn1
install_requires = ['six <2.0']

# TODO: work this into the extras selection instead.
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ deps =
pytest
pytest-cov
pytest-runner
-r{toxinidir}/requirements.txt

commands_pre =
# Remove the python-rsa and python-ecdsa backends
only: pip uninstall -y ecdsa rsa
Expand Down