Documentation ¶
Overview ¶
Package chacha20 implements the ChaCha20 / XChaCha20 stream chipher. Notice that one specific key-nonce combination must be unique for all time.
There are three versions of ChaCha20: - ChaCha20 with a 64 bit nonce (en/decrypt up to 2^64 * 64 bytes for one key-nonce combination) - ChaCha20 with a 96 bit nonce (en/decrypt up to 2^32 * 64 bytes (~256 GB) for one key-nonce combination) - XChaCha20 with a 192 bit nonce (en/decrypt up to 2^64 * 64 bytes for one key-nonce combination)
Index ¶
Constants ¶
View Source
const ( KeySize = 32 NonceSize = 8 )
View Source
const (
NonceSizeX = 24
)
Variables ¶
View Source
var ( ErrBadKeyLength = errors.New("chacha20: bad key length. 32 bytes required") ErrBadNonceLength = errors.New("chacha20: bad nonce length for ChaCha20. 8 bytes required") )
View Source
var (
ErrBadNonceXLength = errors.New("chacha20: bad nonce length for XChaCha20. 24 bytes required")
)
Functions ¶
This section is empty.
Types ¶
type StreamCipher ¶
func New ¶
func New(key, nonce []byte) (StreamCipher, error)
func NewX ¶
func NewX(key, nonce []byte) (StreamCipher, error)
NewX returns a new instance of the XChaCha20 stream cipher. as of now we use the IETF chacha20 variant with 96-bit nonces
Click to show internal directories.
Click to hide internal directories.