-
Notifications
You must be signed in to change notification settings - Fork 114
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
Remove custom PrivateKey exponents/coefficient #71
Remove custom PrivateKey exponents/coefficient #71
Conversation
Given those choices, I'd say choice 2, with a Alternatively we could use the What do you think @adamantike ? |
I completely agree, we have to warn the user about every malformed key, not just the first time. And I think However, I'm in favor of adding the checking in the |
+1 |
@sybrenstuvel this is ready for review! I added |
@@ -42,6 +43,8 @@ | |||
import rsa.randnum | |||
import rsa.core | |||
|
|||
warnings.simplefilter('always') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is something a library should do, or is it? I don't have much experience with the warnings module, but this looks like changing global configuration. If that's indeed the case, we shouldn't (it should be left to the application using our library).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!! I will change it to set this just in the test
@@ -17,10 +17,13 @@ | |||
"""Unittest for saving and loading keys.""" | |||
|
|||
import base64 | |||
import unittest | |||
import mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use unittest.mock. mock
is an implementation backported to Python 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need compatibility with Python 2, and unittest.mock
doesn't provide that to us. According to mock
documentation:
mock is now part of the Python standard library, available as unittest.mock in Python 3.3 onwards. However, if you are writing code that runs on multiple versions of Python the mock package is better, as you get the newest features from the latest release of Python available for all Pythons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we leave it in then ;-)
As discussed in #50, it removes option for custom exps/coef on
PrivateKey
constructor. This way, we can trust on these values for CRT-based primitives and any other future implementation.RFC state because I would like to discuss what's the best solution for PKCS#1 key file imports, and not-so-small repos depend on this (boto/boto, aws/aws-cli, google/oauth2client, ... ;) ).
Alternatives I can think of:
PrivateKey
instance. Mathematically correct, but it could theoretically change behaviour for malformed key files (actually, we currently don't use these values, so I think it's safe).print()
, log... ?)