nx_hkdf_sha256_wasm.nx
buildroot/runtime/nx_hkdf_sha256_wasm.nx
about
nx_hkdf_sha256_wasm.nx -- HKDF-SHA-256 (RFC 5869) for WAT target.
HKDF = Extract + Expand built on HMAC-SHA-256.
PRK = HKDF-Extract(salt, IKM) = HMAC(salt, IKM)
OKM = HKDF-Expand(PRK, info, L)
T(1) = HMAC(PRK, info || 0x01)
T(i) = HMAC(PRK, T(i-1) || info || i)
OKM = first L bytes of T(1) || T(2) || ...
API for the embedder:
nx_hkdf_extract(salt_ptr, salt_len, ikm_ptr, ikm_len,
scratch_ptr, prk_out_ptr) -> i64
prk_out_ptr -- 32 bytes
scratch_ptr -- 1024 bytes
nx_hkdf_expand(prk_ptr, info_ptr, info_len, okm_len,
scratch_ptr, okm_out_ptr) -> i64
prk_ptr -- 32 bytes (PRK from extract)
okm_out_ptr -- okm_len bytes
scratch_ptr -- 2048 bytes
okm_len -- must be <= 8160 (= 255 * 32)
nx_hkdf_extract_and_expand(salt, salt_len, ikm, ikm_len,
info, info_len, okm_len,
scratch, okm_out) -> i64
One-shot convenience that does both at once.
Verified against RFC 5869 §A.1, §A.2 test vectors -- see
AppData/Local/Temp/hkdf_smoke.js.
license_tier: INDEPENDENT_REDERIVE
genealogy_id: international-research-sources/ietf/rfc_5869 +
ietf/rfc_2104
lineage_id: nishi_hkdf_sha256_wasm_q11
dependencies 0 imports · 0 importers
imports: none
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 37 | const M32: i64 = 0xFFFFFFFF |
| 38 | const HMAC_B: i64 = 64 |
functions
| 44 | func _rotr32(x: i64, n: i64) -> i64 called by 1: _sha256_compress |
| 51 | func _sha256_k(i: i64) -> i64 called by 1: _sha256_compress |
| 87 | func _blk_word_be(ctx_ptr: *u8, off: i64) -> i64 called by 1: _sha256_compress |
| 95 | func _h_get(ctx_ptr: *u8, i: i64) -> i64 |
| 103 | func _h_set(ctx_ptr: *u8, i: i64, v: i64) -> i64 |
| 112 | func _sha256_compress(ctx_ptr: *u8) -> i64 |
| 183 | func _sha256_one_shot(in_ptr: *u8, in_len: i64, ctx_ptr: *u8, out_ptr: *u8) -> i64 |
| 249 | func _hmac_sha256(key_ptr: *u8, key_len: i64, msg_ptr: *u8, msg_len: i64, |
| 334 | func nx_hkdf_extract(salt_ptr: *u8, salt_len: i64, |
| 359 | func nx_hkdf_expand(prk_ptr: *u8, info_ptr: *u8, info_len: i64, |
| 406 | func nx_hkdf_extract_and_expand( |