rename the packet types according to recent draft changes

This commit is contained in:
Marten Seemann 2017-11-01 10:15:03 +07:00
parent 49e305f97f
commit 3e6f66da79
5 changed files with 16 additions and 18 deletions

View file

@ -120,7 +120,7 @@ func NewCryptoSetupTLSClient(
nullAEAD: nullAEAD, nullAEAD: nullAEAD,
keyDerivation: crypto.DeriveAESKeys, keyDerivation: crypto.DeriveAESKeys,
aeadChanged: aeadChanged, aeadChanged: aeadChanged,
nextPacketType: protocol.PacketTypeClientInitial, nextPacketType: protocol.PacketTypeInitial,
}, nil }, nil
} }
@ -211,9 +211,9 @@ func (h *cryptoSetupTLS) determineNextPacketType() error {
if h.perspective == protocol.PerspectiveServer { if h.perspective == protocol.PerspectiveServer {
switch state { switch state {
case "ServerStateStart": // if we're still at ServerStateStart when writing the first packet, that means we've come back to that state by sending a HelloRetryRequest case "ServerStateStart": // if we're still at ServerStateStart when writing the first packet, that means we've come back to that state by sending a HelloRetryRequest
h.nextPacketType = protocol.PacketTypeServerStatelessRetry h.nextPacketType = protocol.PacketTypeRetry
case "ServerStateWaitFinished": case "ServerStateWaitFinished":
h.nextPacketType = protocol.PacketTypeServerCleartext h.nextPacketType = protocol.PacketTypeCleartext
default: default:
// TODO: accept 0-RTT data // TODO: accept 0-RTT data
return fmt.Errorf("Unexpected handshake state: %s", state) return fmt.Errorf("Unexpected handshake state: %s", state)
@ -222,7 +222,7 @@ func (h *cryptoSetupTLS) determineNextPacketType() error {
} }
// client // client
if state != "ClientStateWaitSH" { if state != "ClientStateWaitSH" {
h.nextPacketType = protocol.PacketTypeClientCleartext h.nextPacketType = protocol.PacketTypeCleartext
} }
return nil return nil
} }

View file

@ -99,7 +99,7 @@ var _ = Describe("TLS Crypto Setup", func() {
}) })
It("sends a Client Initial first", func() { It("sends a Client Initial first", func() {
Expect(csClient.GetNextPacketType()).To(Equal(protocol.PacketTypeClientInitial)) Expect(csClient.GetNextPacketType()).To(Equal(protocol.PacketTypeInitial))
}) })
It("sends a Client Cleartext after the server sent a Server Hello", func() { It("sends a Client Cleartext after the server sent a Server Hello", func() {
@ -118,14 +118,14 @@ var _ = Describe("TLS Crypto Setup", func() {
cs.tls.(*mockhandshake.MockmintTLS).EXPECT().State().Return(mint.ConnectionState{HandshakeState: "ServerStateStart"}) cs.tls.(*mockhandshake.MockmintTLS).EXPECT().State().Return(mint.ConnectionState{HandshakeState: "ServerStateStart"})
err := cs.determineNextPacketType() err := cs.determineNextPacketType()
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(cs.GetNextPacketType()).To(Equal(protocol.PacketTypeServerStatelessRetry)) Expect(cs.GetNextPacketType()).To(Equal(protocol.PacketTypeRetry))
}) })
It("sends a Server Cleartext packet", func() { It("sends a Server Cleartext packet", func() {
cs.tls.(*mockhandshake.MockmintTLS).EXPECT().State().Return(mint.ConnectionState{HandshakeState: "ServerStateWaitFinished"}) cs.tls.(*mockhandshake.MockmintTLS).EXPECT().State().Return(mint.ConnectionState{HandshakeState: "ServerStateWaitFinished"})
err := cs.determineNextPacketType() err := cs.determineNextPacketType()
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(cs.GetNextPacketType()).To(Equal(protocol.PacketTypeServerCleartext)) Expect(cs.GetNextPacketType()).To(Equal(protocol.PacketTypeCleartext))
}) })
}) })
}) })

View file

@ -27,16 +27,14 @@ type PacketType uint8
const ( const (
// PacketTypeVersionNegotiation is the packet type of a Version Negotiation packet // PacketTypeVersionNegotiation is the packet type of a Version Negotiation packet
PacketTypeVersionNegotiation PacketType = 1 PacketTypeVersionNegotiation PacketType = 1
// PacketTypeClientInitial is the packet type of a Client Initial packet // PacketTypeInitial is the packet type of a Initial packet
PacketTypeClientInitial PacketType = 2 PacketTypeInitial PacketType = 2
// PacketTypeServerStatelessRetry is the packet type of a Server Stateless Retry packet // PacketTypeRetry is the packet type of a Retry packet
PacketTypeServerStatelessRetry PacketType = 3 PacketTypeRetry PacketType = 3
// PacketTypeServerCleartext is the packet type of a Server Cleartext packet // PacketTypeCleartext is the packet type of a Cleartext packet
PacketTypeServerCleartext PacketType = 4 PacketTypeCleartext PacketType = 4
// PacketTypeClientCleartext is the packet type of a Client Cleartext packet
PacketTypeClientCleartext PacketType = 5
// PacketType0RTT is the packet type of a 0-RTT packet // PacketType0RTT is the packet type of a 0-RTT packet
PacketType0RTT PacketType = 6 PacketType0RTT PacketType = 5
) )
// A ConnectionID in QUIC // A ConnectionID in QUIC

View file

@ -279,7 +279,7 @@ func (s *server) handlePacket(pconn net.PacketConn, remoteAddr net.Addr, packet
} }
} }
// send an IETF draft style Version Negotiation Packet, if the client sent an unsupported version with an IETF draft style header // send an IETF draft style Version Negotiation Packet, if the client sent an unsupported version with an IETF draft style header
if hdr.Type == protocol.PacketTypeClientInitial && !protocol.IsSupportedVersion(s.config.Versions, hdr.Version) { if hdr.Type == protocol.PacketTypeInitial && !protocol.IsSupportedVersion(s.config.Versions, hdr.Version) {
_, err := pconn.WriteTo(wire.ComposeVersionNegotiation(hdr.ConnectionID, hdr.PacketNumber, s.config.Versions), remoteAddr) _, err := pconn.WriteTo(wire.ComposeVersionNegotiation(hdr.ConnectionID, hdr.PacketNumber, s.config.Versions), remoteAddr)
return err return err
} }

View file

@ -434,7 +434,7 @@ var _ = Describe("Server", func() {
config.Versions = []protocol.VersionNumber{99} config.Versions = []protocol.VersionNumber{99}
b := &bytes.Buffer{} b := &bytes.Buffer{}
hdr := wire.Header{ hdr := wire.Header{
Type: protocol.PacketTypeClientInitial, Type: protocol.PacketTypeInitial,
IsLongHeader: true, IsLongHeader: true,
ConnectionID: 0x1337, ConnectionID: 0x1337,
PacketNumber: 0x55, PacketNumber: 0x55,