diff --git a/common.go b/common.go index 371d386..e50334e 100644 --- a/common.go +++ b/common.go @@ -43,16 +43,16 @@ import ( ) // TODO: Reconsider the use of global variables -var QuicVersion uint32 = 0xff000017 // See https://tools.ietf.org/html/draft-ietf-quic-transport-08#section-4 -var QuicALPNToken = "hq-23" // See https://www.ietf.org/mail-archive/web/quic/current/msg01882.html -var QuicH3ALPNToken = "h3-23" // See https://tools.ietf.org/html/draft-ietf-quic-http-17#section-2.1 +var QuicVersion uint32 = 0xff000018 // See https://tools.ietf.org/html/draft-ietf-quic-transport-08#section-4 +var QuicALPNToken = "hq-24" // See https://www.ietf.org/mail-archive/web/quic/current/msg01882.html +var QuicH3ALPNToken = "h3-24" // See https://tools.ietf.org/html/draft-ietf-quic-http-17#section-2.1 const ( MinimumInitialLength = 1252 MinimumInitialLengthv6 = 1232 MaxUDPPayloadSize = 65507 - MaximumVersion = 0xff000017 - MinimumVersion = 0xff000017 + MaximumVersion = 0xff000018 + MinimumVersion = 0xff000018 ) // errors diff --git a/scenarii/key_update.go b/scenarii/key_update.go index 2776aad..180584f 100644 --- a/scenarii/key_update.go +++ b/scenarii/key_update.go @@ -47,8 +47,8 @@ forLoop1: } // TODO: Move this to crypto.go - readSecret := conn.Tls.HkdfExpandLabel(conn.Tls.ProtectedReadSecret(), "traffic upd", nil, conn.Tls.HashDigestSize(), pigotls.BaseLabel) - writeSecret := conn.Tls.HkdfExpandLabel(conn.Tls.ProtectedWriteSecret(), "traffic upd", nil, conn.Tls.HashDigestSize(), pigotls.BaseLabel) + readSecret := conn.Tls.HkdfExpandLabel(conn.Tls.ProtectedReadSecret(), "ku", nil, conn.Tls.HashDigestSize(), pigotls.QuicBaseLabel) + writeSecret := conn.Tls.HkdfExpandLabel(conn.Tls.ProtectedWriteSecret(), "ku", nil, conn.Tls.HashDigestSize(), pigotls.QuicBaseLabel) oldState := conn.CryptoStates[qt.EncryptionLevel1RTT] diff --git a/scenarii/multi_packet_client_hello.go b/scenarii/multi_packet_client_hello.go new file mode 100644 index 0000000..b31c6c7 --- /dev/null +++ b/scenarii/multi_packet_client_hello.go @@ -0,0 +1,71 @@ +package scenarii + +import ( + qt "github.com/QUIC-Tracker/quic-tracker" + "github.com/QUIC-Tracker/quic-tracker/agents" + "time" +) + +const ( + MPCH_TLSHandshakeFailed = 1 + MPCH_RequestFailed = 2 +) + +type MultiPacketClientHello struct { + AbstractScenario +} + +func NewMultiPacketClientHello() *MultiPacketClientHello { + return &MultiPacketClientHello{AbstractScenario{name: "multi_packet_client_hello", version: 1}} +} + +func (s *MultiPacketClientHello) Run(conn *qt.Connection, trace *qt.Trace, preferredPath string, debug bool) { + connAgents := agents.AttachAgentsToConnection(conn, agents.GetDefaultAgents()...) + handshakeAgent := &agents.HandshakeAgent{TLSAgent: connAgents.Get("TLSAgent").(*agents.TLSAgent), SocketAgent: connAgents.Get("SocketAgent").(*agents.SocketAgent)} + connAgents.Add(handshakeAgent) + connAgents.Get("SendingAgent").(*agents.SendingAgent).FrameProducer = connAgents.GetFrameProducingAgents() + + handshakeStatus := handshakeAgent.HandshakeStatus.RegisterNewChan(10) + + originalPacket := conn.GetInitialPacket() + originalLen := len(originalPacket.Encode(originalPacket.EncodePayload())) + f := originalPacket.GetFirst(qt.CryptoType).(*qt.CryptoFrame) + secondPacket := qt.NewInitialPacket(conn) + secondPacket.AddFrame(qt.CryptoFrame{Offset: f.Length / 2, Length: f.Length - (f.Length / 2), CryptoData:f.CryptoData[f.Length/2:]}) + secondPacket.PadTo(originalLen) + f.CryptoData = f.CryptoData[:f.Length/2] + f.Length /= 2 + originalPacket.PadTo(originalLen) + + conn.DoSendPacket(secondPacket, qt.EncryptionLevelInitial) + <-time.NewTimer(1 * time.Millisecond).C + conn.DoSendPacket(originalPacket, qt.EncryptionLevelInitial) + + select { + case i := <-handshakeStatus: + status := i.(agents.HandshakeStatus) + if !status.Completed { + trace.MarkError(MPCH_TLSHandshakeFailed, status.Error.Error(), status.Packet) + connAgents.StopAll() + return + } else { + defer connAgents.CloseConnection(false, 0, "") + } + case <-conn.ConnectionClosed: + trace.MarkError(MPCH_TLSHandshakeFailed, "connection closed", nil) + connAgents.StopAll() + return + case <-s.Timeout(): + trace.MarkError(MPCH_TLSHandshakeFailed, "handshake timeout", nil) + connAgents.StopAll() + return + } + + connAgents.AddHTTPAgent().SendRequest(preferredPath, "GET", trace.Host, nil) + + <-s.Timeout() + + if !conn.Streams.Get(0).ReadClosed { + trace.ErrorCode = MPCH_RequestFailed + } +} diff --git a/scenarii/scenario.go b/scenarii/scenario.go index bc59893..67e184d 100644 --- a/scenarii/scenario.go +++ b/scenarii/scenario.go @@ -129,5 +129,6 @@ func GetAllScenarii() map[string]Scenario { "server_flow_control": NewServerFlowControlScenario(), "connection_migration_v4_v6": NewConnectionMigrationv4v6Scenario(), "zero_length_cid": NewZeroLengthCID(), + "multi_packet_client_hello": NewMultiPacketClientHello(), } }