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,
keyDerivation: crypto.DeriveAESKeys,
aeadChanged: aeadChanged,
nextPacketType: protocol.PacketTypeClientInitial,
nextPacketType: protocol.PacketTypeInitial,
}, nil
}
@@ -211,9 +211,9 @@ func (h *cryptoSetupTLS) determineNextPacketType() error {
if h.perspective == protocol.PerspectiveServer {
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
h.nextPacketType = protocol.PacketTypeServerStatelessRetry
h.nextPacketType = protocol.PacketTypeRetry
case "ServerStateWaitFinished":
h.nextPacketType = protocol.PacketTypeServerCleartext
h.nextPacketType = protocol.PacketTypeCleartext
default:
// TODO: accept 0-RTT data
return fmt.Errorf("Unexpected handshake state: %s", state)
@@ -222,7 +222,7 @@ func (h *cryptoSetupTLS) determineNextPacketType() error {
}
// client
if state != "ClientStateWaitSH" {
h.nextPacketType = protocol.PacketTypeClientCleartext
h.nextPacketType = protocol.PacketTypeCleartext
}
return nil
}

View File

@@ -99,7 +99,7 @@ var _ = Describe("TLS Crypto Setup", 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() {
@@ -118,14 +118,14 @@ var _ = Describe("TLS Crypto Setup", func() {
cs.tls.(*mockhandshake.MockmintTLS).EXPECT().State().Return(mint.ConnectionState{HandshakeState: "ServerStateStart"})
err := cs.determineNextPacketType()
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() {
cs.tls.(*mockhandshake.MockmintTLS).EXPECT().State().Return(mint.ConnectionState{HandshakeState: "ServerStateWaitFinished"})
err := cs.determineNextPacketType()
Expect(err).ToNot(HaveOccurred())
Expect(cs.GetNextPacketType()).To(Equal(protocol.PacketTypeServerCleartext))
Expect(cs.GetNextPacketType()).To(Equal(protocol.PacketTypeCleartext))
})
})
})