-
Notifications
You must be signed in to change notification settings - Fork 80
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
Support for AECDH key exchange on server side #111
Conversation
no need to close the pull request when some test fail :) It's actually good to keep the same branch name and the same pull request ID for subsequent versions of the code. You can do that by modifying your local commit (either by amending or rebasing) and then force pushing to github. Now, for actual code: I'd rather not add more code to Finally, in comments you can use FFDHE to differentiate the "old" DH from the new, elliptic curve based, ECDHE. The FF stands for Finite Field and is already somewhat standard designation (see for example draft-ietf-tls-negotiated-ff-dhe-10. |
@@ -1697,15 +1701,39 @@ def _serverCertKeyExchange(self, clientHello, serverHello, | |||
|
|||
def _serverAnonKeyExchange(self, clientHello, serverHello, cipherSuite, | |||
settings): | |||
# Calculate ECDH Xs, Ys | |||
print("1") |
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.
don't forget to remove it :)
Ok :) Should I reopen this pull request? |
yes
yes
the difference between RSA_DHE and ADH are the calls to |
Sorry, that long time nothing happend. Im almost done with moving ADH to keyexchange, but I wanted to ask, if you please could help me, how to make openssl client with DHE-RSA to try connection with tlslite server. I want to test it before sending it, ADH works good, but I want to test DHE-RSA too, but I dont know how to right generate certificate and use it in openssl s_client. Everything that I tried gave me |
since tlslite-ng does not verify client certificates, you can use any set of certificates for testing, there is already a set in the something like this should be enough to test it:
|
Ok, thanks. When I tried it like you wrote, it works. |
first: don't worry, you can't do anything to break my repository (or rather, if you do, tell those people: https://bounty.github.com/ 😄 ), and even in your repository (both local and remote) you can fix most if not all problems (if you're really worried you may loose your work, just copy the whole repository folder, with the hidden second: you add changes to this pull request by changing your local branch (that usually is just a series of alternatively, if you created a new branch to work out the pull request, you can rename local copy of the |
Ok, thanks.
|
|
||
NOT stable API, do NOT use | ||
""" | ||
|
||
def __init__(self, cipherSuite, clientHello, serverHello, privateKey): | ||
super(DHE_RSAKeyExchange, self).__init__(cipherSuite, clientHello, | ||
super(ADHKeyExchange, self).__init__(cipherSuite, clientHello, |
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.
you need to do the same in makeClientKeyExchange
(see Travis-CI errors)
finally, please merge those two commits together, in |
one more thing, you may want to read CONTRIBUTING.md as it says how to set up your system so that you can run the tests from the Makefile (using |
6bbb1d3
to
49e3ce9
Compare
I tried to make merge with |
hmm, maybe it's because your local master doesn't match my master
no, there isn't one, you have to do everything locally
no problem, nobody is born with the knowledge how to operate ok, so now I see it, your master doesn't match my master, so the suggestion to rebase on top of master was incorrect, at least for you, sorry about that so, on https://github.com/mildass/tlslite-ng/network I see that the master and aecdh-key-exchange contain exactly the same commits If that is not the case locally (you can check that using either it may be good idea to save the state of that branch anyway, as the first commit is correct functionally, and you may want to use it later as a template... (as later rebases will essentially drop it) once we know that we can operate on master without fear of loosing previous work, we need to update it to my version of master first, make sure that you're on master, use
now you have to make a local copy of my repository, to do that, you first need to add a remote: now your local repository knows how my repository looks like to switch your local master to the correct position, you can run the following command: (normal workflow is to now that we have updated local master, we need to update your remote master on github: now we can switch to the feature branch and and combine all the commits together:
in the do not push the branch to github yet! if you do, github sometimes gets confused and drops the comments and you then won't know what changes you should do to the code now's the time to resolve all the comments I provided; edit the code as normal, but instead of doing once you think that all the changes are as they should be, run the test suite with now, that the commit is updated, and the tests pass, you can force push your local branch to github: note that for feature branches like aecdh-key-exchange, it is normal to |
Everything looks good, but |
neither |
I got this error from tests |
aah, yes, indeed the new hypothesis requires |
49e3ce9
to
c9d2b55
Compare
def makeServerKeyExchange(self, sigHash=None): | ||
"""Prepare server side of key exchange with selected parameters""" | ||
super(DHE_RSAKeyExchange, self).makeServerKeyExchange() | ||
self.signServerKeyExchange(self.serverKeyExchange, sigHash) |
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.
why adding a serverKeyExchange
field in the object?
anything wrong with this?:
ske = super(DHE_RSAKeyExchange, self).makeServerKeyExchange()
self.signServerKeyExchange(ske, sigHash)
return ske
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.
super(DHE_RSAKeyExchange, self).makeServerKeyExchange()
creates attribute serverKeyExchange
. This attribute will be created in both cases, so why cant we use it and do not create new variable ske
?
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.
because adding attributes to objects outside constructors is bad form (you can see landscape test complaining about it)
and makeServerKeyExchange()
needs to return (and already returns) a ServerKeyExchange object, so there is no need to pass this SKE through a field, it just makes code more complex
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, I got it. I'll change it, before working on AECDH.
When I will add changes now, its just on aecdh-key-exchange
branch - git add
, git commit
, git rebase -i master
and git push origin aecdh-key-exchange --force
, right?
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.
yes, but if you still have just one commit in the branch, you can do also git commit --amend
instead of git commit
, git rebase -i master
(with squash/fixup)
class ADHKeyExchange(KeyExchange): | ||
""" | ||
Handling of anonymous Diffe-Hellman Key exchange | ||
FFDHE without signing serverKeyExchange useful for anonymous DH | ||
NOT stable API, do NOT use |
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.
two things, the summary of the documentation string (the first line) should be a single line and be separated by an empty line from the rest of the doc string
while we're editing it, I think we can remove the "Not stable API" warning, it's not the case any more (it was added when the code was in a different module actually)
sorry, for some reason github didn't notify me of the new pull request, please mention/ping me (@tomato42) if I haven't provided a review on a patch in 24h (especially during the week) |
ea91eba
to
9ee3935
Compare
looks good 👍 you may want to rebase on top of my master branch after you've created additional commits - travis will then finish tests much quicker |
You mean |
yes, but first you need to go to your master branch and update it to my master, so it will be
then switch to the feature branch, and rebase and push changes:
|
Adds ADHKeyExchange class, where is ADH from tlsconnection.py, from which DHE_RSAKeyExchange inherit.
9ee3935
to
76cbe31
Compare
Is it now ok and ready to start working on AECDH? |
@tomato42 Is it rebased, how you have meant? I'm not sure, because I think that it is same as every rebase, that I have done after commit. |
you could have started working on AECDH right away, the and yes, this is what I meant, if you go to the commit: mildas@76cbe31 , on the upper right side you'll see the commit id, to left of it is "1 parent" with a link to other commit, it now points to f9950c8, which is a new commit in my repo, and in Travis you can see that the tests finished in 3 minutes per configuration, not 25 minutes per configuration |
So now just |
in general yes, but if you don't modify the existing commit, you shouldn't need to use |
cipherSuite): | ||
if result in (0,1): yield result | ||
else: break | ||
premasterSecret = result |
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.
everything from for result ...
is the same as in the ADH, the code can reuse it
If I |
only if you set the action for the second action to |
9e42dce
to
732ea1d
Compare
@tomato42 What do you think about it? |
we could make an abstract class and use multiple inheritance, but I don't think it's worth it this time, we can rethink it with addition of ECDSA. I'll do the review on Monday |
""" | ||
def __init__(self, cipherSuite, clientHello, serverHello, acceptedCurves): | ||
super(AECDHKeyExchange, self).__init__(cipherSuite, clientHello, | ||
serverHello) | ||
#pylint: enable = invalid-name |
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.
since code is not disabling the invalid-name check, it doesn't need to re-enable it
sorry for the delay in review. Those nits are all of the problems, please fix them and next message will be that the PR is merged 😄 |
732ea1d
to
632099d
Compare
Reviewed 1 of 2 files at r11, 1 of 1 files at r12. Comments from Reviewable |
Thank you! |
The main changes are in _serverAnonKeyExchange in parts
if cipherSuite in CipherSuite.ecdhAnonSuites:
.else:
part is same as it was (ADH support).This change is