Clash.Meta/transport/shadowsocks/shadowstream/old_chacha20.go

24 lines
436 B
Go
Raw Normal View History

2022-11-16 18:37:14 +08:00
package shadowstream
import (
"crypto/cipher"
2024-07-19 22:08:05 +08:00
"github.com/metacubex/chacha"
2022-11-16 18:37:14 +08:00
)
type chacha20key []byte
func (k chacha20key) IVSize() int {
return chacha.NonceSize
}
func (k chacha20key) Encrypter(iv []byte) cipher.Stream {
2024-07-19 22:08:05 +08:00
c, _ := chacha.NewChaCha20(iv, k)
2022-11-16 18:37:14 +08:00
return c
}
func (k chacha20key) Decrypter(iv []byte) cipher.Stream {
return k.Encrypter(iv)
}
func ChaCha20(key []byte) (Cipher, error) {
return chacha20key(key), nil
}