api

chacha_poly.ch

Declarations in chacha_poly.ch

12 declarationstls

Declarations

Public only
chacha20_rotl#
function
func chacha20_rotl(x : u32, n : u32) : u32
ChaCha20 + Poly1305 AEAD (RFC 8439) for TLS 1.3 ChaCha20-Poly1305-SHA256.
chacha20_quarter_round#
function
func chacha20_quarter_round(s : *u32, a : size_t, b : size_t, c : size_t, d : size_t) : void
chacha20_block#
function
func chacha20_block(key : *u8, counter : u32, nonce : *u8, out : *u8) : void
Produce one 64-byte ChaCha20 keystream block.
chacha20_xor#
function
func chacha20_xor(key : *u8, nonce : *u8, counter_start : u32, input : *u8, len : size_t, output : *u8) : void
XOR `len` bytes of `input` with ChaCha20 keystream starting at block `counter_start`.
Poly1305State#
Publicstruct
struct Poly1305State { var r : u32[5] var h : u32[5] var s : u8[16] var buf : u8[16] var buflen : size_t }
─── Poly1305 (RFC 8439 §2.5), 26-bit limb implementation ─────────────────────
poly1305_load_r#
function
func poly1305_load_r(state : *Poly1305State, key : *u8) : void
poly1305_init#
function
func poly1305_init(state : *Poly1305State, key : *u8) : void
poly1305_process#
function
func poly1305_process(state : *Poly1305State, block : *u8, is_final : bool, final_len : size_t) : void
Process one full (16-byte) or partial (final_len-byte) block into h.
poly1305_update#
function
func poly1305_update(state : *Poly1305State, data : *u8, len : size_t) : void
poly1305_finish#
function
func poly1305_finish(state : *Poly1305State, tag : *u8) : void
chacha20_poly1305_encrypt#
function
func chacha20_poly1305_encrypt(key : *u8, nonce : *u8, aad : *u8, aad_len : size_t, plaintext : *u8, pt_len : size_t, ciphertext : *u8, tag : *u8) : void
─── AEAD (RFC 8439 §2.8) ─────────────────────────────────────────────────────
chacha20_poly1305_decrypt#
function
func chacha20_poly1305_decrypt(key : *u8, nonce : *u8, aad : *u8, aad_len : size_t, ciphertext : *u8, ct_len : size_t, tag : *u8, plaintext : *u8) : int
Returns 0 on success (tag verified), negative on authentication failure.