Browse Source

fix chunk parser for ss aead

Darien Raymond 8 years ago
parent
commit
40222de0f7
1 changed files with 2 additions and 2 deletions
  1. 2 2
      common/crypto/chunk.go

+ 2 - 2
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 {