fix chunk parser for ss aead

pull/787/head
Darien Raymond 2017-11-26 16:55:46 +01:00
parent 981c43afc2
commit 40222de0f7
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 2 additions and 2 deletions

View File

@ -43,7 +43,7 @@ func (p *AEADChunkSizeParser) SizeBytes() int {
} }
func (p *AEADChunkSizeParser) Encode(size uint16, b []byte) []byte { 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) b, err := p.Auth.Seal(b[:0], b)
common.Must(err) common.Must(err)
return b return b
@ -54,7 +54,7 @@ func (p *AEADChunkSizeParser) Decode(b []byte) (uint16, error) {
if err != nil { if err != nil {
return 0, err return 0, err
} }
return serial.BytesToUint16(b), nil return serial.BytesToUint16(b) + uint16(p.Auth.Overhead()), nil
} }
type ChunkStreamReader struct { type ChunkStreamReader struct {