`AEAD_CHACHA20_POLY1305` and `AEAD_XChaCha20_Poly1305` algorithms. Where AEAD stands for Authenticated Encryption with Additional Data. See: - [[ https://www.rfc-editor.org/rfc/rfc8439 ]] - [[ https://datatracker.ietf.org/doc/html/draft-arciszewski-xchacha-03 ]]

Collection Info

View Source
Collection
core
Path
crypto/chacha20poly1305
Entries
10

Source Files

Constants

4

IV_SIZE #

Source
IV_SIZE :: chacha20.IV_SIZE

IV_SIZE is the chacha20poly1305 IV size in bytes.

KEY_SIZE #

Source
KEY_SIZE :: chacha20.KEY_SIZE

KEY_SIZE is the chacha20poly1305 key size in bytes.

TAG_SIZE #

Source
TAG_SIZE :: poly1305.TAG_SIZE

TAG_SIZE is the chacha20poly1305 tag size in bytes.

XIV_SIZE #

Source
XIV_SIZE :: chacha20.XIV_SIZE

XIV_SIZE is the xchacha20poly1305 IV size in bytes.

Types

1

Procedures

5

init #

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

init initializes a Context with the provided key, for AEAD_CHACHA20_POLY1305.

init_xchacha #

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

init_xchacha initializes a Context with the provided key, for AEAD_XChaCha20_Poly1305. Note: While there are multiple definitions of XChaCha20-Poly1305 this sticks to the IETF draft and uses a 32-bit counter.

open #

Source
@(require_results)
open :: proc(
	ctx:                           ^Context, 
	dst, iv, aad, ciphertext, tag: []u8, 
) -> bool {…}

open authenticates the aad and ciphertext, and decrypts the ciphertext, with the provided Context, iv, and tag, and stores the output in dst, returning true if and only if (⟺) the authentication was successful. If authentication fails, the destination buffer will be zeroed. dst and plaintext MUST alias exactly or not at all.

reset #

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

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

seal #

Source
seal :: proc(
	ctx:                          ^Context, 
	dst, tag, iv, aad, plaintext: []u8, 
) {…}

seal encrypts the plaintext and authenticates the aad and ciphertext, with the provided Context and iv, stores the output in dst and tag. dst and plaintext MUST alias exactly or not at all.