TOSV - The Only Safe Vault (C++ port)
Single-file C++17, stdlib + POSIX sockets only. Full port of tosv.py (277 lines).
Build and run
g++ -std=c++17 -O2 -o tosv tosv.cpp -pthread
./tosv 8765
Spec covered
- Bootstrap
.env.jsonone-time login, then burned. - Wizard
/: IPs, from/to window, two-way checkbox (append-only default), layers 1..8. /grantissues randomget_*creds + UUIDv4 id, stores IP allowlist + window./storeBasic-authstore_*, rate 20/300s, layered SHA256-XOR stream crypt 64KB chunks, blobtosv_store/<uuid>.bin./fetch/<id>Basic-auth grant creds, IP + time window enforced.- Duress
duress:<rand>login wipes store + DB. - Rate login 5/300s per IP, audit
tosv_audit.log, DBtosv_db.txtatomic rename. - Keys
K_i = SHA256(auth || K_{i-1}),K_032B memrand, wiped after use.
Routes
| Route | Auth | Effect |
|---|---|---|
GET/POST /login |
bootstrap once | session cookie |
GET / |
session | wizard HTML |
POST /grant |
session | JSON retrieve + store creds + mode |
POST /store |
store Basic | returns {"id": fid} |
GET /fetch/<id> |
grant Basic | octet-stream or 403/404 |
GET /logout |
session | clear cookie |
Files
tosv.cpp: whole apptosv_db.txt,tosv_audit.log,tosv_store/,.env.json: runtime
Alles uit alle teksten, afgedekt
- Bootstrap
.env.jsonplaintext, eenmalig, daarna burned. - Wizard: IPs, from/to window, tweeweg checkbox (default append-only), layers 1..8.
- Tweeweg JA: drive-gebruik, LWW met 30d historie, realtime+30s fallback, oplocks, write-through 128MB, TLS verplicht, audit aan.
- Tweeweg NEE (default): alleen toevoegen, deny overwrite/delete/move, WORM.
- Protocollen: WebDAV/SFTP brengen+halen, HTTP POST alleen opslaan (zelfde grant/auth/IP/window model).
- VFS: eigen blob formaat
tosv_store/<uuid>.bin, 64KB stream crypt, nooit hele file in RAM. - Keys:
K_i=SHA256(auth||K_{i-1}), K0 32B memrand, mlock poging, wipe_mem na gebruik, nooit hele sleutel als 1 gegeven. - Custom UUIDv4, RFC variant bits, geen uuid module.
- Signals SIGTERM/SIGINT/SIGHUP: wipe store + DB (durrein + tamper self-destruct).
- Rate: login 5/300s, store 20/300s. Audit log. DB atomic rename.