Force aead key sizes as 32 bytes due to chacha20-poly1305

This commit is contained in:
Qian Wang 2019-08-07 00:15:55 +01:00
parent 581c2332d1
commit acb999ee64

View File

@ -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
}