Documentation
¶
Overview ¶
Package ChaCha20 implements the core ChaCha20 function as specified in https://tools.ietf.org/html/rfc7539#section-2.3.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HChaCha20 ¶
HChaCha20 uses the ChaCha20 core to generate a derived key from a key and a nonce. It should only be used as part of the XChaCha20 construction.
Types ¶
type Cipher ¶
type Cipher struct {
// contains filtered or unexported fields
}
Cipher is a stateful instance of ChaCha20 using a particular key and nonce. A *Cipher implements the cipher.Stream interface.
func New ¶
New creates a new ChaCha20 stream cipher with the given key and nonce. The initial counter value is set to 0.
func (*Cipher) Advance ¶
func (s *Cipher) Advance()
Advance discards bytes in the key stream until the next 64 byte block boundary is reached and updates the counter accordingly. If the key stream is already at a block boundary no bytes will be discarded and the counter will be unchanged.
func (*Cipher) XORKeyStream ¶
XORKeyStream XORs each byte in the given slice with a byte from the cipher's key stream. Dst and src must overlap entirely or not at all.
If len(dst) < len(src), XORKeyStream will panic. It is acceptable to pass a dst bigger than src, and in that case, XORKeyStream will only update dst[:len(src)] and will not touch the rest of dst.
Multiple calls to XORKeyStream behave as if the concatenation of the src buffers was passed in a single run. That is, Cipher maintains state and does not reset at each XORKeyStream call.