From 89c2205d40fe4b14d023a65e110fbd82246ce673 Mon Sep 17 00:00:00 2001 From: passingwang Date: Fri, 19 Jul 2024 16:51:39 +0800 Subject: [PATCH] fix --- transport/shadowsocks/core/cipher.go | 1 + transport/shadowsocks/shadowstream/cipher.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/transport/shadowsocks/core/cipher.go b/transport/shadowsocks/core/cipher.go index 44b2e8d4..c459b2ea 100644 --- a/transport/shadowsocks/core/cipher.go +++ b/transport/shadowsocks/core/cipher.go @@ -61,6 +61,7 @@ var streamList = map[string]struct { "AES-192-CFB": {24, shadowstream.AESCFB}, "AES-256-CFB": {32, shadowstream.AESCFB}, "CHACHA20": {32, shadowstream.ChaCha20}, + "CHACHA8-IETF": {32, shadowstream.Chacha8IETF}, "CHACHA20-IETF": {32, shadowstream.Chacha20IETF}, "XCHACHA20": {32, shadowstream.Xchacha20}, } diff --git a/transport/shadowsocks/shadowstream/cipher.go b/transport/shadowsocks/shadowstream/cipher.go index a357bbf9..173cf37d 100644 --- a/transport/shadowsocks/shadowstream/cipher.go +++ b/transport/shadowsocks/shadowstream/cipher.go @@ -86,6 +86,13 @@ func (k chacha8ietfkey) Encrypter(iv []byte) cipher.Stream { return ciph } +func Chacha8IETF(key []byte) (Cipher, error) { + if len(key) != chacha8.KeySize { + return nil, KeySizeError(chacha8.KeySize) + } + return chacha8ietfkey(key), nil +} + type xchacha20key []byte func (k xchacha20key) IVSize() int { return chacha20.NonceSizeX }