`ChaCha20` and `XChaCha20` stream ciphers. See: - [[ https://datatracker.ietf.org/doc/html/rfc8439 ]] - [[ https://datatracker.ietf.org/doc/draft-irtf-cfrg-xchacha/03/ ]]

Collection Info

View Source
Collection
core
Path
crypto/chacha20
Entries
11

Source Files

Constants

4

DEFAULT_IMPLEMENTATION #

Source
DEFAULT_IMPLEMENTATION :: Implementation.Simd256

DEFAULT_IMPLEMENTATION is the implementation that will be used by default if possible.

IV_SIZE #

Source
IV_SIZE :: _chacha20.IV_SIZE

IV_SIZE is the ChaCha20 IV size in bytes.

KEY_SIZE #

Source
KEY_SIZE :: _chacha20.KEY_SIZE

KEY_SIZE is the (X)ChaCha20 key size in bytes.

XIV_SIZE #

Source
XIV_SIZE :: _chacha20.XIV_SIZE

XIV_SIZE is the XChaCha20 IV size in bytes.

Types

2

Implementation #

Source
Implementation :: Implementation

Implementation is a ChaCha20 implementation. Most callers will not need to use this as the package will automatically select the most performant implementation available.

Procedures

5

init #

Source
init :: proc(ctx: ^Context, key, iv: []u8, impl: Implementation = DEFAULT_IMPLEMENTATION) {…}

init inititializes a Context for ChaCha20 or XChaCha20 with the provided key and iv.

keystream_bytes #

Source
keystream_bytes :: proc(ctx: ^Context, dst: []u8) {…}

keystream_bytes fills dst with the raw (X)ChaCha20 keystream output.

reset #

Source
reset :: proc(ctx: ^Context) {…}

reset sanitizes the Context. The Context must be re-initialized to be used again.

seek #

Source
seek :: proc(ctx: ^Context, block_nr: u64) {…}

seek seeks the (X)ChaCha20 stream counter to the specified block.

xor_bytes #

Source
xor_bytes :: proc(ctx: ^Context, dst, src: []u8) {…}

xor_bytes XORs each byte in src with bytes taken from the (X)ChaCha20 keystream, and writes the resulting output to dst. Dst and src MUST alias exactly or not at all.