forked from quic-go/quic-go
@@ -175,6 +175,7 @@ func (h *publicHeader) GetLength() (protocol.ByteCount, error) {
|
||||
if !h.TruncateConnectionID {
|
||||
length += 8 // 8 bytes for the connection ID
|
||||
}
|
||||
length += protocol.ByteCount(len(h.DiversificationNonce))
|
||||
length += protocol.ByteCount(h.PacketNumberLen)
|
||||
return length, nil
|
||||
}
|
||||
|
||||
@@ -228,6 +228,16 @@ var _ = Describe("Public Header", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(length).To(Equal(protocol.ByteCount(1 + 8 + 2))) // 1 byte public flag, 8 byte connectionID, and packet number
|
||||
})
|
||||
|
||||
It("works with diversification nonce", func() {
|
||||
hdr := publicHeader{
|
||||
DiversificationNonce: []byte("foo"),
|
||||
PacketNumberLen: protocol.PacketNumberLen1,
|
||||
}
|
||||
length, err := hdr.GetLength()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(length).To(Equal(protocol.ByteCount(1 + 8 + 3 + 1)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("packet number length", func() {
|
||||
|
||||
Reference in New Issue
Block a user