Skip to content

Commit

Permalink
draft-24 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiraux committed Nov 29, 2019
1 parent a44a129 commit cdc4e71
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 7 deletions.
10 changes: 5 additions & 5 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scenarii/key_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
71 changes: 71 additions & 0 deletions scenarii/multi_packet_client_hello.go
Original file line number Diff line number Diff line change
@@ -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
}
}
1 change: 1 addition & 0 deletions scenarii/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}

0 comments on commit cdc4e71

Please sign in to comment.