forked from quic-go/quic-go
implement rules for frame types in 0-RTT packets
This commit is contained in:
@@ -106,11 +106,21 @@ func (p *frameParser) isAllowedAtEncLevel(f Frame, encLevel protocol.EncryptionL
|
|||||||
switch f.(type) {
|
switch f.(type) {
|
||||||
case *CryptoFrame, *AckFrame, *ConnectionCloseFrame, *PingFrame:
|
case *CryptoFrame, *AckFrame, *ConnectionCloseFrame, *PingFrame:
|
||||||
return true
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
case protocol.Encryption0RTT:
|
||||||
|
switch f.(type) {
|
||||||
|
case *CryptoFrame, *AckFrame, *ConnectionCloseFrame, *NewTokenFrame, *PathResponseFrame, *RetireConnectionIDFrame:
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
case protocol.Encryption1RTT:
|
case protocol.Encryption1RTT:
|
||||||
return true
|
return true
|
||||||
|
default:
|
||||||
|
panic("unknown encryption level")
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *frameParser) SetAckDelayExponent(exp uint8) {
|
func (p *frameParser) SetAckDelayExponent(exp uint8) {
|
||||||
|
|||||||
@@ -357,6 +357,19 @@ var _ = Describe("Frame parsing", func() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("rejects all frames but ACK, CRYPTO, CONNECTION_CLOSE, NEW_TOKEN, PATH_RESPONSE and RETIRE_CONNECTION_ID in 0-RTT packets", func() {
|
||||||
|
for i, b := range framesSerialized {
|
||||||
|
_, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption0RTT)
|
||||||
|
switch frames[i].(type) {
|
||||||
|
case *AckFrame, *ConnectionCloseFrame, *CryptoFrame, *NewTokenFrame, *PathResponseFrame, *RetireConnectionIDFrame:
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
Expect(err.Error()).To(ContainSubstring("not allowed at encryption level 0-RTT"))
|
||||||
|
default:
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
It("accepts all frame types in 1-RTT packets", func() {
|
It("accepts all frame types in 1-RTT packets", func() {
|
||||||
for _, b := range framesSerialized {
|
for _, b := range framesSerialized {
|
||||||
_, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
|
_, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
|
||||||
|
|||||||
Reference in New Issue
Block a user