-
Notifications
You must be signed in to change notification settings - Fork 311
Muxer selection in security handshake #446
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
dbde5fd
Muxer selection in security handshake spec
julian88110 a8804dd
Add cross version and security sections
julian88110 ad1bae7
Add security and more sections
julian88110 0d35e15
Address review feedback points, add protobuf.
julian88110 ec2e959
Address some more review points.
julian88110 0042384
Correct some typos
julian88110 dcac239
Address feedback points and update noise section
julian88110 245361c
update Noise extention protobuf
julian88110 a5b3ef0
Remove TBD item
julian88110 349ac76
Remove some redandant info
julian88110 d6eb581
add alternative options considered
julian88110 07f5d70
rebase from master
julian88110 808a6f6
Merge remote-tracking branch 'origin/master' into MuxerSel-inSecHands…
julian88110 c7a1db0
Update noise registration with NoiseExtensions field for muxers.
julian88110 811fc05
Update connections/muxer-sel-in-sec-handshake.md
julian88110 239dfca
Revise noise handshake section to reflect early data carrier msg change.
julian88110 f0fe69a
Merge branch 'MuxerSel-inSecHandshake' of https://github.com/libp2p/s…
julian88110 1c716e2
Correct sequence example in noise handshake
julian88110 24d021d
Update connections/muxer-sel-in-sec-handshake.md
julian88110 5c28fc1
replace nextproto with ALPN extension
julian88110 3e3394a
Merge branch muxerSel-inSecHandshake' of https://github.com/libp2p/sp…
julian88110 c6b8ed2
Update connections/muxer-sel-in-sec-handshake.md
julian88110 54379a9
Update title
julian88110 06896c3
Merge branch 'MuxerSel-inSecHandshake' of https://github.com/libp2p/s…
julian88110 cc2bbcb
Update connections/muxer-sel-in-sec-handshake.md
julian88110 f81c6f4
Update connections/muxer-sel-in-sec-handshake.md
julian88110 0b73a38
address some review points
julian88110 aecfbb8
Address some review points
julian88110 5192ad1
Revise some typos
julian88110 4ff74a7
Revise the Noise selection process so that the selection of muxer is …
julian88110 f69b691
Editorial
julian88110 8e51f46
formatting
julian88110 eb4e697
Update muxer-sel-in-sec-handshake.md
julian88110 ef8657d
Update muxer-sel-in-sec-handshake.md
julian88110 8296442
Update muxer-sel-in-sec-handshake.md
julian88110 0fc4452
Consolidate some sections again and simplify some descriptiosn.
julian88110 a11ff1d
remove accidentally checked file
julian88110 b4ce114
Editorial changes
julian88110 9b11a68
Update connections/muxer-sel-in-sec-handshake.md
julian88110 002e37f
Update connections/muxer-sel-in-sec-handshake.md
julian88110 e3fcb38
Update connections/muxer-sel-in-sec-handshake.md
julian88110 4a167d1
Update connections/muxer-sel-in-sec-handshake.md
julian88110 3e9586b
Apply some suggestions from code review
marten-seemann f682f6b
add myself to list of authors
marten-seemann c07fb79
rewrite the Security section
marten-seemann 1e7a3c0
use the client's preference in Noise
marten-seemann eafbffc
rename document, link to it from connections README
marten-seemann 1e52c1e
remove section describing current muxer selection
marten-seemann fe88ccf
remove repetitive section introducing muxer selection
marten-seemann da63658
improve TLS section
marten-seemann 1306199
condense Noise section
marten-seemann bb070b2
Apply suggestions from code review
marten-seemann d90a15e
Apply suggestions from code review
marten-seemann 447be1f
Apply suggestions from code review
marten-seemann c23af93
bump revisions
marten-seemann 6fe4166
Apply suggestions from code review
marten-seemann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,220 @@ | ||
| # Muxer selection in security handshake | ||
|
|
||
|
|
||
| | Lifecycle Stage | Maturity | Status | Latest Revision | | ||
| |-----------------|---------------|--------|-----------------| | ||
| | 1A | Working Draft | Active | r1, 2022-09-07 | | ||
|
|
||
| Authors: [@julian88110] | ||
|
|
||
| Interest Group: [@marten-seemann], [@marcopolo], [@mxinden] | ||
|
|
||
| [@marten-seemann]: https://github.com/marten-seemann | ||
| [@marcopolo]: https://github.com/marcopolo | ||
| [@mxinden]: https://github.com/mxinden | ||
| [@julian88110]: https://github.com/julian88110 | ||
|
|
||
| See the [lifecycle document][lifecycle-spec] for context about maturity level | ||
| and spec status. | ||
|
|
||
| [lifecycle-spec]: https://github.com/libp2p/specs/blob/master/00-framework-01-spec-lifecycle.md | ||
|
|
||
| ## Table of Contents | ||
|
|
||
| - [Muxer selection in security handshake](#Muxer-selection-in-security-handshake) | ||
| - [Table of Contents](#table-of-contents) | ||
| - [Overview](#overview) | ||
| - [Design])(#Design) | ||
| - [Current connection upgrade process](#current-connection-upgrade-process) | ||
| - [Improved muxer selection](#improved-muxer-selection) | ||
| - [Muxer selection over TLS](#muxer-selection-over-tls) | ||
| - [Muxer selection over Noise](#muxer-selection-over-noise) | ||
| - [Cross version support](#cross-version-support) | ||
| - [TLS case](#tls-case) | ||
| - [Noise case](#noise-case) | ||
| - [Security](#security) | ||
| - [Protocol coupling](#protocol-coupling) | ||
|
|
||
| ## Overview | ||
|
|
||
| This document discribes an imporvement on the connection upgrade process. The | ||
| goal of the improvement is to reduce the number of RTTs that takes to select the | ||
| muxer of a connection. The solution relies on the ability of the security | ||
| protocol's handshake process to negotiate higher level protocols, which enables | ||
| the muxer selection to be carried out along with security protocol handshake. | ||
| The proposed solution saves the RTT of multistream selection for muxers. | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| For more context and the status of this work, please refer to [#426] | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| ## Design | ||
|
|
||
| ### Current connection upgrade process | ||
|
|
||
| The current connection upgrade process is described in detail in [connections]. | ||
| As shown in this [sequence-chart], after a network connection is established, | ||
| the following will happen to upgrade the conntection to a capable connection. | ||
|
|
||
| 1. The multistream-selection protocol is run over the connection to select the | ||
| security protocol to be used. | ||
| 2. The selected security protocol performs handshaking and establishs a secure | ||
| tunnel | ||
| 3. The multistream-selection protocol then will run again for muxer selection. | ||
| 4. Connection then is upgraded to a capable connection by the selected muxer. | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| ## Improved muxer selection | ||
|
|
||
| The security protocol's ability of supporting higher level abstract protocol | ||
| negotiation (for example, TLS's support of NextProtos, and Noise's support of | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
| Early Data) makes it possible to collapse the step 2 and step 3 in the | ||
| previous section into one step. Muxer selection can be performed as part of | ||
| the security protocol handshake, thus there is no need to perform another | ||
| mutistream-selection negotiation for muxer selection. | ||
|
|
||
| In order to achieve the above stated goal, each candidate muxer will be | ||
| represented by a protocol name/code, and the candidate muxers are supplied to | ||
| the security protocol's handshake process as a list of protocol names. | ||
|
|
||
| If the client and server agree upon the common muxer to be used, then the | ||
| result of the muxer selection is a muxer code represented by the selected | ||
| protocol name. If no agreement is reached upon by the client and server | ||
| then an empty muxer code is returned and the connection upgrade process | ||
| MUST fall back to the multistream-selection protocol to negotiate the muxer. | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| ### Muxer selection over TLS | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| When the security protocol selected by the upgrader is TLS, the [ALPN] | ||
| extesion of TLS handshake is used to select the muxer. | ||
|
|
||
| With ALPN, the client sends the list of supported application | ||
| protocols as part of the TLS ClientHello message. The server chooses | ||
| a protocol and sends the selected protocol as part of the TLS | ||
| ServerHello message. The application protocol negotiation can thus | ||
| be accomplished within the TLS handshake, without adding network | ||
| round-trips, and allows the server to associate a different | ||
| certificate with each application protocol, if desired. | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| For the purpose of muxer selection, the types of muxers are coded as protocol | ||
| names in the form of a list of strings, and inserted in the ALPN "NextProtos" | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
| field. An example list as following: | ||
|
|
||
| ["yamux/1.0.0", "mplux", "libp2p"] | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| The NextProtos list is ordered by preference, with the most prefered muxer at | ||
| the beginning. The "libp2p" protocol code MUST always be the last item in the | ||
| ALPN NextProtos list. | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| The server chooses the supported protocol by going through its prefered | ||
| protocol list and searchs if the protocol is supported by the client too. if no | ||
| mutually supported protcol is found the TLS handshake will fail. | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| If the selected NextProto is "libp2p" then the muxer selection process returns | ||
| an empty result, and the multistream-selection protocol MUST be run to negotiate | ||
| the muxer. | ||
|
|
||
| (TBD: in some cases early abortion is desireable) | ||
|
|
||
|
|
||
| ### Muxer selection over Noise | ||
|
|
||
| The libp2p Noise implementation allows the Noise handshake process to carry | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
| early data. [Noise-Early-Data] is carried in the second and third message of | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
| the handshake pattern: | ||
|
|
||
| XX: | ||
| -> e | ||
| <- e, ee, s, es | ||
| -> s, se | ||
|
|
||
| At the end of the handshake pattern, both the client and server have received | ||
| the peer's early data. The Noise protocol does not perform the protocol | ||
| selection as TLS does, rather it just delivers the early data to handshaking | ||
| peers. | ||
|
|
||
| The muxer selection logic runs out of the Noise handshake process, relying on | ||
| the early data exchanged during the handshake. The early data is delivered in | ||
| the form of a byte string. The supported muxers are passed in space separated | ||
| string codes. An example early data string: | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| "yamux/1.0.0 mplux" | ||
|
|
||
| The byte string is ordered by preference, with the most prefered muxer at the | ||
| beginning. | ||
|
|
||
| After the Noise handshake, the client and server run the muxer selection | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
| process with the same logic. Each side will go through the server's early | ||
| data from most prefered to lest prefered muxer, and if the muxer is in the | ||
| client's early data list, that muxer is selected. The process guarantees that | ||
| both the client and server reaches at the same conclusion of muxer slection. | ||
|
|
||
| If the muxer selection process does not find any mutually supported muxer, for | ||
| example, in the case that one early data string is empty, then an empty muxer | ||
| selection result is returned, and multistream-selection MUST be performed. | ||
|
|
||
| (TBD: in some cases early abortion is desireable) | ||
|
|
||
| ## Cross version support | ||
|
|
||
| The improved muxer selection approach MUST be interoperable with pervious | ||
| libp2p versions which do not support this improved approach. | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### TLS case | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| In the current version of libp2p, the "NextProtos" field is populated with a | ||
| key "libp2p". By appending the key of "libp2p" to the end of the supported | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
| muxer list, the TLS handshaking process is not broken when peers run different | ||
| versions of libp2p, because the minimum overlap of the peer's NextProtos sets | ||
| is always satisfied. When one peer runs the old version and the other peer runs | ||
| the version that supports this feature, the negotiated protocol is "libp2p". | ||
|
|
||
| In the case "libp2p" is the result of TLS ALPN, an empty result MUST be | ||
| returned to the upgrade process to indicate that no muxer was selected. And the | ||
| upgrade process MUST fall back to the multistream-selection protocol to | ||
| to negotiate the muxer to be selected. | ||
|
|
||
| ### Noise case | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| The existing version of libp2p Noise handshake carries empty early data. When a | ||
| version that supports this feature talks to an older version which does not | ||
| support this feature, the muxer selection process on the new version runs | ||
| against an empty string and will return empty muxer selection result. | ||
|
|
||
| In the case an empty muxer selection result is returned, the upgrade process | ||
| MUST fall back to the multistream-selection protocol to select the muxer. | ||
|
|
||
| ## Security | ||
|
marten-seemann marked this conversation as resolved.
Outdated
|
||
|
|
||
| The muxer list carried in TLS NextProtos field is part of the ClientHello | ||
| message which is not encrypted. This feature will expose the supported muxers | ||
| in plain text, but this is not a weakening of securiy posture. In the fuure | ||
| when [ECH] is ready the muxer info can be protected too. | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| The early data in Noise handshake is encrypted so that the muxer info carried | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
| over is protected. These is no security weakening in this case either. | ||
|
|
||
|
|
||
| ## Protocol coupling | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
| This feature aggregates the multistream-selecion function and security | ||
| handshake function. From function separation point of view, it introduces | ||
| coupling between different functions. But the argument is that in the case of | ||
| libp2p, the muxer and security are always needed at the same time, and it is a | ||
| small price to pay to gain efficiency by ruducing one RTT. | ||
|
julian88110 marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
|
|
||
| [#426]: https://github.com/libp2p/specs/issues/426 | ||
| [connections]: https://github.com/libp2p/specs/tree/master/connections | ||
| [sequence-chart]: https://github.com/libp2p/specs/tree/master/connections#upgrading-connections | ||
| [ALPN]: https://datatracker.ietf.org/doc/html/rfc7301 | ||
| [Noise-Early-Data]: https://github.com/libp2p/specs/tree/master/noise#the-libp2p-handshake-payload | ||
| [ECH]: https://datatracker.ietf.org/doc/draft-ietf-tls-esni/ | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.