Xray-core/common/crypto/chacha20.go

14 lines
405 B
Go
Raw Permalink Normal View History

2020-11-25 11:01:53 +00:00
package crypto
import (
"crypto/cipher"
2020-12-04 01:36:16 +00:00
"github.com/xtls/xray-core/common/crypto/internal"
2020-11-25 11:01:53 +00:00
)
// NewChaCha20Stream creates a new Chacha20 encryption/descryption stream based on give key and IV.
// Caller must ensure the length of key is 32 bytes, and length of IV is either 8 or 12 bytes.
func NewChaCha20Stream(key []byte, iv []byte) cipher.Stream {
return internal.NewChaCha20Stream(key, iv, 20)
}