56. Secrets, credentials, and the entropy to make them safe
In brief. Milestone 55 needs the Mac to authenticate. So it needs an identity, a secret, and unguessable challenges. We had none of the three, and one of the gaps was a hard blocker rather than a gap. Prerequisite for 55; feeds milestone 49 (users, login, and attribution). calef's existing setup serves three family members with separate passwords. So the credential service holds multiple identities from the start rather than growing into that later.
Status: both halves built (entropy 2026-07-30, credentials 2026-07-31). All three gaps are closed. Unguessable bits come from a virtio-rng behind a capability. An identity plus a secret you can check and cannot read is a service with five kernel tests on both ISAs. What remains is the SMB-specific derivation (the NT hash and HMAC-MD5, so the service can answer a challenge without the adapter seeing the hash). It is described at the end of this entry.
The entropy half: BUILT, 2026-07-30 (DECISIONS §44, notes/entropy.md)
A splitmix64 stream seeded from the virtual counter is predictable to anyone who can guess boot-relative time. It blocks SMB authentication outright: an NTLMv2 server challenge that is guessable is precomputable. So the RNG is a device behind a service, not a patched counter.
What shipped: a virtio-rng driver over both transports (mmio and PCIe, the seam of §18 (the PCIe
transport), one binary). It
is inside an entropy service that is the only thing in the system that can read the device. Clients
hold one endpoint that means "you may obtain randomness" and names no device. That is the fourth
appearance of attenuation by operation rather than by object. The service passes the device's bytes
through and computes nothing. Whitening without a one-way function is a reversible
permutation that obscures the claim rather than strengthening it. The fork is settled: std::random
improves transparently, split on std's own seam. SystemRng (which promises cryptographic
strength) panics when the capability is absent while HashMap's seed degrades to the counter-seeded
stream and says so. Proven on aarch64 and riscv64, over both buses, plus a std program drawing
through the PAL.
What it does not promise: under QEMU the device is backed by the host's /dev/urandom. That is
a fact about the emulator. On real silicon the StarFive JH7110's TRNG is the candidate and needs
verifying before it is relied on. There is no health test, so a device that started returning a
constant would be passed straight through. notes/entropy.md carries the full list.
The credential half: BUILT, 2026-07-31 (notes/credentials.md)
crates/credentialer (Argon2id, the store, constant-time verification), crates/credential_proto (the
wire contract), components/src/credentialer.rs (the service), fixtures/src/credentialer_test_client.rs (its provisioner,
client, and attacker). Five kernel tests on both ISAs, 26 host tests, three Kani harnesses.
The bearer-token problem below is answered, and the answer is sharper than "hand out the
operation". Writing the store is not an operation at all, it is a phase. The service serves a
provision endpoint until SEAL, then deletes its receive end while the provisioner drops its send
end. Nothing in the system can name the object afterwards. So a client is not refused permission to
write the store; there is no object through which the request could travel. That shape was forced by
a real constraint (this kernel has one wait point, so a process serves one endpoint). It turned out
to be better than the guarded-opcode design it replaced.
Argon2id, as a dependency, from RustCrypto. (The amendment to §46 (thin primitives or whole
subsystems): depend, do not vendor. A vendored copy
is invisible to cargo-deny, and crypto is what most needs to be visible to it.) RFC 9106's and the
reference implementation's known-answer vectors run against the version we link. That is the whole
point of depending. The exhaustive record-corruption test found a debug-build overflow
panic inside argon2 0.5.3: Params::new multiplies p_cost * 8 before range-checking p_cost, so
Cost::new enforces the bounds before the value crosses the boundary.
Honest gaps, in full in notes/credentials.md. The cost parameters are below OWASP's (4 MiB rather than 19, because the whole machine is 128 MiB of QEMU RAM). Nothing survives a reboot. One verify page means one client. There is no rate limit or lockout. And the one that matters for milestone 55, below.
The thing we still do not have
There is no crypto in the tree at all. There is now: RustCrypto's argon2, blake2 and
subtle, via the credential half above. There is also the precedent for how a crypto dependency enters (a
deny.toml-clean graph and the specification's own test vectors as tests). What remains is the SMB
side, and it is unchanged in substance. NTLMv2 needs MD4 (the NT hash) and HMAC-MD5. SMB3 signing
needs AES-CMAC. Encryption needs AES-CCM or GCM. SMB 3.1.1 preauth integrity needs SHA-512.
The credential service cannot serve NTLMv2 yet, and this is the next piece rather than a detail. NTLMv2's challenge-response requires the server to hold the NT hash and compute HMAC-MD5 over it. An Argon2id tag cannot produce that, because the two are different functions of the same password. So the store needs a second derivation and the service a second operation ("here is a challenge, give me the response"). That is exactly the use-not-read shape already built, and not code that exists. It also means shipping MD4 and MD5 on purpose. The credential primitive and the SMB compatibility layer are separable, and only one of them requires choosing to ship a broken hash. That is why the split fell here.
Identity lives at the boundary, and stops there
Milestone 49 records that identity is not authority here. SMB requires an identity, and the two reconcile without compromise. The adapter authenticates the client because the protocol demands it, then uses the directory capability it already holds. Identity never becomes ambient authority inside the system. That is 49's login model exactly: authentication produces or permits the use of capabilities rather than setting a field.
The consequence is worth stating plainly because it is the security claim. Compromise the SMB adapter and you get the share it holds. You do not get "authenticated as user X" with powers elsewhere, because there is no elsewhere and no user X.
The hard part: a secret is a bearer token, a capability is an unforgeable reference
This is the genuinely new problem and it is a real tension in the model. Once a component can read a password hash it holds it forever and can copy it anywhere; knowledge cannot be revoked. Every other authority in this system can be.
The answer is to hand out the operation, not the secret. A credential service holds the NT hash and computes the HMAC on request. The adapter sends a challenge and receives a response, and never sees the hash. So the adapter holds a capability to use a credential, not to read one.
That is an improvement over the reference implementation rather than a reframing of it. In Samba,
smbd reads the password database directly, so compromising it leaks every hash: crackable offline,
reusable wherever the password was reused. Here a compromised adapter can use the credential while it
runs and cannot exfiltrate it, and revoking the capability ends the access.
This is the third appearance of one pattern, and it should be named as a principle rather than
rediscovered a fourth time. There is the NTP client that may propose a time but not set it
(milestone 51 (wall-clock time, the date command)), and the clock's read / set / propose ladder
(§43 (reading the clock is a page)). Now there is use-but-not-read.
Attenuation by operation,
not by object.
Built 2026-07-31, and the answer went one step further than this entry expected. "Hand out the operation, not the secret" is right for reading, and it is what the verify endpoint is. But writing the store turned out not to need an attenuated operation at all. It is a phase, and the phase ends. The provision endpoint is deleted at both ends at the seal, so there is no narrow write operation to hand out and no wide one to withhold. The forcing constraint was that this kernel has one wait point per process. That is the same wall the clock service hit (§43) and answered differently. The answer here is better, because "the object no longer exists" is a stronger claim than "the service checks". See notes/credentials.md.
Decisions to make before building
- Take the crypto as a dependency, do not write it and do not vendor it (§46, amended
2026-07-31). Vendoring is for what must be patched, and RustCrypto needs no patch. A vendored copy
is also invisible to
cargo-deny/cargo-audit, which is the one thing crypto most needs. Its crates areno_stdand reviewed, and the supply-chain tooling from milestone 44, namelydeny.toml,script/supply-chainandscript/vendor-verify, already exists for exactly this shape. Writing our own AES or SHA is a bad idea and the entry should say so rather than leaving it open. Done for the KDF, 2026-07-31:argon20.5.3 plusblake2,subtleandzeroize,default-features = false, nine crates,deny.tomlclean unchanged. A discipline came with it that should hold for the SMB primitives too. The specification's own test vectors are tests, because a dependency whose answers are never checked is one we have merely hoped about. The bounds get re-checked at our boundary, because argon2'sParams::newpanics in a debug build on a largep_costand a service a cost value can kill is a login outage. - We will be shipping known-broken primitives on purpose. MD4 and MD5 are required by NTLMv2 for wire compatibility. Record that as a deliberate compatibility cost with its blast radius stated, not as an oversight. Keep them out of anything that is not SMB.
- Secrets at rest are unsolved and should be scoped small. Where does the hash live across
reboots, and encrypted under what key? That is the same chicken-and-egg as milestone 51's NTS
problem (certificates need time, time needs the network). The honest v1 is provisioned at boot and
held only in memory; say so plainly rather than implying durability we do not have. Still
unsolved, and scoped exactly that small 2026-07-31: the store is memory only and dies with the
process.
credentialer::Recordhas a versioned encoding with a round-trip test so the question has a starting point, and nothing writes one to a disk. - Entropy is a capability, and the service that holds it is the only thing that reads the device.
std::randomis transparent (DECISIONS §44), split on std's ownfill_bytes/hashmap_random_keysseam. The caller that promises cryptographic strength refuses rather than degrading. The service passes bytes through and does not pool or whiten.
Sequencing. Before milestone 55 (Time Machine). Both halves are done: entropy, and the credential store and its service. Each was worth doing on its own, and each was testable in QEMU with no board.
What is left of this milestone is the SMB-facing derivation. It is the NT hash, HMAC-MD5, and a second service operation that computes a challenge response without the adapter ever seeing the hash. That is the use-not-read pattern already built, applied to a second secret. It is the first place this project chooses to ship a known-broken primitive. Secrets at rest remains unanswered and is not on milestone 55's critical path. That is because provisioning at boot is enough to authenticate a Mac.
Follow-on
- Milestone 65. The SMB-facing derivation this block names as what is left belongs to milestone 65 (a secrets service). It is the NT hash, HMAC-MD5, and a second service operation that answers a challenge without the adapter ever seeing the hash. It carries the deliberate cost of shipping MD4 and MD5, kept out of everything that is not SMB.
- Milestone 159. Verifying the StarFive JH7110's TRNG before anything relies on it. Under QEMU
the device is the host's
/dev/urandom, which is a fact about the emulator rather than about hardware entropy. This block says the real part needs checking first. - Decision.
design/decisions/0137-trng-health-tests.md: whether nife runs its own health tests on hardware entropy, and what it does when one fails. This block records that there is no health test, so a device that started returning a constant would be passed straight through. - Recorded.
notes/credentials.md: the Argon2id cost parameters are below OWASP's, 4 MiB rather than 19, because the whole machine is 128 MiB of QEMU RAM. - Recorded.
notes/credentials.md: nothing in the credential store survives a reboot, and secrets at rest are unanswered. Scoped exactly that small on purpose.credentialer::Recordhas a versioned encoding with a round-trip test so the question has a starting point, and nothing writes one to a disk. - Recorded.
notes/credentials.md: one verify page means one client, and there is no rate limit or lockout on the verify endpoint.
Index row
built 2026-08-01. Entropy (§44 (entropy is a capability, std::random improves transparently)), the
Argon2id crypto taken as a dependency per §46, and the
credentialer, a store with no getter that verifies and never reads back (§54). The thesis-level
gap it named, that a secret is still a bearer token where a capability is an unforgeable
reference, is milestone 65's subject. Hold the key, expose the operation