mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
replace version number literals with constants to make grepping easier
This commit is contained in:
parent
556bf2fe4b
commit
240946dfde
13 changed files with 75 additions and 67 deletions
|
@ -44,7 +44,7 @@ func DeriveKeysChacha20(version protocol.VersionNumber, forwardSecure bool, shar
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !forwardSecure && version >= protocol.VersionNumber(33) {
|
if !forwardSecure && version >= protocol.Version33 {
|
||||||
if err := diversify(myKey, myIV, divNonce); err != nil {
|
if err := diversify(myKey, myIV, divNonce); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
var _ = Describe("KeyDerivation", func() {
|
var _ = Describe("KeyDerivation", func() {
|
||||||
It("derives non-fs keys", func() {
|
It("derives non-fs keys", func() {
|
||||||
aead, err := DeriveKeysChacha20(
|
aead, err := DeriveKeysChacha20(
|
||||||
32,
|
protocol.Version32,
|
||||||
false,
|
false,
|
||||||
[]byte("0123456789012345678901"),
|
[]byte("0123456789012345678901"),
|
||||||
[]byte("nonce"),
|
[]byte("nonce"),
|
||||||
|
@ -29,7 +29,7 @@ var _ = Describe("KeyDerivation", func() {
|
||||||
|
|
||||||
It("derives fs keys", func() {
|
It("derives fs keys", func() {
|
||||||
aead, err := DeriveKeysChacha20(
|
aead, err := DeriveKeysChacha20(
|
||||||
32,
|
protocol.Version32,
|
||||||
true,
|
true,
|
||||||
[]byte("0123456789012345678901"),
|
[]byte("0123456789012345678901"),
|
||||||
[]byte("nonce"),
|
[]byte("nonce"),
|
||||||
|
@ -48,7 +48,7 @@ var _ = Describe("KeyDerivation", func() {
|
||||||
|
|
||||||
It("does not use diversification nonces in FS key derivation", func() {
|
It("does not use diversification nonces in FS key derivation", func() {
|
||||||
aead, err := DeriveKeysChacha20(
|
aead, err := DeriveKeysChacha20(
|
||||||
33,
|
protocol.Version33,
|
||||||
true,
|
true,
|
||||||
[]byte("0123456789012345678901"),
|
[]byte("0123456789012345678901"),
|
||||||
[]byte("nonce"),
|
[]byte("nonce"),
|
||||||
|
@ -67,7 +67,7 @@ var _ = Describe("KeyDerivation", func() {
|
||||||
|
|
||||||
It("uses diversification nonces in initial key derivation", func() {
|
It("uses diversification nonces in initial key derivation", func() {
|
||||||
aead, err := DeriveKeysChacha20(
|
aead, err := DeriveKeysChacha20(
|
||||||
33,
|
protocol.Version33,
|
||||||
false,
|
false,
|
||||||
[]byte("0123456789012345678901"),
|
[]byte("0123456789012345678901"),
|
||||||
[]byte("nonce"),
|
[]byte("nonce"),
|
||||||
|
|
|
@ -106,7 +106,7 @@ func (f *AckFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove once we drop support for <32
|
// TODO: Remove once we drop support for <32
|
||||||
if version < protocol.VersionNumber(32) {
|
if version < protocol.Version32 {
|
||||||
b.WriteByte(0)
|
b.WriteByte(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ func ParseAckFrame(r *bytes.Reader, version protocol.VersionNumber) (*AckFrame,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove once we drop support for versions <32
|
// TODO: Remove once we drop support for versions <32
|
||||||
if version < protocol.VersionNumber(32) {
|
if version < protocol.Version32 {
|
||||||
_, err = r.ReadByte()
|
_, err = r.ReadByte()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -14,7 +14,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
Context("when parsing", func() {
|
Context("when parsing", func() {
|
||||||
It("accepts sample frame", func() {
|
It("accepts sample frame", func() {
|
||||||
b := bytes.NewReader([]byte{0x40, 0xA4, 0x03, 0x23, 0x45, 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC})
|
b := bytes.NewReader([]byte{0x40, 0xA4, 0x03, 0x23, 0x45, 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC})
|
||||||
frame, err := ParseAckFrame(b, 32)
|
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.Entropy).To(Equal(byte(0xA4)))
|
Expect(frame.Entropy).To(Equal(byte(0xA4)))
|
||||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0x03)))
|
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0x03)))
|
||||||
|
@ -25,7 +25,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
|
|
||||||
It("parses a frame with a 48 bit packet number", func() {
|
It("parses a frame with a 48 bit packet number", func() {
|
||||||
b := bytes.NewReader([]byte{0x4C, 0xA4, 0x37, 0x13, 0xAD, 0xFB, 0xCA, 0xDE, 0x23, 0x45, 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC})
|
b := bytes.NewReader([]byte{0x4C, 0xA4, 0x37, 0x13, 0xAD, 0xFB, 0xCA, 0xDE, 0x23, 0x45, 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC})
|
||||||
frame, err := ParseAckFrame(b, 32)
|
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0xDECAFBAD1337)))
|
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0xDECAFBAD1337)))
|
||||||
Expect(b.Len()).To(Equal(0))
|
Expect(b.Len()).To(Equal(0))
|
||||||
|
@ -33,14 +33,14 @@ var _ = Describe("AckFrame", func() {
|
||||||
|
|
||||||
It("completely parses a frame with multiple timestamps", func() {
|
It("completely parses a frame with multiple timestamps", func() {
|
||||||
b := bytes.NewReader([]byte{0x40, 0xA4, 0x03, 0x23, 0x45, 0x03, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0x12, 0x34, 0x56, 0x78, 0x90, 0xA0})
|
b := bytes.NewReader([]byte{0x40, 0xA4, 0x03, 0x23, 0x45, 0x03, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0x12, 0x34, 0x56, 0x78, 0x90, 0xA0})
|
||||||
_, err := ParseAckFrame(b, 32)
|
_, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Len()).To(Equal(0))
|
Expect(b.Len()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("parses a frame containing one NACK range", func() {
|
It("parses a frame containing one NACK range", func() {
|
||||||
b := bytes.NewReader([]byte{0x60, 0x8, 0x3, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x1, 0x1})
|
b := bytes.NewReader([]byte{0x60, 0x8, 0x3, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x1, 0x1})
|
||||||
frame, err := ParseAckFrame(b, 32)
|
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.HasNACK()).To(Equal(true))
|
Expect(frame.HasNACK()).To(Equal(true))
|
||||||
Expect(frame.NackRanges).To(HaveLen(1))
|
Expect(frame.NackRanges).To(HaveLen(1))
|
||||||
|
@ -51,7 +51,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
|
|
||||||
It("support version 31", func() {
|
It("support version 31", func() {
|
||||||
b := bytes.NewReader([]byte{0x60, 0x8, 0x3, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0})
|
b := bytes.NewReader([]byte{0x60, 0x8, 0x3, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0})
|
||||||
frame, err := ParseAckFrame(b, 31)
|
frame, err := ParseAckFrame(b, protocol.Version31)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.HasNACK()).To(Equal(true))
|
Expect(frame.HasNACK()).To(Equal(true))
|
||||||
Expect(frame.NackRanges).To(HaveLen(1))
|
Expect(frame.NackRanges).To(HaveLen(1))
|
||||||
|
@ -63,7 +63,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
It("parses a frame containing one NACK range with a 48 bit LargestObserved and missingPacketSequenceNumberDelta", func() {
|
It("parses a frame containing one NACK range with a 48 bit LargestObserved and missingPacketSequenceNumberDelta", func() {
|
||||||
var rangeLength uint64 = 3
|
var rangeLength uint64 = 3
|
||||||
b := bytes.NewReader([]byte{(0x4C | 0x20 | 0x03), 0x08, 0x37, 0x13, 0xAD, 0xFB, 0xCA, 0xDE, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE, byte(rangeLength)})
|
b := bytes.NewReader([]byte{(0x4C | 0x20 | 0x03), 0x08, 0x37, 0x13, 0xAD, 0xFB, 0xCA, 0xDE, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE, byte(rangeLength)})
|
||||||
frame, err := ParseAckFrame(b, 32)
|
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0xDECAFBAD1337)))
|
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0xDECAFBAD1337)))
|
||||||
Expect(frame.HasNACK()).To(Equal(true))
|
Expect(frame.HasNACK()).To(Equal(true))
|
||||||
|
@ -75,7 +75,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
It("parses a frame containing multiple NACK ranges", func() {
|
It("parses a frame containing multiple NACK ranges", func() {
|
||||||
// sent packets 1, 3, 7, 15
|
// sent packets 1, 3, 7, 15
|
||||||
b := bytes.NewReader([]byte{0x60, 0x2, 0xf, 0xb8, 0x1, 0x1, 0x0, 0xe5, 0x58, 0x4, 0x0, 0x3, 0x1, 0x6, 0x1, 0x2, 0x1, 0x0})
|
b := bytes.NewReader([]byte{0x60, 0x2, 0xf, 0xb8, 0x1, 0x1, 0x0, 0xe5, 0x58, 0x4, 0x0, 0x3, 0x1, 0x6, 0x1, 0x2, 0x1, 0x0})
|
||||||
frame, err := ParseAckFrame(b, 32)
|
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.HasNACK()).To(Equal(true))
|
Expect(frame.HasNACK()).To(Equal(true))
|
||||||
Expect(frame.NackRanges).To(HaveLen(3))
|
Expect(frame.NackRanges).To(HaveLen(3))
|
||||||
|
@ -88,13 +88,13 @@ var _ = Describe("AckFrame", func() {
|
||||||
It("rejects a packet with an invalid NACK range", func() {
|
It("rejects a packet with an invalid NACK range", func() {
|
||||||
// LargestObserved: 8, NackRange: (8-7-3) to (8-7)
|
// LargestObserved: 8, NackRange: (8-7-3) to (8-7)
|
||||||
b := bytes.NewReader([]byte{0x60, 0x8, 0x7, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x7, 0x3})
|
b := bytes.NewReader([]byte{0x60, 0x8, 0x7, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x7, 0x3})
|
||||||
_, err := ParseAckFrame(b, 32)
|
_, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).To(MatchError(errInvalidNackRanges))
|
Expect(err).To(MatchError(errInvalidNackRanges))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("accepts truncated acks", func() {
|
It("accepts truncated acks", func() {
|
||||||
b := bytes.NewReader([]byte{0x50, 0xA4, 0x03, 0x23, 0x45})
|
b := bytes.NewReader([]byte{0x50, 0xA4, 0x03, 0x23, 0x45})
|
||||||
frame, err := ParseAckFrame(b, 32)
|
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.Truncated).To(BeTrue())
|
Expect(frame.Truncated).To(BeTrue())
|
||||||
Expect(b.Len()).To(BeZero())
|
Expect(b.Len()).To(BeZero())
|
||||||
|
@ -102,7 +102,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
|
|
||||||
It("parses a frame with the largest observed missing", func() {
|
It("parses a frame with the largest observed missing", func() {
|
||||||
b := bytes.NewReader([]byte{0x60, 0x2, 0xf, 0xb8, 0x1, 0x1, 0x0, 0xe5, 0x58, 0x4, 0x0, 0x1, 0x0, 0x0})
|
b := bytes.NewReader([]byte{0x60, 0x2, 0xf, 0xb8, 0x1, 0x1, 0x0, 0xe5, 0x58, 0x4, 0x0, 0x1, 0x0, 0x0})
|
||||||
frame, err := ParseAckFrame(b, 32)
|
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.HasNACK()).To(Equal(true))
|
Expect(frame.HasNACK()).To(Equal(true))
|
||||||
Expect(frame.NackRanges).To(HaveLen(1))
|
Expect(frame.NackRanges).To(HaveLen(1))
|
||||||
|
@ -113,7 +113,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
Context("contiguous NACK ranges", func() {
|
Context("contiguous NACK ranges", func() {
|
||||||
It("parses a frame with a contiguous NACK range spanning two fields", func() {
|
It("parses a frame with a contiguous NACK range spanning two fields", func() {
|
||||||
b := bytes.NewReader([]byte{0x64, 0x8, 0x2E, 0x01, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x2b, 0x0, 0xff})
|
b := bytes.NewReader([]byte{0x64, 0x8, 0x2E, 0x01, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x2b, 0x0, 0xff})
|
||||||
frame, err := ParseAckFrame(b, 32)
|
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(302)))
|
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(302)))
|
||||||
Expect(frame.NackRanges).To(HaveLen(1))
|
Expect(frame.NackRanges).To(HaveLen(1))
|
||||||
|
@ -122,7 +122,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
|
|
||||||
It("parses a frame with a contiguous NACK range spanning more than two fields", func() {
|
It("parses a frame with a contiguous NACK range spanning more than two fields", func() {
|
||||||
b := bytes.NewReader([]byte{0x64, 0x8, 0x16, 0x05, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x6, 0x1, 0x13, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff})
|
b := bytes.NewReader([]byte{0x64, 0x8, 0x16, 0x05, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x6, 0x1, 0x13, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff})
|
||||||
frame, err := ParseAckFrame(b, 32)
|
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(1302)))
|
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(1302)))
|
||||||
Expect(frame.NackRanges).To(HaveLen(1))
|
Expect(frame.NackRanges).To(HaveLen(1))
|
||||||
|
@ -131,7 +131,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
|
|
||||||
It("parses a frame with two contiguous NACK ranges", func() {
|
It("parses a frame with two contiguous NACK ranges", func() {
|
||||||
b := bytes.NewReader([]byte{0x64, 0x8, 0x23, 0x03, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x4, 0x1, 0x8f, 0x0, 0xff, 0x1, 0x8f, 0x0, 0xff})
|
b := bytes.NewReader([]byte{0x64, 0x8, 0x23, 0x03, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x4, 0x1, 0x8f, 0x0, 0xff, 0x1, 0x8f, 0x0, 0xff})
|
||||||
frame, err := ParseAckFrame(b, 32)
|
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(803)))
|
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(803)))
|
||||||
Expect(frame.NackRanges).To(HaveLen(2))
|
Expect(frame.NackRanges).To(HaveLen(2))
|
||||||
|
@ -142,7 +142,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
It("rejects a frame with an invalid NACK range", func() {
|
It("rejects a frame with an invalid NACK range", func() {
|
||||||
// LargestObserved: 280, but NACK range is 301 packets long
|
// LargestObserved: 280, but NACK range is 301 packets long
|
||||||
b := bytes.NewReader([]byte{0x64, 0x8, 0x18, 0x01, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x2b, 0x0, 0xff})
|
b := bytes.NewReader([]byte{0x64, 0x8, 0x18, 0x01, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x2b, 0x0, 0xff})
|
||||||
_, err := ParseAckFrame(b, 32)
|
_, err := ParseAckFrame(b, protocol.Version32)
|
||||||
Expect(err).To(MatchError(errInvalidNackRanges))
|
Expect(err).To(MatchError(errInvalidNackRanges))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -267,7 +267,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
Entropy: 2,
|
Entropy: 2,
|
||||||
LargestObserved: 1,
|
LargestObserved: 1,
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
// check all values except the DelayTime
|
// check all values except the DelayTime
|
||||||
Expect(b.Bytes()[0:3]).To(Equal([]byte{0x40, 0x02, 0x01}))
|
Expect(b.Bytes()[0:3]).To(Equal([]byte{0x40, 0x02, 0x01}))
|
||||||
|
@ -279,7 +279,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 5,
|
LargestObserved: 5,
|
||||||
PacketReceivedTime: time.Now().Add(-750 * time.Millisecond),
|
PacketReceivedTime: time.Now().Add(-750 * time.Millisecond),
|
||||||
}
|
}
|
||||||
frame.Write(b, 32)
|
frame.Write(b, protocol.Version32)
|
||||||
Expect(frame.DelayTime).To(BeNumerically("~", 750*time.Millisecond, 10*time.Millisecond))
|
Expect(frame.DelayTime).To(BeNumerically("~", 750*time.Millisecond, 10*time.Millisecond))
|
||||||
delayTime := frame.DelayTime
|
delayTime := frame.DelayTime
|
||||||
var b2 bytes.Buffer
|
var b2 bytes.Buffer
|
||||||
|
@ -293,7 +293,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 4,
|
LargestObserved: 4,
|
||||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
missingPacketBytes := b.Bytes()[b.Len()-8:]
|
missingPacketBytes := b.Bytes()[b.Len()-8:]
|
||||||
Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges
|
Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges
|
||||||
|
@ -309,7 +309,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 4,
|
LargestObserved: 4,
|
||||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 31)
|
err := frame.Write(b, protocol.Version31)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
missingPacketBytes := b.Bytes()[b.Len()-9:]
|
missingPacketBytes := b.Bytes()[b.Len()-9:]
|
||||||
Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges
|
Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges
|
||||||
|
@ -328,7 +328,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 7,
|
LargestObserved: 7,
|
||||||
NackRanges: []NackRange{nackRange1, nackRange2},
|
NackRanges: []NackRange{nackRange1, nackRange2},
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
|
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
|
||||||
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
|
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
|
||||||
|
@ -349,7 +349,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 258,
|
LargestObserved: 258,
|
||||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 257}},
|
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 257}},
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
missingPacketBytes := b.Bytes()[b.Len()-(1+7):]
|
missingPacketBytes := b.Bytes()[b.Len()-(1+7):]
|
||||||
Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges
|
Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges
|
||||||
|
@ -363,7 +363,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 302,
|
LargestObserved: 302,
|
||||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 301}},
|
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 301}},
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
|
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
|
||||||
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
|
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
|
||||||
|
@ -379,7 +379,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 259,
|
LargestObserved: 259,
|
||||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 258}},
|
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 258}},
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
|
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
|
||||||
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
|
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
|
||||||
|
@ -395,7 +395,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 603,
|
LargestObserved: 603,
|
||||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 601}},
|
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 601}},
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
missingPacketBytes := b.Bytes()[b.Len()-(1+3*7):]
|
missingPacketBytes := b.Bytes()[b.Len()-(1+3*7):]
|
||||||
Expect(missingPacketBytes[0]).To(Equal(uint8(3))) // numRanges
|
Expect(missingPacketBytes[0]).To(Equal(uint8(3))) // numRanges
|
||||||
|
@ -415,7 +415,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 655,
|
LargestObserved: 655,
|
||||||
NackRanges: []NackRange{nackRange2, nackRange1},
|
NackRanges: []NackRange{nackRange2, nackRange1},
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
missingPacketBytes := b.Bytes()[b.Len()-(1+4*7):]
|
missingPacketBytes := b.Bytes()[b.Len()-(1+4*7):]
|
||||||
Expect(missingPacketBytes[0]).To(Equal(uint8(4))) // numRanges
|
Expect(missingPacketBytes[0]).To(Equal(uint8(4))) // numRanges
|
||||||
|
@ -434,7 +434,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
frame := AckFrame{
|
frame := AckFrame{
|
||||||
LargestObserved: 7,
|
LargestObserved: 7,
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x40)))
|
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x40)))
|
||||||
Expect(b.Bytes()[2]).To(Equal(uint8(7)))
|
Expect(b.Bytes()[2]).To(Equal(uint8(7)))
|
||||||
|
@ -444,7 +444,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
frame := AckFrame{
|
frame := AckFrame{
|
||||||
LargestObserved: 0x1337,
|
LargestObserved: 0x1337,
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x44)))
|
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x44)))
|
||||||
Expect(b.Bytes()[2:4]).To(Equal([]byte{0x37, 0x13}))
|
Expect(b.Bytes()[2:4]).To(Equal([]byte{0x37, 0x13}))
|
||||||
|
@ -454,7 +454,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
frame := AckFrame{
|
frame := AckFrame{
|
||||||
LargestObserved: 0xDECAFBAD,
|
LargestObserved: 0xDECAFBAD,
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x48)))
|
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x48)))
|
||||||
Expect(b.Bytes()[2:6]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE}))
|
Expect(b.Bytes()[2:6]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE}))
|
||||||
|
@ -464,7 +464,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
frame := AckFrame{
|
frame := AckFrame{
|
||||||
LargestObserved: 0xDEADBEEFCAFE,
|
LargestObserved: 0xDEADBEEFCAFE,
|
||||||
}
|
}
|
||||||
err := frame.Write(b, 32)
|
err := frame.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x4C)))
|
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x4C)))
|
||||||
Expect(b.Bytes()[2:8]).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE}))
|
Expect(b.Bytes()[2:8]).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE}))
|
||||||
|
@ -497,7 +497,7 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 4,
|
LargestObserved: 4,
|
||||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
||||||
}
|
}
|
||||||
err := f.Write(b, 31)
|
err := f.Write(b, protocol.Version31)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len())))
|
Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len())))
|
||||||
})
|
})
|
||||||
|
@ -515,9 +515,9 @@ var _ = Describe("AckFrame", func() {
|
||||||
Entropy: 0xDE,
|
Entropy: 0xDE,
|
||||||
LargestObserved: 6789,
|
LargestObserved: 6789,
|
||||||
}
|
}
|
||||||
err := frameOrig.Write(b, 32)
|
err := frameOrig.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
frame, err := ParseAckFrame(bytes.NewReader(b.Bytes()), 32)
|
frame, err := ParseAckFrame(bytes.NewReader(b.Bytes()), protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.Entropy).To(Equal(frameOrig.Entropy))
|
Expect(frame.Entropy).To(Equal(frameOrig.Entropy))
|
||||||
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
|
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
|
||||||
|
@ -533,10 +533,10 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 15,
|
LargestObserved: 15,
|
||||||
NackRanges: nackRanges,
|
NackRanges: nackRanges,
|
||||||
}
|
}
|
||||||
err := frameOrig.Write(b, 32)
|
err := frameOrig.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
r := bytes.NewReader(b.Bytes())
|
r := bytes.NewReader(b.Bytes())
|
||||||
frame, err := ParseAckFrame(r, 32)
|
frame, err := ParseAckFrame(r, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
|
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
|
||||||
Expect(frame.NackRanges).To(HaveLen(len(frameOrig.NackRanges)))
|
Expect(frame.NackRanges).To(HaveLen(len(frameOrig.NackRanges)))
|
||||||
|
@ -553,10 +553,10 @@ var _ = Describe("AckFrame", func() {
|
||||||
LargestObserved: 1600,
|
LargestObserved: 1600,
|
||||||
NackRanges: nackRanges,
|
NackRanges: nackRanges,
|
||||||
}
|
}
|
||||||
err := frameOrig.Write(b, 32)
|
err := frameOrig.Write(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
r := bytes.NewReader(b.Bytes())
|
r := bytes.NewReader(b.Bytes())
|
||||||
frame, err := ParseAckFrame(r, 32)
|
frame, err := ParseAckFrame(r, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
|
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
|
||||||
Expect(frame.NackRanges).To(HaveLen(len(frameOrig.NackRanges)))
|
Expect(frame.NackRanges).To(HaveLen(len(frameOrig.NackRanges)))
|
||||||
|
|
|
@ -198,7 +198,7 @@ func (h *CryptoSetup) handleInchoateCHLO(sni string, data []byte, cryptoData map
|
||||||
}
|
}
|
||||||
|
|
||||||
var chloOrNil []byte
|
var chloOrNil []byte
|
||||||
if h.version > protocol.VersionNumber(30) {
|
if h.version > protocol.Version30 {
|
||||||
chloOrNil = data
|
chloOrNil = data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ func (h *CryptoSetup) handleCHLO(sni string, data []byte, cryptoData map[Tag][]b
|
||||||
|
|
||||||
// DiversificationNonce returns a diversification nonce if required in the next packet to be Seal'ed. See LockForSealing()!
|
// DiversificationNonce returns a diversification nonce if required in the next packet to be Seal'ed. See LockForSealing()!
|
||||||
func (h *CryptoSetup) DiversificationNonce() []byte {
|
func (h *CryptoSetup) DiversificationNonce() []byte {
|
||||||
if h.version < protocol.VersionNumber(33) {
|
if h.version < protocol.Version33 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if h.receivedForwardSecurePacket || h.secureAEAD == nil {
|
if h.receivedForwardSecurePacket || h.secureAEAD == nil {
|
||||||
|
|
|
@ -171,7 +171,7 @@ var _ = Describe("Crypto setup", func() {
|
||||||
|
|
||||||
Context("diversification nonce", func() {
|
Context("diversification nonce", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
cs.version = 33
|
cs.version = protocol.Version33
|
||||||
cs.secureAEAD = &mockAEAD{}
|
cs.secureAEAD = &mockAEAD{}
|
||||||
cs.receivedForwardSecurePacket = false
|
cs.receivedForwardSecurePacket = false
|
||||||
})
|
})
|
||||||
|
@ -181,7 +181,7 @@ var _ = Describe("Crypto setup", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("does not return nonce for version < 33", func() {
|
It("does not return nonce for version < 33", func() {
|
||||||
cs.version = 32
|
cs.version = protocol.Version32
|
||||||
Expect(cs.DiversificationNonce()).To(BeEmpty())
|
Expect(cs.DiversificationNonce()).To(BeEmpty())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ var _ = Describe("Crypto setup", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("generates REJ messages for version 30", func() {
|
It("generates REJ messages for version 30", func() {
|
||||||
cs.version = protocol.VersionNumber(30)
|
cs.version = protocol.Version30
|
||||||
_, err := cs.handleInchoateCHLO("", sampleCHLO, nil)
|
_, err := cs.handleInchoateCHLO("", sampleCHLO, nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(signer.gotCHLO).To(BeFalse())
|
Expect(signer.gotCHLO).To(BeFalse())
|
||||||
|
|
|
@ -135,7 +135,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
It("packs many control frames into 1 packets", func() {
|
It("packs many control frames into 1 packets", func() {
|
||||||
f := &frames.AckFrame{LargestObserved: 1}
|
f := &frames.AckFrame{LargestObserved: 1}
|
||||||
b := &bytes.Buffer{}
|
b := &bytes.Buffer{}
|
||||||
f.Write(b, 32)
|
f.Write(b, protocol.Version32)
|
||||||
maxFramesPerPacket := int(protocol.MaxFrameAndPublicHeaderSize-publicHeaderLen) / b.Len()
|
maxFramesPerPacket := int(protocol.MaxFrameAndPublicHeaderSize-publicHeaderLen) / b.Len()
|
||||||
var controlFrames []frames.Frame
|
var controlFrames []frames.Frame
|
||||||
for i := 0; i < maxFramesPerPacket; i++ {
|
for i := 0; i < maxFramesPerPacket; i++ {
|
||||||
|
|
|
@ -63,7 +63,7 @@ var _ = Describe("Packet unpacker", func() {
|
||||||
LargestObserved: 0x13,
|
LargestObserved: 0x13,
|
||||||
Entropy: 0x37,
|
Entropy: 0x37,
|
||||||
}
|
}
|
||||||
err := f.Write(buf, 32)
|
err := f.Write(buf, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
setReader(buf.Bytes())
|
setReader(buf.Bytes())
|
||||||
packet, err := unpacker.Unpack(hdrBin, hdr, r)
|
packet, err := unpacker.Unpack(hdrBin, hdr, r)
|
||||||
|
|
|
@ -9,9 +9,17 @@ import (
|
||||||
// VersionNumber is a version number as int
|
// VersionNumber is a version number as int
|
||||||
type VersionNumber int
|
type VersionNumber int
|
||||||
|
|
||||||
|
// The version numbers, making grepping easier
|
||||||
|
const (
|
||||||
|
Version30 VersionNumber = 30 + iota
|
||||||
|
Version31
|
||||||
|
Version32
|
||||||
|
Version33
|
||||||
|
)
|
||||||
|
|
||||||
// SupportedVersions lists the versions that the server supports
|
// SupportedVersions lists the versions that the server supports
|
||||||
var SupportedVersions = []VersionNumber{
|
var SupportedVersions = []VersionNumber{
|
||||||
30, 31, 32, 33,
|
Version30, Version31, Version32, Version33,
|
||||||
}
|
}
|
||||||
|
|
||||||
// SupportedVersionsAsTags is needed for the SHLO crypto message
|
// SupportedVersionsAsTags is needed for the SHLO crypto message
|
||||||
|
|
|
@ -10,12 +10,12 @@ import (
|
||||||
var _ = Describe("Version", func() {
|
var _ = Describe("Version", func() {
|
||||||
It("converts tags to numbers", func() {
|
It("converts tags to numbers", func() {
|
||||||
Expect(protocol.VersionTagToNumber('Q' + '1'<<8 + '2'<<16 + '3'<<24)).To(Equal(protocol.VersionNumber(123)))
|
Expect(protocol.VersionTagToNumber('Q' + '1'<<8 + '2'<<16 + '3'<<24)).To(Equal(protocol.VersionNumber(123)))
|
||||||
Expect(protocol.VersionTagToNumber('Q' + '0'<<8 + '3'<<16 + '0'<<24)).To(Equal(protocol.VersionNumber(30)))
|
Expect(protocol.VersionTagToNumber('Q' + '0'<<8 + '3'<<16 + '0'<<24)).To(Equal(protocol.Version30))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("converts number to tag", func() {
|
It("converts number to tag", func() {
|
||||||
Expect(protocol.VersionNumberToTag(protocol.VersionNumber(123))).To(Equal(uint32('Q' + '1'<<8 + '2'<<16 + '3'<<24)))
|
Expect(protocol.VersionNumberToTag(protocol.VersionNumber(123))).To(Equal(uint32('Q' + '1'<<8 + '2'<<16 + '3'<<24)))
|
||||||
Expect(protocol.VersionNumberToTag(protocol.VersionNumber(30))).To(Equal(uint32('Q' + '0'<<8 + '3'<<16 + '0'<<24)))
|
Expect(protocol.VersionNumberToTag(protocol.Version30)).To(Equal(uint32('Q' + '0'<<8 + '3'<<16 + '0'<<24)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("has proper tag list", func() {
|
It("has proper tag list", func() {
|
||||||
|
|
|
@ -45,7 +45,7 @@ func (h *publicHeader) WritePublicHeader(b *bytes.Buffer, version protocol.Versi
|
||||||
publicFlagByte |= 0x02
|
publicFlagByte |= 0x02
|
||||||
}
|
}
|
||||||
if !h.TruncateConnectionID {
|
if !h.TruncateConnectionID {
|
||||||
if version < protocol.VersionNumber(33) {
|
if version < protocol.Version33 {
|
||||||
publicFlagByte |= 0x0c
|
publicFlagByte |= 0x0c
|
||||||
} else {
|
} else {
|
||||||
publicFlagByte |= 0x08
|
publicFlagByte |= 0x08
|
||||||
|
|
|
@ -17,7 +17,7 @@ var _ = Describe("Public Header", func() {
|
||||||
Expect(hdr.VersionFlag).To(BeTrue())
|
Expect(hdr.VersionFlag).To(BeTrue())
|
||||||
Expect(hdr.ResetFlag).To(BeFalse())
|
Expect(hdr.ResetFlag).To(BeFalse())
|
||||||
Expect(hdr.ConnectionID).To(Equal(protocol.ConnectionID(0x4cfa9f9b668619f6)))
|
Expect(hdr.ConnectionID).To(Equal(protocol.ConnectionID(0x4cfa9f9b668619f6)))
|
||||||
Expect(hdr.VersionNumber).To(Equal(protocol.VersionNumber(30)))
|
Expect(hdr.VersionNumber).To(Equal(protocol.Version30))
|
||||||
Expect(hdr.PacketNumber).To(Equal(protocol.PacketNumber(1)))
|
Expect(hdr.PacketNumber).To(Equal(protocol.PacketNumber(1)))
|
||||||
Expect(b.Len()).To(BeZero())
|
Expect(b.Len()).To(BeZero())
|
||||||
})
|
})
|
||||||
|
@ -84,7 +84,7 @@ var _ = Describe("Public Header", func() {
|
||||||
PacketNumber: 2,
|
PacketNumber: 2,
|
||||||
PacketNumberLen: protocol.PacketNumberLen6,
|
PacketNumberLen: protocol.PacketNumberLen6,
|
||||||
}
|
}
|
||||||
hdr.WritePublicHeader(b, protocol.VersionNumber(32))
|
hdr.WritePublicHeader(b, protocol.Version32)
|
||||||
Expect(b.Bytes()).To(Equal([]byte{0x38 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 2, 0, 0, 0, 0, 0}))
|
Expect(b.Bytes()).To(Equal([]byte{0x38 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 2, 0, 0, 0, 0, 0}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ var _ = Describe("Public Header", func() {
|
||||||
PacketNumber: 2,
|
PacketNumber: 2,
|
||||||
PacketNumberLen: protocol.PacketNumberLen6,
|
PacketNumberLen: protocol.PacketNumberLen6,
|
||||||
}
|
}
|
||||||
hdr.WritePublicHeader(b, protocol.VersionNumber(32))
|
hdr.WritePublicHeader(b, protocol.Version32)
|
||||||
// must be the first assertion
|
// must be the first assertion
|
||||||
Expect(b.Len()).To(Equal(1 + 8)) // 1 FlagByte + 8 ConnectionID
|
Expect(b.Len()).To(Equal(1 + 8)) // 1 FlagByte + 8 ConnectionID
|
||||||
firstByte, _ := b.ReadByte()
|
firstByte, _ := b.ReadByte()
|
||||||
|
@ -111,7 +111,7 @@ var _ = Describe("Public Header", func() {
|
||||||
PacketNumber: 2,
|
PacketNumber: 2,
|
||||||
PacketNumberLen: protocol.PacketNumberLen6,
|
PacketNumberLen: protocol.PacketNumberLen6,
|
||||||
}
|
}
|
||||||
hdr.WritePublicHeader(b, protocol.VersionNumber(32))
|
hdr.WritePublicHeader(b, protocol.Version32)
|
||||||
// must be the first assertion
|
// must be the first assertion
|
||||||
Expect(b.Len()).To(Equal(1 + 8)) // 1 FlagByte + 8 ConnectionID
|
Expect(b.Len()).To(Equal(1 + 8)) // 1 FlagByte + 8 ConnectionID
|
||||||
firstByte, _ := b.ReadByte()
|
firstByte, _ := b.ReadByte()
|
||||||
|
@ -127,7 +127,7 @@ var _ = Describe("Public Header", func() {
|
||||||
PacketNumber: 2,
|
PacketNumber: 2,
|
||||||
PacketNumberLen: protocol.PacketNumberLen6,
|
PacketNumberLen: protocol.PacketNumberLen6,
|
||||||
}
|
}
|
||||||
err := hdr.WritePublicHeader(b, protocol.VersionNumber(32))
|
err := hdr.WritePublicHeader(b, protocol.Version32)
|
||||||
Expect(err).To(MatchError(errResetAndVersionFlagSet))
|
Expect(err).To(MatchError(errResetAndVersionFlagSet))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ var _ = Describe("Public Header", func() {
|
||||||
PacketNumberLen: protocol.PacketNumberLen6,
|
PacketNumberLen: protocol.PacketNumberLen6,
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
}
|
}
|
||||||
err := hdr.WritePublicHeader(b, protocol.VersionNumber(32))
|
err := hdr.WritePublicHeader(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Bytes()).To(Equal([]byte{0x30, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0}))
|
Expect(b.Bytes()).To(Equal([]byte{0x30, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0}))
|
||||||
})
|
})
|
||||||
|
@ -151,7 +151,7 @@ var _ = Describe("Public Header", func() {
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
PacketNumberLen: protocol.PacketNumberLen1,
|
PacketNumberLen: protocol.PacketNumberLen1,
|
||||||
}
|
}
|
||||||
err := hdr.WritePublicHeader(b, protocol.VersionNumber(33))
|
err := hdr.WritePublicHeader(b, protocol.Version33)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Bytes()).To(Equal([]byte{0x08, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0x01}))
|
Expect(b.Bytes()).To(Equal([]byte{0x08, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0x01}))
|
||||||
})
|
})
|
||||||
|
@ -164,7 +164,7 @@ var _ = Describe("Public Header", func() {
|
||||||
PacketNumberLen: protocol.PacketNumberLen1,
|
PacketNumberLen: protocol.PacketNumberLen1,
|
||||||
DiversificationNonce: bytes.Repeat([]byte{1}, 32),
|
DiversificationNonce: bytes.Repeat([]byte{1}, 32),
|
||||||
}
|
}
|
||||||
err := hdr.WritePublicHeader(b, protocol.VersionNumber(33))
|
err := hdr.WritePublicHeader(b, protocol.Version33)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Bytes()).To(Equal([]byte{
|
Expect(b.Bytes()).To(Equal([]byte{
|
||||||
0x0c, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c,
|
0x0c, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c,
|
||||||
|
@ -247,7 +247,7 @@ var _ = Describe("Public Header", func() {
|
||||||
ConnectionID: 0x4cfa9f9b668619f6,
|
ConnectionID: 0x4cfa9f9b668619f6,
|
||||||
PacketNumber: 0xDECAFBAD,
|
PacketNumber: 0xDECAFBAD,
|
||||||
}
|
}
|
||||||
err := hdr.WritePublicHeader(b, protocol.VersionNumber(32))
|
err := hdr.WritePublicHeader(b, protocol.Version32)
|
||||||
Expect(err).To(MatchError(errPacketNumberLenNotSet))
|
Expect(err).To(MatchError(errPacketNumberLenNotSet))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ var _ = Describe("Public Header", func() {
|
||||||
PacketNumber: 0xDECAFBAD,
|
PacketNumber: 0xDECAFBAD,
|
||||||
PacketNumberLen: protocol.PacketNumberLen1,
|
PacketNumberLen: protocol.PacketNumberLen1,
|
||||||
}
|
}
|
||||||
err := hdr.WritePublicHeader(b, protocol.VersionNumber(32))
|
err := hdr.WritePublicHeader(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Bytes()).To(Equal([]byte{0x08 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD}))
|
Expect(b.Bytes()).To(Equal([]byte{0x08 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD}))
|
||||||
})
|
})
|
||||||
|
@ -270,7 +270,7 @@ var _ = Describe("Public Header", func() {
|
||||||
PacketNumber: 0xDECAFBAD,
|
PacketNumber: 0xDECAFBAD,
|
||||||
PacketNumberLen: protocol.PacketNumberLen2,
|
PacketNumberLen: protocol.PacketNumberLen2,
|
||||||
}
|
}
|
||||||
err := hdr.WritePublicHeader(b, protocol.VersionNumber(32))
|
err := hdr.WritePublicHeader(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Bytes()).To(Equal([]byte{0x18 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD, 0xFB}))
|
Expect(b.Bytes()).To(Equal([]byte{0x18 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD, 0xFB}))
|
||||||
})
|
})
|
||||||
|
@ -282,7 +282,7 @@ var _ = Describe("Public Header", func() {
|
||||||
PacketNumber: 0x13DECAFBAD,
|
PacketNumber: 0x13DECAFBAD,
|
||||||
PacketNumberLen: protocol.PacketNumberLen4,
|
PacketNumberLen: protocol.PacketNumberLen4,
|
||||||
}
|
}
|
||||||
err := hdr.WritePublicHeader(b, protocol.VersionNumber(32))
|
err := hdr.WritePublicHeader(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Bytes()).To(Equal([]byte{0x28 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD, 0xFB, 0xCA, 0xDE}))
|
Expect(b.Bytes()).To(Equal([]byte{0x28 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD, 0xFB, 0xCA, 0xDE}))
|
||||||
})
|
})
|
||||||
|
@ -294,7 +294,7 @@ var _ = Describe("Public Header", func() {
|
||||||
PacketNumber: 0xBE1337DECAFBAD,
|
PacketNumber: 0xBE1337DECAFBAD,
|
||||||
PacketNumberLen: protocol.PacketNumberLen6,
|
PacketNumberLen: protocol.PacketNumberLen6,
|
||||||
}
|
}
|
||||||
err := hdr.WritePublicHeader(b, protocol.VersionNumber(32))
|
err := hdr.WritePublicHeader(b, protocol.Version32)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(b.Bytes()).To(Equal([]byte{0x38 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD, 0xFB, 0xCA, 0xDE, 0x37, 0x13}))
|
Expect(b.Bytes()).To(Equal([]byte{0x38 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD, 0xFB, 0xCA, 0xDE, 0x37, 0x13}))
|
||||||
})
|
})
|
||||||
|
|
|
@ -187,7 +187,7 @@ func composeVersionNegotiation(connectionID protocol.ConnectionID) []byte {
|
||||||
VersionFlag: true,
|
VersionFlag: true,
|
||||||
}
|
}
|
||||||
// TODO: Update version number
|
// TODO: Update version number
|
||||||
err := responsePublicHeader.WritePublicHeader(fullReply, protocol.VersionNumber(32))
|
err := responsePublicHeader.WritePublicHeader(fullReply, protocol.Version32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Errorf("error composing version negotiation packet: %s", err.Error())
|
utils.Errorf("error composing version negotiation packet: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue