code wiki / (root) / nx_chacha20_poly1305_wasm.nx

nx_chacha20_poly1305_wasm.nx

buildroot/runtime/nx_chacha20_poly1305_wasm.nx

16749 B468 linesdepth 0pulls 0 transitivereach 0 importersview sourcekind orphan librarytopic chacha20
docsdependenciesstructsconstsfunctions

about

nx_chacha20_poly1305_wasm.nx -- ChaCha20-Poly1305 AEAD (RFC 7539 §2.8). AEAD construction: otk = chacha20_block(key, counter=0, nonce)[:32] ciphertext = chacha20_xor(key, counter=1, nonce, plaintext) mac_data = aad || pad16(aad) || ct || pad16(ct) || le64(aad_len) || le64(ct_len) tag = poly1305(otk, mac_data) return ciphertext || tag pad16(x) = zero-bytes to reach the next 16-byte multiple; empty if already aligned. API for the embedder: nx_chacha20poly1305_seal(key, nonce, aad, aad_len, plaintext, pt_len, scratch, ciphertext_out, tag_out) -> i64 nx_chacha20poly1305_open(key, nonce, aad, aad_len, ciphertext, ct_len, tag, scratch, plaintext_out) -> i64 returns 0 on auth success + plaintext_out filled, -1 on auth failure (plaintext_out NOT touched). scratch_ptr must be >= 4096 bytes (Poly1305 needs 128 + AEAD staging). Verified against RFC 7539 §2.8.2 test vector. license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/ietf/rfc_7539 lineage_id: nishi_chacha20poly1305_wasm_q11

dependencies 0 imports · 0 importers

imports: none

imported by: nobody (leaf or entry point)

structs

none

consts

36const M32: i64 = 0xFFFFFFFF
37const M26: i64 = 0x3ffffff

functions

41func _le32_read(buf: *u8, off: i64) -> i64
48func _le32_write(buf: *u8, off: i64, v: i64) -> i64
56func _rotl32(x: i64, n: i64) -> i64
called by 1: _qr
63func _qr(state: *u8, ai: i64, bi: i64, ci: i64, di: i64) -> i64
79func _chacha20_block(init: *u8, work: *u8, keystream: *u8) -> i64
105func _chacha20_init_state(init: *u8, key: *u8, nonce: *u8, counter: i64) -> i64
120func _chacha20_xor(key: *u8, nonce: *u8, counter: i64,
146func _i64_get(buf: *u8, idx: i64) -> i64
157func _i64_set(buf: *u8, idx: i64, v: i64) -> i64
170func _clamp_and_split_r(key: *u8, r_lims: *u8) -> i64
called by 1: _poly1305 calls 2: _le32_read_i64_set
188func _poly_block(acc: *u8, r_lims: *u8, blk: *u8, blk_len: i64, hi_bit: i64) -> i64
253func _poly1305(key: *u8, msg: *u8, msg_len: i64, scratch: *u8, out: *u8) -> i64
325func _pad16(len: i64) -> i64
343func nx_chacha20poly1305_seal(key: *u8, nonce: *u8,
402func nx_chacha20poly1305_open(key: *u8, nonce: *u8,