remove the LongHeader field from the wire.Header

This commit is contained in:
Marten Seemann 2022-12-27 12:03:38 +13:00
parent aca052dc7c
commit 86edf7fd4b
23 changed files with 154 additions and 363 deletions

View file

@ -30,7 +30,6 @@ func getVNP(src, dest protocol.ArbitraryLenConnectionID, numVersions int) []byte
func main() {
headers := []wire.Header{
{ // Initial without token
IsLongHeader: true,
SrcConnectionID: protocol.ParseConnectionID(getRandomData(3)),
DestConnectionID: protocol.ParseConnectionID(getRandomData(8)),
Type: protocol.PacketTypeInitial,
@ -38,14 +37,12 @@ func main() {
Version: version,
},
{ // Initial without token, with zero-length src conn id
IsLongHeader: true,
DestConnectionID: protocol.ParseConnectionID(getRandomData(8)),
Type: protocol.PacketTypeInitial,
Length: protocol.ByteCount(rand.Intn(1000)),
Version: version,
},
{ // Initial with Token
IsLongHeader: true,
SrcConnectionID: protocol.ParseConnectionID(getRandomData(10)),
DestConnectionID: protocol.ParseConnectionID(getRandomData(19)),
Type: protocol.PacketTypeInitial,
@ -54,7 +51,6 @@ func main() {
Token: getRandomData(25),
},
{ // Handshake packet
IsLongHeader: true,
SrcConnectionID: protocol.ParseConnectionID(getRandomData(5)),
DestConnectionID: protocol.ParseConnectionID(getRandomData(10)),
Type: protocol.PacketTypeHandshake,
@ -62,14 +58,12 @@ func main() {
Version: version,
},
{ // Handshake packet, with zero-length src conn id
IsLongHeader: true,
DestConnectionID: protocol.ParseConnectionID(getRandomData(12)),
Type: protocol.PacketTypeHandshake,
Length: protocol.ByteCount(rand.Intn(1000)),
Version: version,
},
{ // 0-RTT packet
IsLongHeader: true,
SrcConnectionID: protocol.ParseConnectionID(getRandomData(8)),
DestConnectionID: protocol.ParseConnectionID(getRandomData(9)),
Type: protocol.PacketType0RTT,
@ -77,7 +71,6 @@ func main() {
Version: version,
},
{ // Retry Packet, with empty orig dest conn id
IsLongHeader: true,
SrcConnectionID: protocol.ParseConnectionID(getRandomData(8)),
DestConnectionID: protocol.ParseConnectionID(getRandomData(9)),
Type: protocol.PacketTypeRetry,

View file

@ -30,8 +30,14 @@ func Fuzz(data []byte) int {
if err != nil {
return 0
}
if !wire.IsLongHeaderPacket(data[0]) {
wire.ParseShortHeader(data, connIDLen)
return 1
}
is0RTTPacket := wire.Is0RTTPacket(data)
hdr, _, _, err := wire.ParsePacket(data, connIDLen)
hdr, _, _, err := wire.ParsePacket(data)
if err != nil {
return 0
}
@ -42,11 +48,6 @@ func Fuzz(data []byte) int {
panic("inconsistent 0-RTT packet detection")
}
if !wire.IsLongHeaderPacket(data[0]) {
wire.ParseShortHeader(data, connIDLen)
return 1
}
var extHdr *wire.ExtendedHeader
// Parse the extended header, if this is not a Retry packet.
if hdr.Type == protocol.PacketTypeRetry {
@ -60,7 +61,7 @@ func Fuzz(data []byte) int {
}
// We always use a 2-byte encoding for the Length field in Long Header packets.
// Serializing the header will fail when using a higher value.
if hdr.IsLongHeader && hdr.Length > 16383 {
if hdr.Length > 16383 {
return 1
}
b := &bytes.Buffer{}