code wiki / (root) / nx_aes128_gcm_wasm.nx

nx_aes128_gcm_wasm.nx

buildroot/runtime/nx_aes128_gcm_wasm.nx

22188 B488 linesdepth 0pulls 0 transitivereach 0 importersview sourcekind orphan librarytopic aes128
docsdependenciesstructsconstsfunctions

about

nx_aes128_gcm_wasm.nx -- AES-128-GCM AEAD (NIST SP 800-38D / RFC 5288). Inlines AES-128 ECB + CTR-mode encryption + GHASH (GF(2^128) multiply) to produce a single seal/open AEAD pair. Verified vs NIST SP 800-38D Appendix B Test Cases 1-4. API (12-byte IV form per RFC 5288 ยง3 -- the only IV length real-world TLS / IPsec / WireGuard use): nx_aes128_gcm_seal(key, iv12, aad, aad_len, pt, pt_len, scratch, ct_out, tag16_out) -> i64 nx_aes128_gcm_open(key, iv12, aad, aad_len, ct, ct_len, tag16, scratch, pt_out) -> i64 (0=OK, -1=auth fail) scratch >= 320 bytes. (Original CTR + ECB header below is the inlined cipher core.) nx_aes128_wasm.nx -- AES-128 ECB (FIPS 197) self-contained for WAT target. Rijndael-128 with 128-bit key, 16-byte block, 10 rounds. ECB mode only -- caller composes CTR/GCM/CBC on top. Implementation: byte-oriented SBox/InvSBox + ShiftRows + MixColumns done as straightforward 4x4 byte ops. No T-tables (slower but smaller code, simpler, side-channel-friendly). API: nx_aes128_encrypt(key_ptr, in_block, scratch_ptr, out_block) -> i64 key_ptr -- 16 bytes (128-bit key) in_block -- 16 bytes plaintext scratch_ptr -- >= 256 bytes (key schedule = 11 round keys = 176 bytes) out_block -- 16 bytes ciphertext nx_aes128_decrypt(key_ptr, in_block, scratch_ptr, out_block) -> i64 symmetric inverse (uses InvSBox + InvShiftRows + InvMixColumns) Verified against FIPS 197 Appendix C.1 (single-block KAT). license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/nist/fips_197 lineage_id: nishi_aes128_wasm_q11

dependencies 0 imports · 0 importers

imports: none

imported by: nobody (leaf or entry point)

structs

none

consts

none

functions

43func _aes_sbox(b: i64) -> i64
112func _aes_rcon(i: i64) -> i64
called by 1: _aes128_key_expand
121func _xtime(a: i64) -> i64
called by 1: _aes_mix_columns
129func _aes128_key_expand(key: *u8, rk: *u8) -> i64
161func _aes_add_round_key(state: *u8, rk: *u8, round: i64) -> i64
168func _aes_sub_bytes(state: *u8) -> i64
called by 1: _aes128_encrypt_block calls 1: _aes_sbox
180func _aes_shift_rows(state: *u8) -> i64
209func _aes_mix_columns(state: *u8) -> i64
called by 1: _aes128_encrypt_block calls 1: _xtime
233func _aes128_encrypt_block(key_ptr: *u8, in_block: *u8,
262func _aes_gcm_inc32(ctr: *u8) -> i64
276func _ghash_mul(x16: *u8, h16: *u8, z16: *u8, v16: *u8) -> i64
called by 1: _ghash_update_block
306func _ghash_update_block(y16: *u8, h16: *u8, x16: *u8,
315func _ghash_update_buf(y16: *u8, h16: *u8, buf: *u8, buf_len: i64,
333func _be64_put(dst: *u8, v: i64) -> i64
359func nx_aes128_gcm_seal(key_ptr: *u8, iv12: *u8,
426func nx_aes128_gcm_open(key_ptr: *u8, iv12: *u8,