mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 20:57:36 +03:00
use in place decryption for unpacking packets
This commit is contained in:
parent
89e719f03b
commit
38efa84e9c
2 changed files with 2 additions and 9 deletions
|
@ -108,11 +108,7 @@ func tlsToMintConfig(tlsConf *tls.Config, pers protocol.Perspective) (*mint.Conf
|
||||||
// unpackInitialOrRetryPacket unpacks packets Initial and Retry packets
|
// unpackInitialOrRetryPacket unpacks packets Initial and Retry packets
|
||||||
// These packets must contain a STREAM_FRAME for the crypto stream, starting at offset 0.
|
// These packets must contain a STREAM_FRAME for the crypto stream, starting at offset 0.
|
||||||
func unpackInitialPacket(aead crypto.AEAD, hdr *wire.Header, data []byte, logger utils.Logger, version protocol.VersionNumber) (*wire.StreamFrame, error) {
|
func unpackInitialPacket(aead crypto.AEAD, hdr *wire.Header, data []byte, logger utils.Logger, version protocol.VersionNumber) (*wire.StreamFrame, error) {
|
||||||
buf := *getPacketBuffer()
|
decrypted, err := aead.Open(data[:0], data, hdr.PacketNumber, hdr.Raw)
|
||||||
buf = buf[:0]
|
|
||||||
defer putPacketBuffer(&buf)
|
|
||||||
|
|
||||||
decrypted, err := aead.Open(buf, data, hdr.PacketNumber, hdr.Raw)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,10 +63,7 @@ func newPacketUnpackerGQUIC(aead gQUICAEAD, version protocol.VersionNumber) unpa
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *packetUnpackerGQUIC) Unpack(headerBinary []byte, hdr *wire.Header, data []byte) (*unpackedPacket, error) {
|
func (u *packetUnpackerGQUIC) Unpack(headerBinary []byte, hdr *wire.Header, data []byte) (*unpackedPacket, error) {
|
||||||
buf := *getPacketBuffer()
|
decrypted, encryptionLevel, err := u.aead.Open(data[:0], data, hdr.PacketNumber, headerBinary)
|
||||||
buf = buf[:0]
|
|
||||||
defer putPacketBuffer(&buf)
|
|
||||||
decrypted, encryptionLevel, err := u.aead.Open(buf, data, hdr.PacketNumber, headerBinary)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Wrap err in quicError so that public reset is sent by session
|
// Wrap err in quicError so that public reset is sent by session
|
||||||
return nil, qerr.Error(qerr.DecryptionFailure, err.Error())
|
return nil, qerr.Error(qerr.DecryptionFailure, err.Error())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue