Skip to content
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

implement QUIC v2 #3432

Merged
merged 6 commits into from Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions http3/server.go
Expand Up @@ -44,7 +44,7 @@ const (
)

func versionToALPN(v protocol.VersionNumber) string {
if v == protocol.Version1 {
if v == protocol.Version1 || v == protocol.Version2 {
return nextProtoH3
}
if v == protocol.VersionTLS || v == protocol.VersionDraft29 {
Expand All @@ -63,11 +63,9 @@ func ConfigureTLSConfig(tlsConf *tls.Config) *tls.Config {
return &tls.Config{
GetConfigForClient: func(ch *tls.ClientHelloInfo) (*tls.Config, error) {
// determine the ALPN from the QUIC version used
proto := nextProtoH3Draft29
proto := nextProtoH3
if qconn, ok := ch.Conn.(handshake.ConnWithVersion); ok {
if qconn.GetQUICVersion() == protocol.Version1 {
proto = nextProtoH3
}
proto = versionToALPN(qconn.GetQUICVersion())
}
config := tlsConf
if tlsConf.GetConfigForClient != nil {
Expand Down
10 changes: 5 additions & 5 deletions http3/server_test.go
Expand Up @@ -819,23 +819,23 @@ var _ = Describe("Server", func() {
ch = &tls.ClientHelloInfo{}
})

It("advertises draft by default", func() {
It("advertises v1 by default", func() {
tlsConf = ConfigureTLSConfig(tlsConf)
Expect(tlsConf.GetConfigForClient).NotTo(BeNil())

config, err := tlsConf.GetConfigForClient(ch)
Expect(err).NotTo(HaveOccurred())
Expect(config.NextProtos).To(Equal([]string{nextProtoH3Draft29}))
Expect(config.NextProtos).To(Equal([]string{nextProtoH3}))
})

It("advertises h3 for quic version 1", func() {
It("advertises h3-29 for draft-29", func() {
tlsConf = ConfigureTLSConfig(tlsConf)
Expect(tlsConf.GetConfigForClient).NotTo(BeNil())

ch.Conn = newMockConn(protocol.Version1)
ch.Conn = newMockConn(protocol.VersionDraft29)
config, err := tlsConf.GetConfigForClient(ch)
Expect(err).NotTo(HaveOccurred())
Expect(config.NextProtos).To(Equal([]string{nextProtoH3}))
Expect(config.NextProtos).To(Equal([]string{nextProtoH3Draft29}))
})
})

Expand Down
1 change: 1 addition & 0 deletions interface.go
Expand Up @@ -23,6 +23,7 @@ const (
VersionDraft29 = protocol.VersionDraft29
// Version1 is RFC 9000
Version1 = protocol.Version1
Version2 = protocol.Version2
)

// A Token can be used to verify the ownership of the client address.
Expand Down
12 changes: 9 additions & 3 deletions internal/handshake/aead.go
Expand Up @@ -9,9 +9,15 @@ import (
"github.com/lucas-clemente/quic-go/internal/utils"
)

func createAEAD(suite *qtls.CipherSuiteTLS13, trafficSecret []byte) cipher.AEAD {
key := hkdfExpandLabel(suite.Hash, trafficSecret, []byte{}, "quic key", suite.KeyLen)
iv := hkdfExpandLabel(suite.Hash, trafficSecret, []byte{}, "quic iv", suite.IVLen())
func createAEAD(suite *qtls.CipherSuiteTLS13, trafficSecret []byte, v protocol.VersionNumber) cipher.AEAD {
keyLabel := hkdfLabelKeyV1
ivLabel := hkdfLabelIVV1
if v == protocol.Version2 {
keyLabel = hkdfLabelKeyV2
ivLabel = hkdfLabelIVV2
}
key := hkdfExpandLabel(suite.Hash, trafficSecret, []byte{}, keyLabel, suite.KeyLen)
iv := hkdfExpandLabel(suite.Hash, trafficSecret, []byte{}, ivLabel, suite.IVLen())
return suite.AEAD(key, iv)
}

Expand Down