diff --git a/internal/handshake/crypto_setup.go b/internal/handshake/crypto_setup.go index c7f0a887..a075e609 100644 --- a/internal/handshake/crypto_setup.go +++ b/internal/handshake/crypto_setup.go @@ -576,7 +576,7 @@ func (h *cryptoSetup) GetHandshakeSealer() (LongHeaderSealer, error) { if h.initialSealer == nil { return nil, ErrKeysDropped } - return nil, errors.New("CryptoSetup: no sealer with encryption level Handshake") + return nil, ErrKeysNotYetAvailable } return h.handshakeSealer, nil } @@ -586,7 +586,7 @@ func (h *cryptoSetup) Get1RTTSealer() (ShortHeaderSealer, error) { defer h.mutex.Unlock() if !h.has1RTTSealer { - return nil, errors.New("CryptoSetup: no sealer with encryption level 1-RTT") + return nil, ErrKeysNotYetAvailable } return h.aead, nil } @@ -607,7 +607,7 @@ func (h *cryptoSetup) GetHandshakeOpener() (LongHeaderOpener, error) { if h.handshakeOpener == nil { if h.initialOpener != nil { - return nil, ErrOpenerNotYetAvailable + return nil, ErrKeysNotYetAvailable } // if the initial opener is also not available, the keys were already dropped return nil, ErrKeysDropped @@ -620,7 +620,7 @@ func (h *cryptoSetup) Get1RTTOpener() (ShortHeaderOpener, error) { defer h.mutex.Unlock() if !h.has1RTTOpener { - return nil, ErrOpenerNotYetAvailable + return nil, ErrKeysNotYetAvailable } return h.aead, nil } diff --git a/internal/handshake/interface.go b/internal/handshake/interface.go index 25b22b2c..1baee25a 100644 --- a/internal/handshake/interface.go +++ b/internal/handshake/interface.go @@ -11,10 +11,10 @@ import ( ) var ( - // ErrOpenerNotYetAvailable is returned when an opener is requested for an encryption level, + // ErrKeysNotYetAvailable is returned when an opener or a sealer is requested for an encryption level, // but the corresponding opener has not yet been initialized // This can happen when packets arrive out of order. - ErrOpenerNotYetAvailable = errors.New("CryptoSetup: opener at this encryption level not yet available") + ErrKeysNotYetAvailable = errors.New("CryptoSetup: keys at this encryption level not yet available") // ErrKeysDropped is returned when an opener or a sealer is requested for an encryption level, // but the corresponding keys have already been dropped. ErrKeysDropped = errors.New("CryptoSetup: keys were already dropped") diff --git a/packet_unpacker_test.go b/packet_unpacker_test.go index 0f5623e7..9b1eb260 100644 --- a/packet_unpacker_test.go +++ b/packet_unpacker_test.go @@ -85,9 +85,9 @@ var _ = Describe("Packet Unpacker", func() { PacketNumberLen: 2, } hdr, hdrRaw := getHeader(extHdr) - cs.EXPECT().Get1RTTOpener().Return(nil, handshake.ErrOpenerNotYetAvailable) + cs.EXPECT().Get1RTTOpener().Return(nil, handshake.ErrKeysNotYetAvailable) _, err := unpacker.Unpack(hdr, time.Now(), append(hdrRaw, payload...)) - Expect(err).To(MatchError(handshake.ErrOpenerNotYetAvailable)) + Expect(err).To(MatchError(handshake.ErrKeysNotYetAvailable)) }) It("returns the error when unpacking fails", func() { diff --git a/session.go b/session.go index b57723e7..1c9040f3 100644 --- a/session.go +++ b/session.go @@ -677,7 +677,7 @@ func (s *session) handleSinglePacket(p *receivedPacket, hdr *wire.Header) bool / switch err { case handshake.ErrKeysDropped: s.logger.Debugf("Dropping packet because we already dropped the keys.") - case handshake.ErrOpenerNotYetAvailable: + case handshake.ErrKeysNotYetAvailable: // Sealer for this encryption level not yet available. // Try again later. wasQueued = true diff --git a/session_test.go b/session_test.go index fbe5e3c4..8aad69fc 100644 --- a/session_test.go +++ b/session_test.go @@ -749,7 +749,7 @@ var _ = Describe("Session", func() { PacketNumberLen: protocol.PacketNumberLen1, PacketNumber: 1, } - unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, handshake.ErrOpenerNotYetAvailable) + unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, handshake.ErrKeysNotYetAvailable) packet := getPacket(hdr, nil) Expect(sess.handlePacketImpl(packet)).To(BeFalse()) Expect(sess.undecryptablePackets).To(Equal([]*receivedPacket{packet})) @@ -832,7 +832,7 @@ var _ = Describe("Session", func() { hdrLen1, packet1 := getPacketWithLength(srcConnID, 456) hdrLen2, packet2 := getPacketWithLength(srcConnID, 123) gomock.InOrder( - unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, handshake.ErrOpenerNotYetAvailable), + unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, handshake.ErrKeysNotYetAvailable), unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_ *wire.Header, _ time.Time, data []byte) (*unpackedPacket, error) { Expect(data).To(HaveLen(hdrLen2 + 123 - 3)) return &unpackedPacket{