mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
use separate functions per encryption level to get sealers
This commit is contained in:
parent
d4d3f09ee3
commit
c503769bcd
6 changed files with 180 additions and 124 deletions
|
@ -564,41 +564,31 @@ func (h *cryptoSetup) SendAlert(alert uint8) {
|
|||
h.alertChan <- alert
|
||||
}
|
||||
|
||||
func (h *cryptoSetup) GetSealer() (protocol.EncryptionLevel, Sealer) {
|
||||
func (h *cryptoSetup) GetInitialSealer() (Sealer, error) {
|
||||
h.mutex.Lock()
|
||||
defer h.mutex.Unlock()
|
||||
|
||||
if h.sealer != nil {
|
||||
return protocol.Encryption1RTT, h.sealer
|
||||
}
|
||||
if h.handshakeSealer != nil {
|
||||
return protocol.EncryptionHandshake, h.handshakeSealer
|
||||
}
|
||||
return protocol.EncryptionInitial, h.initialSealer
|
||||
return h.initialSealer, nil
|
||||
}
|
||||
|
||||
func (h *cryptoSetup) GetSealerWithEncryptionLevel(level protocol.EncryptionLevel) (Sealer, error) {
|
||||
errNoSealer := fmt.Errorf("CryptoSetup: no sealer with encryption level %s", level.String())
|
||||
|
||||
func (h *cryptoSetup) GetHandshakeSealer() (Sealer, error) {
|
||||
h.mutex.Lock()
|
||||
defer h.mutex.Unlock()
|
||||
|
||||
switch level {
|
||||
case protocol.EncryptionInitial:
|
||||
return h.initialSealer, nil
|
||||
case protocol.EncryptionHandshake:
|
||||
if h.handshakeSealer == nil {
|
||||
return nil, errNoSealer
|
||||
}
|
||||
return h.handshakeSealer, nil
|
||||
case protocol.Encryption1RTT:
|
||||
if h.sealer == nil {
|
||||
return nil, errNoSealer
|
||||
}
|
||||
return h.sealer, nil
|
||||
default:
|
||||
return nil, errNoSealer
|
||||
if h.handshakeSealer == nil {
|
||||
return nil, errors.New("CryptoSetup: no sealer with encryption level Handshake")
|
||||
}
|
||||
return h.handshakeSealer, nil
|
||||
}
|
||||
|
||||
func (h *cryptoSetup) Get1RTTSealer() (Sealer, error) {
|
||||
h.mutex.Lock()
|
||||
defer h.mutex.Unlock()
|
||||
|
||||
if h.sealer == nil {
|
||||
return nil, errors.New("CryptoSetup: no sealer with encryption level 1-RTT")
|
||||
}
|
||||
return h.sealer, nil
|
||||
}
|
||||
|
||||
func (h *cryptoSetup) GetInitialOpener() (Opener, error) {
|
||||
|
|
|
@ -49,6 +49,7 @@ type CryptoSetup interface {
|
|||
GetHandshakeOpener() (Opener, error)
|
||||
Get1RTTOpener() (Opener, error)
|
||||
|
||||
GetSealer() (protocol.EncryptionLevel, Sealer)
|
||||
GetSealerWithEncryptionLevel(protocol.EncryptionLevel) (Sealer, error)
|
||||
GetInitialSealer() (Sealer, error)
|
||||
GetHandshakeSealer() (Sealer, error)
|
||||
Get1RTTSealer() (Sealer, error)
|
||||
}
|
||||
|
|
|
@ -93,6 +93,21 @@ func (mr *MockCryptoSetupMockRecorder) Get1RTTOpener() *gomock.Call {
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get1RTTOpener", reflect.TypeOf((*MockCryptoSetup)(nil).Get1RTTOpener))
|
||||
}
|
||||
|
||||
// Get1RTTSealer mocks base method
|
||||
func (m *MockCryptoSetup) Get1RTTSealer() (handshake.Sealer, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Get1RTTSealer")
|
||||
ret0, _ := ret[0].(handshake.Sealer)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Get1RTTSealer indicates an expected call of Get1RTTSealer
|
||||
func (mr *MockCryptoSetupMockRecorder) Get1RTTSealer() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get1RTTSealer", reflect.TypeOf((*MockCryptoSetup)(nil).Get1RTTSealer))
|
||||
}
|
||||
|
||||
// GetHandshakeOpener mocks base method
|
||||
func (m *MockCryptoSetup) GetHandshakeOpener() (handshake.Opener, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -108,6 +123,21 @@ func (mr *MockCryptoSetupMockRecorder) GetHandshakeOpener() *gomock.Call {
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHandshakeOpener", reflect.TypeOf((*MockCryptoSetup)(nil).GetHandshakeOpener))
|
||||
}
|
||||
|
||||
// GetHandshakeSealer mocks base method
|
||||
func (m *MockCryptoSetup) GetHandshakeSealer() (handshake.Sealer, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetHandshakeSealer")
|
||||
ret0, _ := ret[0].(handshake.Sealer)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetHandshakeSealer indicates an expected call of GetHandshakeSealer
|
||||
func (mr *MockCryptoSetupMockRecorder) GetHandshakeSealer() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHandshakeSealer", reflect.TypeOf((*MockCryptoSetup)(nil).GetHandshakeSealer))
|
||||
}
|
||||
|
||||
// GetInitialOpener mocks base method
|
||||
func (m *MockCryptoSetup) GetInitialOpener() (handshake.Opener, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -123,34 +153,19 @@ func (mr *MockCryptoSetupMockRecorder) GetInitialOpener() *gomock.Call {
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInitialOpener", reflect.TypeOf((*MockCryptoSetup)(nil).GetInitialOpener))
|
||||
}
|
||||
|
||||
// GetSealer mocks base method
|
||||
func (m *MockCryptoSetup) GetSealer() (protocol.EncryptionLevel, handshake.Sealer) {
|
||||
// GetInitialSealer mocks base method
|
||||
func (m *MockCryptoSetup) GetInitialSealer() (handshake.Sealer, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetSealer")
|
||||
ret0, _ := ret[0].(protocol.EncryptionLevel)
|
||||
ret1, _ := ret[1].(handshake.Sealer)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetSealer indicates an expected call of GetSealer
|
||||
func (mr *MockCryptoSetupMockRecorder) GetSealer() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSealer", reflect.TypeOf((*MockCryptoSetup)(nil).GetSealer))
|
||||
}
|
||||
|
||||
// GetSealerWithEncryptionLevel mocks base method
|
||||
func (m *MockCryptoSetup) GetSealerWithEncryptionLevel(arg0 protocol.EncryptionLevel) (handshake.Sealer, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetSealerWithEncryptionLevel", arg0)
|
||||
ret := m.ctrl.Call(m, "GetInitialSealer")
|
||||
ret0, _ := ret[0].(handshake.Sealer)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetSealerWithEncryptionLevel indicates an expected call of GetSealerWithEncryptionLevel
|
||||
func (mr *MockCryptoSetupMockRecorder) GetSealerWithEncryptionLevel(arg0 interface{}) *gomock.Call {
|
||||
// GetInitialSealer indicates an expected call of GetInitialSealer
|
||||
func (mr *MockCryptoSetupMockRecorder) GetInitialSealer() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSealerWithEncryptionLevel", reflect.TypeOf((*MockCryptoSetup)(nil).GetSealerWithEncryptionLevel), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInitialSealer", reflect.TypeOf((*MockCryptoSetup)(nil).GetInitialSealer))
|
||||
}
|
||||
|
||||
// HandleMessage mocks base method
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
handshake "github.com/lucas-clemente/quic-go/internal/handshake"
|
||||
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
)
|
||||
|
||||
// MockSealingManager is a mock of SealingManager interface
|
||||
|
@ -35,32 +34,47 @@ func (m *MockSealingManager) EXPECT() *MockSealingManagerMockRecorder {
|
|||
return m.recorder
|
||||
}
|
||||
|
||||
// GetSealer mocks base method
|
||||
func (m *MockSealingManager) GetSealer() (protocol.EncryptionLevel, handshake.Sealer) {
|
||||
// Get1RTTSealer mocks base method
|
||||
func (m *MockSealingManager) Get1RTTSealer() (handshake.Sealer, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetSealer")
|
||||
ret0, _ := ret[0].(protocol.EncryptionLevel)
|
||||
ret1, _ := ret[1].(handshake.Sealer)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetSealer indicates an expected call of GetSealer
|
||||
func (mr *MockSealingManagerMockRecorder) GetSealer() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSealer", reflect.TypeOf((*MockSealingManager)(nil).GetSealer))
|
||||
}
|
||||
|
||||
// GetSealerWithEncryptionLevel mocks base method
|
||||
func (m *MockSealingManager) GetSealerWithEncryptionLevel(arg0 protocol.EncryptionLevel) (handshake.Sealer, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetSealerWithEncryptionLevel", arg0)
|
||||
ret := m.ctrl.Call(m, "Get1RTTSealer")
|
||||
ret0, _ := ret[0].(handshake.Sealer)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetSealerWithEncryptionLevel indicates an expected call of GetSealerWithEncryptionLevel
|
||||
func (mr *MockSealingManagerMockRecorder) GetSealerWithEncryptionLevel(arg0 interface{}) *gomock.Call {
|
||||
// Get1RTTSealer indicates an expected call of Get1RTTSealer
|
||||
func (mr *MockSealingManagerMockRecorder) Get1RTTSealer() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSealerWithEncryptionLevel", reflect.TypeOf((*MockSealingManager)(nil).GetSealerWithEncryptionLevel), arg0)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get1RTTSealer", reflect.TypeOf((*MockSealingManager)(nil).Get1RTTSealer))
|
||||
}
|
||||
|
||||
// GetHandshakeSealer mocks base method
|
||||
func (m *MockSealingManager) GetHandshakeSealer() (handshake.Sealer, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetHandshakeSealer")
|
||||
ret0, _ := ret[0].(handshake.Sealer)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetHandshakeSealer indicates an expected call of GetHandshakeSealer
|
||||
func (mr *MockSealingManagerMockRecorder) GetHandshakeSealer() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHandshakeSealer", reflect.TypeOf((*MockSealingManager)(nil).GetHandshakeSealer))
|
||||
}
|
||||
|
||||
// GetInitialSealer mocks base method
|
||||
func (m *MockSealingManager) GetInitialSealer() (handshake.Sealer, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetInitialSealer")
|
||||
ret0, _ := ret[0].(handshake.Sealer)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetInitialSealer indicates an expected call of GetInitialSealer
|
||||
func (mr *MockSealingManagerMockRecorder) GetInitialSealer() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetInitialSealer", reflect.TypeOf((*MockSealingManager)(nil).GetInitialSealer))
|
||||
}
|
||||
|
|
|
@ -93,8 +93,9 @@ type packetNumberManager interface {
|
|||
}
|
||||
|
||||
type sealingManager interface {
|
||||
GetSealer() (protocol.EncryptionLevel, handshake.Sealer)
|
||||
GetSealerWithEncryptionLevel(protocol.EncryptionLevel) (handshake.Sealer, error)
|
||||
GetInitialSealer() (handshake.Sealer, error)
|
||||
GetHandshakeSealer() (handshake.Sealer, error)
|
||||
Get1RTTSealer() (handshake.Sealer, error)
|
||||
}
|
||||
|
||||
type frameSource interface {
|
||||
|
@ -163,7 +164,23 @@ func (p *packetPacker) PackConnectionClose(ccf *wire.ConnectionCloseFrame) (*pac
|
|||
frames: []wire.Frame{ccf},
|
||||
length: ccf.Length(p.version),
|
||||
}
|
||||
encLevel, sealer := p.cryptoSetup.GetSealer()
|
||||
// send the CONNECTION_CLOSE frame with the highest available encryption level
|
||||
var sealer handshake.Sealer
|
||||
var err error
|
||||
encLevel := protocol.Encryption1RTT
|
||||
sealer, err = p.cryptoSetup.Get1RTTSealer()
|
||||
if err != nil {
|
||||
encLevel = protocol.EncryptionHandshake
|
||||
sealer, err = p.cryptoSetup.GetHandshakeSealer()
|
||||
if err != nil {
|
||||
encLevel = protocol.EncryptionInitial
|
||||
sealer, err = p.cryptoSetup.GetInitialSealer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header := p.getHeader(encLevel)
|
||||
return p.writeAndSealPacket(header, payload, encLevel, sealer)
|
||||
}
|
||||
|
@ -178,9 +195,12 @@ func (p *packetPacker) MaybePackAckPacket() (*packedPacket, error) {
|
|||
length: ack.Length(p.version),
|
||||
}
|
||||
// TODO(#1534): only pack ACKs with the right encryption level
|
||||
encLevel, sealer := p.cryptoSetup.GetSealer()
|
||||
header := p.getHeader(encLevel)
|
||||
return p.writeAndSealPacket(header, payload, encLevel, sealer)
|
||||
sealer, err := p.cryptoSetup.Get1RTTSealer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
header := p.getHeader(protocol.Encryption1RTT)
|
||||
return p.writeAndSealPacket(header, payload, protocol.Encryption1RTT, sealer)
|
||||
}
|
||||
|
||||
// PackRetransmission packs a retransmission
|
||||
|
@ -202,8 +222,18 @@ func (p *packetPacker) PackRetransmission(packet *ackhandler.Packet) ([]*packedP
|
|||
}
|
||||
|
||||
var packets []*packedPacket
|
||||
encLevel := packet.EncryptionLevel
|
||||
sealer, err := p.cryptoSetup.GetSealerWithEncryptionLevel(encLevel)
|
||||
var err error
|
||||
var sealer handshake.Sealer
|
||||
switch packet.EncryptionLevel {
|
||||
case protocol.EncryptionInitial:
|
||||
sealer, err = p.cryptoSetup.GetInitialSealer()
|
||||
case protocol.EncryptionHandshake:
|
||||
sealer, err = p.cryptoSetup.GetHandshakeSealer()
|
||||
case protocol.Encryption1RTT:
|
||||
sealer, err = p.cryptoSetup.Get1RTTSealer()
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected encryption level: %s", packet.EncryptionLevel)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -211,7 +241,7 @@ func (p *packetPacker) PackRetransmission(packet *ackhandler.Packet) ([]*packedP
|
|||
var frames []wire.Frame
|
||||
var length protocol.ByteCount
|
||||
|
||||
header := p.getHeader(encLevel)
|
||||
header := p.getHeader(packet.EncryptionLevel)
|
||||
headerLen := header.GetLength(p.version)
|
||||
maxSize := p.maxPacketSize - protocol.ByteCount(sealer.Overhead()) - headerLen
|
||||
|
||||
|
@ -247,7 +277,7 @@ func (p *packetPacker) PackRetransmission(packet *ackhandler.Packet) ([]*packedP
|
|||
if sf, ok := frames[len(frames)-1].(*wire.StreamFrame); ok {
|
||||
sf.DataLenPresent = false
|
||||
}
|
||||
p, err := p.writeAndSealPacket(header, payload{frames: frames, length: length}, encLevel, sealer)
|
||||
p, err := p.writeAndSealPacket(header, payload{frames: frames, length: length}, packet.EncryptionLevel, sealer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -267,8 +297,12 @@ func (p *packetPacker) PackPacket() (*packedPacket, error) {
|
|||
return packet, nil
|
||||
}
|
||||
|
||||
encLevel, sealer := p.cryptoSetup.GetSealer()
|
||||
header := p.getHeader(encLevel)
|
||||
sealer, err := p.cryptoSetup.Get1RTTSealer()
|
||||
if err != nil {
|
||||
// sealer not yet available
|
||||
return nil, nil
|
||||
}
|
||||
header := p.getHeader(protocol.Encryption1RTT)
|
||||
headerLen := header.GetLength(p.version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -297,7 +331,7 @@ func (p *packetPacker) PackPacket() (*packedPacket, error) {
|
|||
p.numNonAckElicitingAcks = 0
|
||||
}
|
||||
|
||||
return p.writeAndSealPacket(header, payload, encLevel, sealer)
|
||||
return p.writeAndSealPacket(header, payload, protocol.Encryption1RTT, sealer)
|
||||
}
|
||||
|
||||
func (p *packetPacker) maybePackCryptoPacket() (*packedPacket, error) {
|
||||
|
@ -306,25 +340,27 @@ func (p *packetPacker) maybePackCryptoPacket() (*packedPacket, error) {
|
|||
|
||||
hasData := p.initialStream.HasData()
|
||||
ack := p.acks.GetAckFrame(protocol.EncryptionInitial)
|
||||
var sealer handshake.Sealer
|
||||
var err error
|
||||
if hasData || ack != nil {
|
||||
s = p.initialStream
|
||||
encLevel = protocol.EncryptionInitial
|
||||
sealer, err = p.cryptoSetup.GetInitialSealer()
|
||||
} else {
|
||||
hasData = p.handshakeStream.HasData()
|
||||
ack = p.acks.GetAckFrame(protocol.EncryptionHandshake)
|
||||
if hasData || ack != nil {
|
||||
s = p.handshakeStream
|
||||
encLevel = protocol.EncryptionHandshake
|
||||
sealer, err = p.cryptoSetup.GetHandshakeSealer()
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
sealer, err := p.cryptoSetup.GetSealerWithEncryptionLevel(encLevel)
|
||||
if err != nil {
|
||||
// The sealer
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var payload payload
|
||||
if ack != nil {
|
||||
|
|
|
@ -174,7 +174,7 @@ var _ = Describe("Packet packer", func() {
|
|||
}
|
||||
}),
|
||||
)
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
|
||||
|
@ -217,7 +217,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("returns nil when no packet is queued", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
// don't expect any calls to PopPacketNumber
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
|
||||
framer.EXPECT().AppendControlFrames(nil, gomock.Any())
|
||||
framer.EXPECT().AppendStreamFrames(nil, gomock.Any())
|
||||
|
@ -229,7 +229,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("packs single packets", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
|
||||
expectAppendControlFrames()
|
||||
f := &wire.StreamFrame{
|
||||
|
@ -249,7 +249,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("stores the encryption level a packet was sealed with", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
|
||||
expectAppendControlFrames()
|
||||
expectAppendStreamFrames(&wire.StreamFrame{
|
||||
|
@ -266,7 +266,7 @@ var _ = Describe("Packet packer", func() {
|
|||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Largest: 42, Smallest: 1}}}
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Return(ack)
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
expectAppendControlFrames()
|
||||
expectAppendStreamFrames()
|
||||
p, err := packer.PackPacket()
|
||||
|
@ -283,7 +283,7 @@ var _ = Describe("Packet packer", func() {
|
|||
ErrorCode: 0x1337,
|
||||
ReasonPhrase: "foobar",
|
||||
}
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
p, err := packer.PackConnectionClose(&ccf)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(p.frames).To(HaveLen(1))
|
||||
|
@ -293,7 +293,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("packs control frames", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
|
||||
frames := []wire.Frame{&wire.ResetStreamFrame{}, &wire.MaxDataFrame{}}
|
||||
expectAppendControlFrames(frames...)
|
||||
|
@ -307,7 +307,7 @@ var _ = Describe("Packet packer", func() {
|
|||
|
||||
It("accounts for the space consumed by control frames", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
|
||||
var maxSize protocol.ByteCount
|
||||
gomock.InOrder(
|
||||
|
@ -335,7 +335,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("packs ACK packets", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 10}}}
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Return(ack)
|
||||
p, err := packer.MaybePackAckPacket()
|
||||
|
@ -349,7 +349,7 @@ var _ = Describe("Packet packer", func() {
|
|||
for i := 0; i < protocol.MaxNonAckElicitingAcks; i++ {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
|
||||
expectAppendControlFrames()
|
||||
expectAppendStreamFrames()
|
||||
|
@ -365,7 +365,7 @@ var _ = Describe("Packet packer", func() {
|
|||
sendMaxNumNonAckElicitingAcks()
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
|
||||
expectAppendControlFrames()
|
||||
expectAppendStreamFrames()
|
||||
|
@ -376,7 +376,7 @@ var _ = Describe("Packet packer", func() {
|
|||
// make sure the next packet doesn't contain another PING
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
|
||||
expectAppendControlFrames()
|
||||
expectAppendStreamFrames()
|
||||
|
@ -391,7 +391,7 @@ var _ = Describe("Packet packer", func() {
|
|||
sendMaxNumNonAckElicitingAcks()
|
||||
// nothing to send
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
expectAppendControlFrames()
|
||||
expectAppendStreamFrames()
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
|
||||
|
@ -403,7 +403,7 @@ var _ = Describe("Packet packer", func() {
|
|||
expectAppendStreamFrames()
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}}
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Return(ack)
|
||||
p, err = packer.PackPacket()
|
||||
|
@ -416,7 +416,7 @@ var _ = Describe("Packet packer", func() {
|
|||
sendMaxNumNonAckElicitingAcks()
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
|
||||
expectAppendStreamFrames()
|
||||
expectAppendControlFrames(&wire.MaxDataFrame{})
|
||||
|
@ -432,7 +432,7 @@ var _ = Describe("Packet packer", func() {
|
|||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
expectAppendControlFrames()
|
||||
sf := &wire.StreamFrame{
|
||||
Offset: 1,
|
||||
|
@ -468,7 +468,7 @@ var _ = Describe("Packet packer", func() {
|
|||
}
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
|
||||
expectAppendControlFrames()
|
||||
expectAppendStreamFrames(f1, f2, f3)
|
||||
|
@ -486,7 +486,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("retransmits a small packet", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.Encryption1RTT).Return(sealer, nil)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
frames := []wire.Frame{
|
||||
&wire.MaxDataFrame{ByteOffset: 0x1234},
|
||||
&wire.StreamFrame{StreamID: 42, Data: []byte("foobar")},
|
||||
|
@ -505,7 +505,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("packs two packets for retransmission if the original packet contained many control frames", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2).Times(2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42)).Times(2)
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.Encryption1RTT).Return(sealer, nil)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
var frames []wire.Frame
|
||||
var totalLen protocol.ByteCount
|
||||
// pack a bunch of control frames, such that the packet is way bigger than a single packet
|
||||
|
@ -533,7 +533,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("splits a STREAM frame that doesn't fit", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2).Times(2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42)).Times(2)
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.Encryption1RTT).Return(sealer, nil)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
packets, err := packer.PackRetransmission(&ackhandler.Packet{
|
||||
EncryptionLevel: protocol.Encryption1RTT,
|
||||
Frames: []wire.Frame{&wire.StreamFrame{
|
||||
|
@ -562,7 +562,7 @@ var _ = Describe("Packet packer", func() {
|
|||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2).AnyTimes()
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42)).AnyTimes()
|
||||
for i := 0; i < 100; i++ {
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.Encryption1RTT).Return(sealer, nil).MaxTimes(2)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil).MaxTimes(2)
|
||||
sf1 := &wire.StreamFrame{
|
||||
StreamID: 42,
|
||||
Offset: 1337,
|
||||
|
@ -598,7 +598,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("packs two packets for retransmission if the original packet contained many STREAM frames", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2).Times(2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42)).Times(2)
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.Encryption1RTT).Return(sealer, nil)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
var frames []wire.Frame
|
||||
var totalLen protocol.ByteCount
|
||||
// pack a bunch of control frames, such that the packet is way bigger than a single packet
|
||||
|
@ -627,7 +627,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("correctly sets the DataLenPresent on STREAM frames", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.Encryption1RTT).Return(sealer, nil)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
frames := []wire.Frame{
|
||||
&wire.StreamFrame{StreamID: 4, Data: []byte("foobar"), DataLenPresent: true},
|
||||
&wire.StreamFrame{StreamID: 5, Data: []byte("barfoo")},
|
||||
|
@ -654,7 +654,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Context("max packet size", func() {
|
||||
It("sets the maximum packet size", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2).Times(2)
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer).Times(2)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil).Times(2)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Times(2)
|
||||
var initialMaxPacketSize protocol.ByteCount
|
||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any()).Do(func(_ []wire.Frame, maxLen protocol.ByteCount) ([]wire.Frame, protocol.ByteCount) {
|
||||
|
@ -679,7 +679,7 @@ var _ = Describe("Packet packer", func() {
|
|||
|
||||
It("doesn't increase the max packet size", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2).Times(2)
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer).Times(2)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil).Times(2)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Times(2)
|
||||
var initialMaxPacketSize protocol.ByteCount
|
||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any()).Do(func(_ []wire.Frame, maxLen protocol.ByteCount) ([]wire.Frame, protocol.ByteCount) {
|
||||
|
@ -715,7 +715,7 @@ var _ = Describe("Packet packer", func() {
|
|||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial)
|
||||
initialStream.EXPECT().HasData().Return(true)
|
||||
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).Return(f)
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.EncryptionInitial).Return(sealer, nil)
|
||||
sealingManager.EXPECT().GetInitialSealer().Return(sealer, nil)
|
||||
p, err := packer.PackPacket()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
checkLength(p.raw)
|
||||
|
@ -725,7 +725,7 @@ var _ = Describe("Packet packer", func() {
|
|||
var f *wire.CryptoFrame
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.EncryptionHandshake).Return(sealer, nil)
|
||||
sealingManager.EXPECT().GetHandshakeSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake)
|
||||
initialStream.EXPECT().HasData()
|
||||
|
@ -749,7 +749,7 @@ var _ = Describe("Packet packer", func() {
|
|||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 10, Largest: 20}}}
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial).Return(ack)
|
||||
initialStream.EXPECT().HasData()
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.EncryptionInitial).Return(sealer, nil)
|
||||
sealingManager.EXPECT().GetInitialSealer().Return(sealer, nil)
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
||||
p, err := packer.PackPacket()
|
||||
|
@ -763,7 +763,7 @@ var _ = Describe("Packet packer", func() {
|
|||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake).Return(ack)
|
||||
initialStream.EXPECT().HasData()
|
||||
handshakeStream.EXPECT().HasData()
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.EncryptionHandshake).Return(sealer, nil)
|
||||
sealingManager.EXPECT().GetHandshakeSealer().Return(sealer, nil)
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42))
|
||||
p, err := packer.PackPacket()
|
||||
|
@ -777,7 +777,7 @@ var _ = Describe("Packet packer", func() {
|
|||
f := &wire.CryptoFrame{Data: []byte("foobar")}
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.EncryptionInitial).Return(sealer, nil)
|
||||
sealingManager.EXPECT().GetInitialSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial)
|
||||
initialStream.EXPECT().HasData().Return(true)
|
||||
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).Return(f)
|
||||
|
@ -799,7 +799,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(f.Length(packer.version)).To(BeEquivalentTo(2))
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen1)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionHandshake)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
|
||||
|
@ -833,7 +833,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("sets the correct length for an Initial packet", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.EncryptionInitial).Return(sealer, nil)
|
||||
sealingManager.EXPECT().GetInitialSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial)
|
||||
initialStream.EXPECT().HasData().Return(true)
|
||||
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).Return(&wire.CryptoFrame{
|
||||
|
@ -850,7 +850,7 @@ var _ = Describe("Packet packer", func() {
|
|||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 42, Largest: 1337}}}
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.EncryptionInitial).Return(sealer, nil)
|
||||
sealingManager.EXPECT().GetInitialSealer().Return(sealer, nil)
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial).Return(ack)
|
||||
initialStream.EXPECT().HasData().Return(true)
|
||||
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).Return(f)
|
||||
|
@ -869,7 +869,7 @@ var _ = Describe("Packet packer", func() {
|
|||
It("packs a retransmission with the right encryption level", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.EncryptionInitial).Return(sealer, nil)
|
||||
sealingManager.EXPECT().GetInitialSealer().Return(sealer, nil)
|
||||
packet := &ackhandler.Packet{
|
||||
PacketType: protocol.PacketTypeHandshake,
|
||||
EncryptionLevel: protocol.EncryptionInitial,
|
||||
|
@ -888,7 +888,7 @@ var _ = Describe("Packet packer", func() {
|
|||
packer.SetToken(token)
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().GetSealerWithEncryptionLevel(protocol.EncryptionInitial).Return(sealer, nil)
|
||||
sealingManager.EXPECT().GetInitialSealer().Return(sealer, nil)
|
||||
packer.perspective = protocol.PerspectiveClient
|
||||
packet := &ackhandler.Packet{
|
||||
PacketType: protocol.PacketTypeInitial,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue