nx_vault.nx
buildroot/runtime/bin/nx_vault.nx
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
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
structs
| none |
consts
| 37 | const NXV_HDR_FIXED: i64 = 56 // 8 magic + 32 salt + 12 nonce + 4 n_entries |
| 38 | const NXV_E_OK: i64 = 0 |
| 39 | const NXV_E_USAGE: i64 = 2 |
| 40 | const NXV_E_NO_KEY: i64 = 3 |
| 41 | const NXV_E_NO_STORE: i64 = 4 |
| 42 | const NXV_E_BAD_MAGIC: i64 = 5 |
| 43 | const NXV_E_NOT_FOUND: i64 = 6 |
| 44 | const NXV_E_DECRYPT: i64 = 7 |
| 45 | const NXV_E_IO: i64 = 8 |
functions
| 48 | func v_strlen(s: *u8) -> i64 |
| 54 | func v_eq(a: *u8, alen: i64, b: *u8, blen: i64) -> i64 |
| 65 | func be_r16(p: *u8, off: i64) -> i64 |
| 68 | func be_r32(p: *u8, off: i64) -> i64 |
| 71 | func be_w16(p: *u8, off: i64, v: i64) -> i64 called by 1: cmd_put |
| 76 | func be_w32(p: *u8, off: i64, v: i64) -> i64 |
| 84 | func write_file_mode(path: *u8, buf: *u8, n: i64, mode: i64) -> i64 |
| 98 | func put_magic(p: *u8) -> i64 called by 1: cmd_init |
| 109 | func check_magic(p: *u8) -> i64 |
| 119 | func derive_master(keypath: *u8, salt: *u8, key_out: *u8) -> i64 |
| 131 | func cmd_init(keypath: *u8, storepath: *u8) -> i64 |
| 151 | func find_entry(buf: *u8, n: i64, name: *u8, nlen: i64, idx_box: *i64) -> i64 |
| 171 | func cmd_get(keypath: *u8, storepath: *u8, name: *u8) -> i64 |
| 197 | func cmd_put(keypath: *u8, storepath: *u8, name: *u8, value: *u8) -> i64 |
| 290 | func cmd_list(keypath: *u8, storepath: *u8) -> i64 |
| 310 | func argp(argv: *i64, i: i64) -> *u8 called by 1: main |
| 314 | func main(argc: i64, argv: *i64) -> i64 |