From 40222de0f7bd5e556d0a0c18229231e24101f178 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Sun, 26 Nov 2017 16:55:46 +0100 Subject: [PATCH] fix chunk parser for ss aead --- common/crypto/chunk.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/crypto/chunk.go b/common/crypto/chunk.go index 84eb438c..5b622df6 100644 --- a/common/crypto/chunk.go +++ b/common/crypto/chunk.go @@ -43,7 +43,7 @@ func (p *AEADChunkSizeParser) SizeBytes() int { } func (p *AEADChunkSizeParser) Encode(size uint16, b []byte) []byte { - b = serial.Uint16ToBytes(size, b) + b = serial.Uint16ToBytes(size-uint16(p.Auth.Overhead()), b) b, err := p.Auth.Seal(b[:0], b) common.Must(err) return b @@ -54,7 +54,7 @@ func (p *AEADChunkSizeParser) Decode(b []byte) (uint16, error) { if err != nil { return 0, err } - return serial.BytesToUint16(b), nil + return serial.BytesToUint16(b) + uint16(p.Auth.Overhead()), nil } type ChunkStreamReader struct {