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
Preliminary Version Negotiation Support #14
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…PacketProtectorHandler. Added ability to update / reinstantiate all keys upon a Version negotiation.
…initialize our PacketProtectorHandler.
…r of preference).
…nd responding to them accordingly.
…g an unsupported version.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Preliminary Support for Version Negotiation
As described in RFC9000 - Section 6
What
This PR adds preliminary support for version negotiation at the beginning of a Connection.
How
Server Side
Client Side
Version
passed into theQUICClientHandler
's initializer.VersionNegotiationPacket
in response to our Initial Client Hello packet.PacketProtectorHandler
cycles through our supported versions and the servers supported versions searching for the best match.if
we find a Version matchPacketProtectorHandler
fires aVersionNegotiated
event down the pipeline for ourStateHandler
to receive.Statehandler
reinitializes the NIOSSLHandler with the correct version dependent params and writes the newly generated ClientHello out to be padded and encrypted by thePacketProtectorHandler
using the newly generated keys.else
(we don't have a supported version overlap)PacketProtectorHandler
enters the.incompatible
state and fires aVersionNegotiationFailed
event down the pipeline for theStateHandler
to receive.StateHandler
is responsible for closing / terminating the connection upon receiving the event.Testing it
Swift Server <--> Go Client
Using the Go example code provided in the Go Client Handshake Test file. The Go Client will attempt to establish a connection using
.version1
. If we change our supported versions in the Quic file to only.versionDraft29
then we will trigger a Version Negotiation to take place. The Go Client, will re send the Initial Client Hello packet using theversionDraft29
spec and the connection will proceed as usual.Swift Client <--> Go Server
Using the Go example code provided in the Go Server Handshake Test file. The Go Server supports
.version2
,.version1
and.versionDraft29
. So we need to provide a fake / unknown version in order trigger a version negotiation. If we change.version2
's tag from the correct identifier0x6b33_43cf
to an incorrect identifier of0x2
then attempt to connect to the Go Server using the supportedversions: [.version2, .version1]
. We'll receive aVersionNegotiationPacket
in response to the unknown version0x2
and ourPacketProtectorHandler
will match on the next best supported version.version1
. At which point the logic stated above plays out and the connection is established using the negotiated version,.version1
.