-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Error cleanly if the public and private keys to an ECDH key exchange … #2455
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
Conversation
…are on different curves
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.
This fails py3's pep8 with E721 do not compare types, use 'isinstance()'
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.
Yeah, I don't know what that means. What's teh right way to check if two curves rae equivilant.
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 know this was already fixed another way, but for future reference you could do it as a type check by saying:
if not isinstance(peer_public_key.curve, type(self.curve)):
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.
Yeah, I wonder if we should just have an __eq__
on curves.
On Thu, Oct 29, 2015 at 9:37 AM, Ron Frederick notifications@github.com
wrote:
In src/cryptography/hazmat/backends/openssl/ec.py
#2455 (comment):@@ -182,6 +182,11 @@ def exchange(self, algorithm, peer_public_key):
_Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM
)
if type(peer_public_key.curve) is not type(self.curve):
I know this was already fixed another way, but for future reference you
could do it as a type check by saying:if not isinstance(peer_public_key.curve, type(self.curve)):
—
Reply to this email directly or view it on GitHub
https://github.com/pyca/cryptography/pull/2455/files#r43384597.
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084
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.
Yeah, that would probably look cleaner. When writing an eq for classes that have other members to compare, part of it is usually involves an isinstance() check of this sort before comparing the members. In this case, if these classes have no other state, the isinstance() by itself could be enough.
That said, is there any reason these are classes instead of instances that could just be compared directly with "is"? Is it just for consistency with other parts of the API where arguments might be passed when constructing such an object?
One possibility here would be to make these singletons, so you still construct them from classes, but the constructor always returns the same instance.
Current coverage is
|
Error cleanly if the public and private keys to an ECDH key exchange …
Changes Unknown when pulling e245345 on alex:different-curves into ** on pyca:master**. |
…are on different curves