Salsa20 v0.2.0 Salsa20
Salsa20 symmetric stream cipher
As specified in http://cr.yp.to/snuffle/spec.pdf.
The calling semantics are still sub-optimal and no performance tuning has been done.
Summary
Types
The shared encryption key
The shared per-session nonce
The parameters and state of the current session
Functions
The crypt function suitable for a complete message
The crypt function suitable for streaming
Types
key :: <<_::32 * 8>> | <<_::16 * 8>>
The shared encryption key.
32-byte values are to be preferred over 16-byte ones where possible.
nonce :: <<_::8 * 8>>
The shared per-session nonce.
By spec, this nonce may be used to encrypt a stream of up to 2^70 bytes.
salsa_parameters :: {key, nonce, non_neg_integer, binary}
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
Starting from block 0 the initial state is {k,v,0,""}
Functions
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,v) = c
, then crypt(c,k,v) = m
Specs
crypt_bytes(binary, salsa_parameters, [binary]) :: {binary, salsa_parameters}
The crypt function suitable for streaming
Use an initial state of {k,v,0,""}
The returned parameters can be used for the next available bytes.
Any previous emitted binary can be included in the acc
, if desired.