Documentation
¶
Overview ¶
Package chacha implements some low level functions of the ChaCha cipher family.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Core ¶
Core generates 64 byte keystream from the given state performing 'rounds' rounds and writes them to dst. This function expects valid values. (no nil ptr etc.) Core increments the counter of state.
func XORBlocks ¶
XORBlocks crypts full block ( len(src) - (len(src) mod 64) bytes ) from src to dst using the state. Src and dst may be the same slice but otherwise should not overlap. This function increments the counter of state. If len(src) > len(dst), XORBlocks does nothing.
func XORKeyStream ¶
XORKeyStream crypts bytes from src to dst using the given key, nonce and counter. The rounds argument specifies the number of rounds (must be even) performed for keystream generation. (Common values are 20, 12 or 8) Src and dst may be the same slice but otherwise should not overlap. If len(dst) < len(src) this function panics.
Types ¶
type Cipher ¶
type Cipher struct {
// contains filtered or unexported fields
}
Cipher is the ChaCha/X struct. X is the number of rounds (e.g. ChaCha20 for 20 rounds)
func NewCipher ¶
NewCipher returns a new *chacha.Cipher implementing the ChaCha/X (X = even number of rounds) stream cipher. The nonce must be unique for one key for all time.
func (*Cipher) SetCounter ¶
Sets the counter of the cipher. Notice that this function skips the unused keystream of the current 64 byte block.
func (*Cipher) XORKeyStream ¶
XORKeyStream crypts bytes from src to dst. Src and dst may be the same slice but otherwise should not overlap. If len(dst) < len(src) the function panics.