nx_profile_backup.nx
buildroot/runtime/nx_profile_backup.nx
about
nx_profile_backup.nx -- ENCRYPTED second-copy backup of the browser profile store (lib, no main).
Operator 2026-07-02: "have it also create a backup so two is one one is none, on the os encrypted
whether nishi os or windows or android". Blob = ChaCha20-Poly1305 AEAD under a key HKDF-derived from
MACHINE IDENTITY (/etc/machine-id, 128-bit random) + a fresh random 32B salt PER BACKUP (fresh salt =>
fresh key => the (key,nonce) pair is never reused across snapshots -- the AEAD nonce-reuse hazard).
Threat model (same as nx_machine_key/nx_vault): defeats offline theft of the backup file without the
machine; NOT an attacker with local machine access. Destination = OS-level dir OUTSIDE the repo, from
knowledge/hosting/profile_backup.conf (line 1) -- portable across NishiOS/Windows(drvfs)/Android paths.
.nxpb v1 layout: "NXPB1\n"(6) | salt(32) | nonce(12) | ptlen(8 LE) | tag(16) | ct(ptlen).
pb_backup_file WRITES then RE-READS + DECRYPTS + BYTE-COMPARES (a backup that doesn't restore is not
a backup) -- returns 0 only on proven roundtrip. license_tier: ORIGINAL
dependencies 3 imports · 2 importers
imports: nx_syscalls.nxnx_chacha20_poly1305.nxnx_hkdf.nx
imported by: nx_profile_backup_gate.nxnx_profile_backup_run.nx
structs
| none |
consts
| 16 | const K_MAGIC_134217728: i64 = 134217728 |
functions
| 18 | func pb_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 21 | func pb_derive_key(ikm: *u8, ilen: i64, salt: *u8, key_out: *u8) -> i64 |
| 29 | func pb_rand(buf: *u8, n: i64) -> i64 |
| 43 | func pb_machine_ikm(out: *u8, cap: i64) -> i64 |
| 57 | func pb_restore_buf(blobpath: *u8, ikm: *u8, ilen: i64, out: *u8, cap: i64, lenbox: *i64) -> i64 called by 2: pb_backup_filepb_restore_file calls 4: sys_mmapsys_read_filepb_derive_keynx_chacha20_poly1305_decrypt |
| 86 | func pb_backup_file(src: *u8, dst: *u8, ikm: *u8, ilen: i64) -> i64 called by 2: mainmain calls 9: sys_mmapsys_read_filepb_randpb_derive_keynx_chacha20_poly1305_encryptsys_openat_wr+3 |
| 134 | func pb_restore_file(blobpath: *u8, dst: *u8, ikm: *u8, ilen: i64) -> i64 |