2016-02-23 11:33:54 -05:00
|
|
|
package crypto
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/cipher"
|
|
|
|
|
2021-02-16 15:31:50 -05:00
|
|
|
"github.com/v2fly/v2ray-core/v4/common/crypto/internal"
|
2016-02-23 11:33:54 -05:00
|
|
|
)
|
|
|
|
|
2016-07-26 15:21:22 -04: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.
|
2016-07-23 07:04:44 -04:00
|
|
|
func NewChaCha20Stream(key []byte, iv []byte) cipher.Stream {
|
2016-07-25 04:28:11 -04:00
|
|
|
return internal.NewChaCha20Stream(key, iv, 20)
|
2016-02-23 11:33:54 -05:00
|
|
|
}
|