Documentation
¶
Index ¶
Constants ¶
View Source
const ( // KeySize is the ChaCha20 key size in bytes. KeySize = 32 // NonceSize is the ChaCha20 nonce size in bytes. NonceSize = 8 // INonceSize is the IETF ChaCha20 nonce size in bytes. INonceSize = 12 // XNonceSize is the XChaCha20 nonce size in bytes. XNonceSize = 24 // HNonceSize is the HChaCha20 nonce size in bytes. HNonceSize = 16 // BlockSize is the ChaCha20 block size in bytes. BlockSize = 64 )
Variables ¶
View Source
var ( // ErrInvalidKey is the error returned when the key is invalid. ErrInvalidKey = errors.New("key length must be KeySize bytes") // ErrInvalidNonce is the error returned when the nonce is invalid. ErrInvalidNonce = errors.New("nonce length must be NonceSize/INonceSize/XNonceSize bytes") // ErrInvalidCounter is the error returned when the counter is invalid. ErrInvalidCounter = errors.New("block counter is invalid (out of range)") )
Functions ¶
func HChaCha ¶
func HChaCha(key []byte, nonce *[HNonceSize]byte, out *[32]byte)
HChaCha is the HChaCha20 hash function used to make XChaCha.
Types ¶
type Cipher ¶
type Cipher struct {
// contains filtered or unexported fields
}
A Cipher is an instance of ChaCha20/XChaCha20 using a particular key and nonce.
func NewCipher ¶
NewCipher returns a new ChaCha20/XChaCha20 instance.
func (*Cipher) KeyStream ¶
KeyStream sets dst to the raw keystream.
func (*Cipher) ReKey ¶
ReKey reinitializes the ChaCha20/XChaCha20 instance with the provided key and nonce.
func (*Cipher) Reset ¶
func (c *Cipher) Reset()
Reset zeros the key data so that it will no longer appear in the process's memory.
func (*Cipher) Seek ¶
Seek sets the block counter to a given offset.
Click to show internal directories.
Click to hide internal directories.