code wiki / (root) / nx_hmac_drbg_wasm.nx

nx_hmac_drbg_wasm.nx

buildroot/runtime/nx_hmac_drbg_wasm.nx

17683 B455 linesdepth 0pulls 0 transitivereach 0 importersview sourcekind orphan librarytopic hmac
docsdependenciesstructsconstsfunctions

about

nx_hmac_drbg_wasm.nx -- HMAC-DRBG with SHA-256 per NIST SP 800-90A ยง10.1.2. State: K (32 B), V (32 B). Update(provided_data): K = HMAC(K, V || 0x00 || provided_data) V = HMAC(K, V) if provided_data is empty: return K = HMAC(K, V || 0x01 || provided_data) V = HMAC(K, V) Instantiate(entropy, nonce, personalisation): K = 32 zero bytes V = 32 0x01 bytes Update(entropy || nonce || personalisation) Reseed(entropy, additional_input): Update(entropy || additional_input) Generate(N, additional_input): if additional_input non-empty: Update(additional_input) tmp = "" while len(tmp) < N: V = HMAC(K, V) tmp = tmp || V Update(additional_input) -- this is required even when additional_input was empty return tmp[:N] API for the embedder (each takes a 64-byte state buffer = K || V): nx_drbg_instantiate(state_ptr, entropy_ptr, entropy_len, nonce_ptr, nonce_len, person_ptr, person_len, scratch_ptr) -> i64 nx_drbg_reseed(state_ptr, entropy_ptr, entropy_len, addl_ptr, addl_len, scratch_ptr) -> i64 nx_drbg_generate(state_ptr, out_ptr, out_len, addl_ptr, addl_len, scratch_ptr) -> i64

dependencies 0 imports · 0 importers

imports: none

imported by: nobody (leaf or entry point)

structs

none

consts

54const M32: i64 = 0xFFFFFFFF
55const HMAC_B: i64 = 64

functions

59func _rotr32(x: i64, n: i64) -> i64
called by 1: _sha256_compress
66func _sha256_k(i: i64) -> i64
called by 1: _sha256_compress
102func _blk_word_be(ctx_ptr: *u8, off: i64) -> i64
called by 1: _sha256_compress
110func _h_get(ctx_ptr: *u8, i: i64) -> i64
118func _h_set(ctx_ptr: *u8, i: i64, v: i64) -> i64
127func _sha256_compress(ctx_ptr: *u8) -> i64
198func _sha256_one_shot(in_ptr: *u8, in_len: i64, ctx_ptr: *u8, out_ptr: *u8) -> i64
251func _hmac_sha256(key_ptr: *u8, key_len: i64, msg_ptr: *u8, msg_len: i64,
346func _drbg_update(state: *u8, pdata: *u8, pdata_len: i64, scratch: *u8) -> i64
382func nx_drbg_instantiate(state: *u8,
calls 1: _drbg_update
410func nx_drbg_reseed(state: *u8,
calls 1: _drbg_update
431func nx_drbg_generate(state: *u8, out_ptr: *u8, out_len: i64,