diff --git a/crypto_stream.go b/crypto_stream.go index 7f43a2a2..d399d37d 100644 --- a/crypto_stream.go +++ b/crypto_stream.go @@ -6,6 +6,7 @@ import ( "io" "github.com/lucas-clemente/quic-go/internal/protocol" + "github.com/lucas-clemente/quic-go/internal/qerr" "github.com/lucas-clemente/quic-go/internal/utils" "github.com/lucas-clemente/quic-go/internal/wire" ) @@ -73,7 +74,7 @@ func (s *cryptoStreamImpl) HandleCryptoFrame(f *wire.CryptoFrame) error { if s.finished { if highestOffset > s.highestOffset { // reject crypto data received after this stream was already finished - return errors.New("received crypto data after change of encryption level") + return qerr.Error(qerr.ProtocolViolation, "received crypto data after change of encryption level") } // ignore data with a smaller offset than the highest received // could e.g. be a retransmission diff --git a/crypto_stream_test.go b/crypto_stream_test.go index 834bbd5f..9467f798 100644 --- a/crypto_stream_test.go +++ b/crypto_stream_test.go @@ -119,7 +119,7 @@ var _ = Describe("Crypto Stream", func() { err := str.HandleCryptoFrame(&wire.CryptoFrame{ Data: createHandshakeMessage(5), }) - Expect(err).To(MatchError("received crypto data after change of encryption level")) + Expect(err).To(MatchError("PROTOCOL_VIOLATION: received crypto data after change of encryption level")) }) It("ignores crypto data below the maximum offset received before finishing", func() {