mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
return the encryption level of a packet when decrypting it
This commit is contained in:
parent
811bd20939
commit
a972c7a21e
12 changed files with 85 additions and 47 deletions
|
@ -12,30 +12,40 @@ import (
|
|||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
type mockAEAD struct{}
|
||||
|
||||
func (m *mockAEAD) Open(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) ([]byte, protocol.EncryptionLevel, error) {
|
||||
res, err := (&crypto.NullAEAD{}).Open(dst, src, packetNumber, associatedData)
|
||||
return res, protocol.EncryptionUnspecified, err
|
||||
}
|
||||
func (m *mockAEAD) Seal(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) []byte {
|
||||
return (&crypto.NullAEAD{}).Seal(dst, src, packetNumber, associatedData)
|
||||
}
|
||||
|
||||
var _ quicAEAD = &mockAEAD{}
|
||||
|
||||
var _ = Describe("Packet unpacker", func() {
|
||||
var (
|
||||
unpacker *packetUnpacker
|
||||
hdr *PublicHeader
|
||||
hdrBin []byte
|
||||
aead crypto.AEAD
|
||||
data []byte
|
||||
buf *bytes.Buffer
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
aead = &crypto.NullAEAD{}
|
||||
hdr = &PublicHeader{
|
||||
PacketNumber: 10,
|
||||
PacketNumberLen: 1,
|
||||
}
|
||||
hdrBin = []byte{0x04, 0x4c, 0x01}
|
||||
unpacker = &packetUnpacker{aead: aead}
|
||||
unpacker = &packetUnpacker{aead: &mockAEAD{}}
|
||||
data = nil
|
||||
buf = &bytes.Buffer{}
|
||||
})
|
||||
|
||||
setData := func(p []byte) {
|
||||
data = aead.Seal(nil, p, 0, hdrBin)
|
||||
data = unpacker.aead.Seal(nil, p, 0, hdrBin)
|
||||
}
|
||||
|
||||
It("does not read read a private flag for QUIC Version >= 34", func() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue