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

Conversation

bdraco
Copy link
Contributor

@bdraco bdraco commented Jul 22, 2020

In #117 dependency on ecdsa cryptography backend was removed, however it is still loaded even when not used. Since ecdsa has a load time performance penalty when gmpy2 is not installed, this can be a bit painful on embedded systems.

We can avoid all this overhead and check to see if the key object hasattr to_pem instead since we only
care of these if ecdsa has already been loaded by something else.

@bdraco
Copy link
Contributor Author

bdraco commented Jul 22, 2020

The test failure is unrelated and documented here : #176

@blag
Copy link
Contributor

blag commented Jul 29, 2020

Thanks for this, I like it. I'm waiting on tlsfuzzer/python-ecdsa#205 to be merged, but in the meantime would you mind pinning ecdsa < 0.15 in requirements.txt so the tests pass for this PR? Once the tests pass I'll merge it in.

@blag
Copy link
Contributor

blag commented Jul 29, 2020

I have another branch that I'm actively working on where I make the Travis tests a lot more straightforward, so this should hopefully not be an issue for very much longer, but for now the Travis configuration hands off to tox to run the actual tests.

And tox "installs the current package", which seems to mean that it runs the equivalent of python setup.py install. Unfortunately, none of that machinery reads requirements.txt, so only pinning ecdsa there won't fix the tests (it does fix installation via pip though). You'll have to tweak the constraints in legacy_backend_requires in setup.py to fix the tests.

@codecov
Copy link

codecov bot commented Jul 29, 2020

Codecov Report

Merging #178 into master will decrease coverage by 6.31%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #178      +/-   ##
==========================================
- Coverage   97.18%   90.87%   -6.32%     
==========================================
  Files          14       14              
  Lines        1067     1063       -4     
==========================================
- Hits         1037      966      -71     
- Misses         30       97      +67     
Impacted Files Coverage Δ
jose/backends/cryptography_backend.py 98.07% <100.00%> (-0.04%) ⬇️
jose/backends/rsa_backend.py 60.27% <0.00%> (-36.31%) ⬇️
jose/utils.py 69.56% <0.00%> (-30.44%) ⬇️
jose/backends/__init__.py 81.81% <0.00%> (-18.19%) ⬇️
jose/backends/pycrypto_backend.py 97.52% <0.00%> (+1.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b4d4385...d0a6268. Read the comment docs.

@bdraco
Copy link
Contributor Author

bdraco commented Jul 29, 2020

@blag I'm not sure what is going on with codecov here 🤷‍♂️ , but the change has 100% of diff hit.

@blag
Copy link
Contributor

blag commented Jul 29, 2020

No worries, codecov gets confused sometimes. This looks good. Thank you for fixing the tests and dependency!

@blag blag merged commit 5cbebe0 into mpdavis:master Jul 29, 2020
@bdraco
Copy link
Contributor Author

bdraco commented Jul 29, 2020

Thanks @blag. Can we get a version bump so we can get this in Home Assistant release 0.114?

@blag
Copy link
Contributor

blag commented Jul 29, 2020

Wow, you all really seem to take "release early, release often" as "release right now, release constantly". 😜

I'll bump the version and publish it to PyPI. Thank you all for Home Assistant!

@blag
Copy link
Contributor

blag commented Jul 30, 2020

@bdraco Version 3.2.0 is now available on PyPI and GitHub. 😄

@bdraco
Copy link
Contributor Author

bdraco commented Jul 30, 2020

@bdraco Version 3.2.0 is now available on PyPI and GitHub. 😄

Thank you 🍾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants