use an array instead of a byte slice for Connection IDs

This commit is contained in:
Marten Seemann
2022-08-28 16:05:56 +03:00
parent 9e0f9e62ff
commit 1aced95d41
47 changed files with 530 additions and 487 deletions

View File

@@ -19,13 +19,12 @@ type connIDGenerator struct {
length int
}
func (c *connIDGenerator) GenerateConnectionID() ([]byte, error) {
func (c *connIDGenerator) GenerateConnectionID() (quic.ConnectionID, error) {
b := make([]byte, c.length)
_, err := rand.Read(b)
if err != nil {
if _, err := rand.Read(b); err != nil {
fmt.Fprintf(GinkgoWriter, "generating conn ID failed: %s", err)
}
return b, nil
return protocol.ParseConnectionID(b), nil
}
func (c *connIDGenerator) ConnectionIDLen() int {

View File

@@ -367,7 +367,7 @@ var _ = Describe("MITM test", func() {
}
initialPacketIntercepted = true
fakeSrcConnID := protocol.ConnectionID{0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12}
fakeSrcConnID := protocol.ParseConnectionID([]byte{0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12})
retryPacket := testutils.ComposeRetryPacket(fakeSrcConnID, hdr.SrcConnectionID, hdr.DestConnectionID, []byte("token"), hdr.Version)
_, err = serverUDPConn.WriteTo(retryPacket, clientUDPConn.LocalAddr())

View File

@@ -372,7 +372,7 @@ var _ = Describe("0-RTT", func() {
It("retransmits all 0-RTT data when the server performs a Retry", func() {
var mutex sync.Mutex
var firstConnID, secondConnID protocol.ConnectionID
var firstConnID, secondConnID *protocol.ConnectionID
var firstCounter, secondCounter protocol.ByteCount
tlsConf, clientConf := dialAndReceiveSessionTicket(nil)
@@ -415,13 +415,13 @@ var _ = Describe("0-RTT", func() {
if zeroRTTBytes := countZeroRTTBytes(data); zeroRTTBytes > 0 {
if firstConnID == nil {
firstConnID = connID
firstConnID = &connID
firstCounter += zeroRTTBytes
} else if firstConnID != nil && firstConnID.Equal(connID) {
Expect(secondConnID).To(BeNil())
firstCounter += zeroRTTBytes
} else if secondConnID == nil {
secondConnID = connID
secondConnID = &connID
secondCounter += zeroRTTBytes
} else if secondConnID != nil && secondConnID.Equal(connID) {
secondCounter += zeroRTTBytes