From acb999ee6438fd68aa6492c5b60179d2570b9900 Mon Sep 17 00:00:00 2001 From: Qian Wang Date: Wed, 7 Aug 2019 00:15:55 +0100 Subject: [PATCH] Force aead key sizes as 32 bytes due to chacha20-poly1305 --- internal/multiplex/obfs.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/multiplex/obfs.go b/internal/multiplex/obfs.go index 8682a46..0a18e5e 100644 --- a/internal/multiplex/obfs.go +++ b/internal/multiplex/obfs.go @@ -117,7 +117,6 @@ func GenerateObfs(encryptionMethod byte, sessionKey []byte) (obfuscator *Obfusca err = errors.New("sessionKey size must be 32 bytes") } - blockKey := sessionKey[:16] var salsaKey [32]byte copy(salsaKey[:], sessionKey) @@ -127,7 +126,7 @@ func GenerateObfs(encryptionMethod byte, sessionKey []byte) (obfuscator *Obfusca payloadCipher = nil case 0x01: var c cipher.Block - c, err = aes.NewCipher(blockKey) + c, err = aes.NewCipher(sessionKey) if err != nil { return } @@ -136,7 +135,7 @@ func GenerateObfs(encryptionMethod byte, sessionKey []byte) (obfuscator *Obfusca return } case 0x02: - payloadCipher, err = chacha20poly1305.New(blockKey) + payloadCipher, err = chacha20poly1305.New(sessionKey) if err != nil { return }