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

add unsafe_skip_rsa_key_validation #7667

Merged
merged 3 commits into from
Oct 3, 2022
Merged

Conversation

reaperhulk
Copy link
Member

This allows users to skip RSA key validation when calling load_pem_private_key, load_der_private_key, and
RSAPrivateNumbers.private_key. This is a significant performance improvement but is only safe if you know the key is valid. If you use this when the key is invalid OpenSSL makes no guarantees about what might happen. Infinite loops, crashes, and all manner of terrible things become possible if that occurs. Beware, beware, beware.

@reaperhulk reaperhulk force-pushed the fast-but-dangerous-rsa branch 4 times, most recently from 79d8c65 to 93c93d8 Compare October 1, 2022 21:10
docs/hazmat/primitives/asymmetric/rsa.rst Outdated Show resolved Hide resolved
docs/hazmat/primitives/asymmetric/rsa.rst Outdated Show resolved Hide resolved
src/cryptography/hazmat/backends/openssl/backend.py Outdated Show resolved Hide resolved
src/cryptography/hazmat/backends/openssl/backend.py Outdated Show resolved Hide resolved
This allows users to skip RSA key validation when calling
load_pem_private_key, load_der_private_key, and
RSAPrivateNumbers.private_key. This is a significant performance
improvement but is **only safe if you know the key is valid**. If you
use this when the key is invalid OpenSSL makes no guarantees about what
might happen. Infinite loops, crashes, and all manner of terrible things
become possible if that occurs. Beware, beware, beware.
reaperhulk and others added 2 commits October 3, 2022 07:16
Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
@alex alex enabled auto-merge (squash) October 3, 2022 14:26
@alex alex merged commit 01687d6 into pyca:main Oct 3, 2022
@reaperhulk reaperhulk deleted the fast-but-dangerous-rsa branch October 3, 2022 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Massive performance regression in RSA key loading in cryptography 37.0.x
2 participants