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