code wiki / bin / nx_vault.nx

nx_vault.nx

buildroot/runtime/bin/nx_vault.nx

12989 B339 linesdepth 8pulls 16 transitivereach 0 importersview sourcekind tooltopic vault
docsdependenciesstructsconstsfunctions

about

nx_vault.nx -- sovereign secrets vault CLI (HashiCorp-Vault-class, bits-up; ZERO third-party dependency). Operator 2026-05-27: "stored like hashicorp vault or something from zero up so you can deploy on the nas easily and powerfully." Composes the substrate's at-rest crypto primitives (nx_password_vault: HKDF-SHA256 key derivation + ChaCha20-Poly1305 AEAD). This file adds the on-disk read/write + the put/get/init/list CLI. SEAL MODEL (auto-unseal, HashiCorp-style): The vault store (NXVLT format) is encrypted at rest under a 32-byte master key derived HKDF(salt, unseal_passphrase). The unseal passphrase lives in a SEPARATE 0600 key file (the "unseal key"). Possession of the encrypted store alone cannot recover secrets. Auto-unseal = the key file is machine-local, so no operator re-entry. THREAT MODEL: disk theft of BOTH files (key + store together) defeats it -- store them on different media for stronger posture, or switch to passphrase-prompt mode (a future flag). USAGE (paths supplied by caller so the binary is $HOME-agnostic): nx_vault init <keypath> <storepath> nx_vault put <keypath> <storepath> <name> <value> nx_vault get <keypath> <storepath> <name> # prints value to stdout nx_vault list <keypath> <storepath> # prints names, one per line File format (big-endian), NXVLT version 1: magic[8]="NXVLT\0\0\1" salt[32] nonce_base[12] n_entries[4] per entry: name_len[2] name[name_len] ct_len[4] ct[ct_len] tag[16] license_tier: ORIGINAL (sovereign; composes RFC 8439 + RFC 5869 prims)

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_csprng.nx nx_password_vault.nx nx_vault.nx

imports: nx_syscalls.nxnx_csprng.nxnx_password_vault.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_write argp v_eq v_strlen cmd_init sys_mmap nx_csprng_fill sys_mmap ↻ nx_csprng_urandom_path sys_openat_rd sys_read sys_close write_file_mode sys_openat_wr sys_write ↻ sys_close ↻ put_magic be_w32 sys_write ↻ cmd_list sys_mmap ↻ sys_read_file sys_openat_rd ↻ sys_lseek sys_mmap ↻ sys_read ↻ sys_close ↻ check_magic be_r32 be_r16 sys_write ↻ cmd_get sys_mmap ↻ sys_read_file ↻ check_magic ↻ v_strlen ↻ find_entry be_r32 ↻ be_r16 ↻

structs

none

consts

37const NXV_HDR_FIXED: i64 = 56 // 8 magic + 32 salt + 12 nonce + 4 n_entries
38const NXV_E_OK: i64 = 0
39const NXV_E_USAGE: i64 = 2
40const NXV_E_NO_KEY: i64 = 3
41const NXV_E_NO_STORE: i64 = 4
42const NXV_E_BAD_MAGIC: i64 = 5
43const NXV_E_NOT_FOUND: i64 = 6
44const NXV_E_DECRYPT: i64 = 7
45const NXV_E_IO: i64 = 8

functions

48func v_strlen(s: *u8) -> i64
called by 3: cmd_getcmd_putmain
54func v_eq(a: *u8, alen: i64, b: *u8, blen: i64) -> i64
called by 2: find_entrymain
65func be_r16(p: *u8, off: i64) -> i64
68func be_r32(p: *u8, off: i64) -> i64
71func be_w16(p: *u8, off: i64, v: i64) -> i64
called by 1: cmd_put
76func be_w32(p: *u8, off: i64, v: i64) -> i64
called by 2: cmd_initcmd_put
84func write_file_mode(path: *u8, buf: *u8, n: i64, mode: i64) -> i64
98func put_magic(p: *u8) -> i64
called by 1: cmd_init
109func check_magic(p: *u8) -> i64
119func derive_master(keypath: *u8, salt: *u8, key_out: *u8) -> i64
131func cmd_init(keypath: *u8, storepath: *u8) -> i64
151func find_entry(buf: *u8, n: i64, name: *u8, nlen: i64, idx_box: *i64) -> i64
called by 2: cmd_getcmd_put calls 3: be_r32be_r16v_eq
171func cmd_get(keypath: *u8, storepath: *u8, name: *u8) -> i64
197func cmd_put(keypath: *u8, storepath: *u8, name: *u8, value: *u8) -> i64
290func cmd_list(keypath: *u8, storepath: *u8) -> i64
310func argp(argv: *i64, i: i64) -> *u8
called by 1: main
314func main(argc: i64, argv: *i64) -> i64