mirror of
https://github.com/MetaCubeX/Clash.Meta.git
synced 2025-04-18 08:20:53 +00:00
Add chacha8-ietf cipher(Uncompleted)
This commit is contained in:
parent
9e3589d638
commit
a82ab21ed8
1 changed files with 13 additions and 0 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"crypto/rc4"
|
||||
"strconv"
|
||||
|
||||
"github.com/chocolatkey/chacha8"
|
||||
"golang.org/x/crypto/chacha20"
|
||||
)
|
||||
|
||||
|
@ -73,6 +74,18 @@ func Chacha20IETF(key []byte) (Cipher, error) {
|
|||
return chacha20ietfkey(key), nil
|
||||
}
|
||||
|
||||
type chacha8ietfkey []byte
|
||||
|
||||
func (k chacha8ietfkey) IVSize() int { return chacha8.NonceSize }
|
||||
func (k chacha8ietfkey) Decrypter(iv []byte) cipher.Stream { return k.Encrypter(iv) }
|
||||
func (k chacha8ietfkey) Encrypter(iv []byte) cipher.Stream {
|
||||
ciph, err := chacha8.New(k, iv)
|
||||
if err != nil {
|
||||
panic(err) // should never happen
|
||||
}
|
||||
return ciph
|
||||
}
|
||||
|
||||
type xchacha20key []byte
|
||||
|
||||
func (k xchacha20key) IVSize() int { return chacha20.NonceSizeX }
|
||||
|
|
Loading…
Add table
Reference in a new issue