ignore post-handshake CRYPTO frames

This commit is contained in:
Marten Seemann 2019-01-26 16:40:35 +08:00
parent 350363a796
commit 2fffad94bc
2 changed files with 12 additions and 2 deletions

View file

@ -37,6 +37,9 @@ func (m *cryptoStreamManager) HandleCryptoFrame(frame *wire.CryptoFrame, encLeve
str = m.initialStream
case protocol.EncryptionHandshake:
str = m.handshakeStream
case protocol.Encryption1RTT:
// TODO(#981): process session tickets
return false, nil
default:
return false, fmt.Errorf("received CRYPTO frame with unexpected encryption level: %s", encLevel)
}

View file

@ -98,8 +98,15 @@ var _ = Describe("Crypto Stream Manager", func() {
Expect(err).To(MatchError(err))
})
It("ignores post-handshake crypto data", func() {
changed, err := csm.HandleCryptoFrame(&wire.CryptoFrame{}, protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
Expect(changed).To(BeFalse())
})
It("errors for unknown encryption levels", func() {
_, err := csm.HandleCryptoFrame(&wire.CryptoFrame{}, protocol.Encryption1RTT)
Expect(err).To(MatchError("received CRYPTO frame with unexpected encryption level: 1-RTT"))
_, err := csm.HandleCryptoFrame(&wire.CryptoFrame{}, 42)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("received CRYPTO frame with unexpected encryption level"))
})
})