Chacha20 v0.3.5 Chacha20
Chacha20 symmetric stream cipher
https://tools.ietf.org/html/rfc7539
The calling semantics are still sub-optimal and no performance tuning has been done.
Summary
Types
The parameters and state of the current session
The shared encryption key
The shared per-session nonce
Functions
Return an arbitrary block
The crypt function suitable for a complete message
The crypt function suitable for streaming
Types
The parameters and state of the current session
- The shared key
- The session nonce
- The next block number
- The unused portion of the current block
To start from block 0, the initial state is {k,n,0,""}
The shared encryption key.
The shared per-session nonce.
By spec, this nonce may be used to encrypt a stream of up to 256GiB
An eight-byte nonce is compatible with the original reference implementation.
Functions
Return an arbitrary block
This is probably most useful in fast-forwarding a stream.
The crypt function suitable for a complete message.
This is a convenience wrapper when the full message is ready for processing.
The operations are symmetric, so if crypt(m,k,n) = c
, then crypt(c,k,n) = m
crypt_bytes(binary, chacha_parameters, [binary]) :: {binary, chacha_parameters}
The crypt function suitable for streaming
Use an initial state of {k,n,0,""}
The returned parameters can be used for the next available bytes.
Any previous emitted binary can be included in the acc
, if desired.