Artifact ff91eb55196d91adc4b5f39b3c56aa41a17738de6b509cead47b93b5f426bdd0:
- File docs/design/key-sources.md — part of check-in [07c6b1441d] at 2026-11-23 13:42:13 on branch keysource — Key sources: the platform names its sources; cred.c names none of the host's (user: dmestas, size: 3334) [annotate] [blame] [check-ins using] [more...]
Where the credential store's key comes from
Status: built 2026-11-23 (owner's choice: options A and C, with E's sources that need no terminal).
Tier: core (cred.c: the recorded source, pic_cred_quiet, pic_cred_rekey, the offer) over the
platform seam (platform.h: secret_key, secret_keep, secret_drop); the host's sources live in
platform.c alone. Clock: os (the security and secret-tool command lines, tmutil). Record:
picu_credential_key.source (keychain, file or passphrase; a raw key's kdf is none), the
setting cred.offer. Default: a new store's random key in the login Keychain (or keyring), else
~/.pic/master.key; a passphrase only when chosen.
The threat model
A copied pic.sqlite, a backup or an exported journal on its own reveals nothing. Malware or a
person acting in the user's unlocked session can read the key, as with the keys other tools keep.
So a passphrase stops being the default: it guarded against the second case at the cost of a prompt
in every process, and against the first case no better than a key kept apart from the database.
Decisions
- The sealing (ChaCha20-Poly1305 under a 32-byte master key, the verifier) is unchanged; only where the master key comes from changes, with no stretching for a raw key.
- The keystore runs as a child process (
/usr/bin/security -i, the command on its stdin;secret-tool store, the secret on its stdin), so the key is never in argv and pic links no framework. A keep is read back before it counts, since a locked Keychain can seem to take one. - The keystore is used only for the store under the account's own home directory; any other
HOMEgets the key file. Tests run under a privateHOME, so a test that forgets the stand-in (PIC_TEST_KEYCHAIN) still cannot reach the real Keychain. - A rekey reseals every sealed row (credentials, remote control's keys and devices) in one transaction; the old source is cleared only after the commit, and a new source that the commit did not take is cleared again. A row that did not open under the old key is left as it was.
- Every target stays fully featured.
cred.ctreats every source butpassphraseas an opaque name the platform gave, so a platform adds a key source in its ownsecret_key,secret_keepandsecret_dropwithout touchingcred.c;secret_keep(NULL)is its choice for a new store andsecret_keep("")its choice of a source that keeps a key (the offer's yes). On a host the key file is the portable source, working on any POSIX system; the Keychain or Secret Service is an improvement taken when present. - A platform with no filesystem keeps the "file" key as a blob in a SQLite key database of its
own beside
pic.sqlite, through its VFS, attached only to read the key, so a copiedpic.sqliteor backup still reveals nothing. Only a platform that has a single database and nothing else may put the key inpic.sqliteitself, and then a copied database opens: that platform loses the copied-database protection, and its documentation must say so. - An OS-free build that holds a fixed boot key has
secret_keepname that source and keep nothing;cred.cthen fetches it. pic remoteopens a keychain or file store with no prompt, whichpic remote install(a login agent) will rely on.