notes

Credentials

Scope note, 2026-08-30. This service held two kinds of secret until that day: a password verifier and an NTLM key. The NTLM half was removed with the SMB implementation that was its only consumer (notes/smb.md), so what ships now is the password verifier alone: provision::PUT, provision::SEAL, verify::VERIFY, and a reply that is one word carrying no data. Everything below that describes put_ntlm, ntlm_proof, PUT_NTLM, NTLM_PROOF or a SessionBaseKey is history; notes/ntlm.md carries that half's own record and the reason its removal is worth reading about.

An identity, a secret, and a way to check the second against the first without ever being able to read it. Milestone 56's second half; the first half is entropy, and this depends on it for every salt it uses.

The contract is crates/credential_contract, the logic is crates/credentialer, the service is components/src/credentialer.rs, and its clients are fixtures/src/credentialer_test_client.rs.

Milestone 65 (a secrets service) generalized this process in place (NTLM). The milestone's rule was that the credentialer becomes an operation in the secrets service, because a second process holding secrets is what the design exists to avoid. Where this file says "the credential service", read "the secrets service". The phases, the seal and the wipe are exactly as described.

The problem this exists to solve

Milestone 55 wants a Mac to authenticate against an SMB share. SMB requires an identity and a secret; this system had neither, and had no cryptography at all. Adding "a password file" is the obvious move and it is the one that gives away the property this kernel is for.

The tension is the interesting part of the milestone:

A secret is a bearer token. A capability is an unforgeable reference. 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.

So the answer is not to protect the file better. It is to hand out the operation, not the secret. A client gets an endpoint that means "you may ask whether a secret is right". It never gets the secret, the salt, the tag, or the list of who exists.

This is the fifth appearance of one idea, and the roadmap gives it its name: attenuation by operation, not by object.

milestone the object the attenuated power
51 the wall clock an NTP client may propose a time, not set it
51 (§43) the clock page read is a read-only mapping, set is a writable one
56 the virtio-rng obtain bytes, without reaching the device
56 the credential store use a credential, without reading it
56 the credential store write it, only during a phase that ends
65 an NTLM key compute a proof with it, without reading it

The shape

   the provisioner ──the provision endpoint──►┌────────────┐
   (once, at boot)      (PUT, then SEAL)      │ credential │──►the entropy service
                                              │  service   │   (salts; an endpoint
   a client ────────the verify endpoint──────►└────────────┘    that names no device)
                    (VERIFY, forever)            the store lives here and nowhere else

Two endpoints. Two phases. The second phase never ends and the first one never comes back.

  1. Provision. The service blocks on the provision endpoint. Each PUT derives a record with a salt drawn from the entropy service. SEAL ends the phase.
  2. Delete. The service capability_deletes its receive end. The provisioner drops its send end. Between them, nothing in the system can name the object any more.
  3. Serve. The service blocks on the verify endpoint, forever. One opcode, VERIFY, and the answer is yes or no. (Between milestone 65 and 2026-08-30 there were two, and an NTLM yes carried a session key in the shared page.)

Why two phases and not two operations

Because this kernel has one wait point. There is no wait-any primitive and no threads inside one address space, so a process can block on exactly one endpoint. components/src/clock.rs records the same constraint and answers it differently: the clock's wide authority (set) is a page write rather than a message, so the service only ever serves the narrow one.

A credential store cannot copy that, because "write the store" is not a memory operation you can hand out as a mapping. But it does not need to: writing the store is not an operation at all, it is a phase. Provisioning happens once, before any client exists, and then it is over. Making that a phase rather than a privileged opcode is what turns "the service refuses to let you write" into "there is no object through which the request could travel".

A client is not refused permission. By the time a client holds anything, PUT is a word arriving at a loop that implements one opcode, and the endpoint that gave the word meaning has been destroyed.

Compare Samba: smbd opens the password database directly, so compromising it leaks every hash, crackable offline and reusable wherever the password was reused. Here a compromised client can guess passwords while it runs and cannot exfiltrate one, and revoking its endpoint ends the access.

Argon2id, and why we depend rather than write

DECISIONS §46 (thin primitives or whole subsystems) draws the line at exposure: write the thing whose correctness you can argue from the spec, and depend on the thing whose correctness is won by many people checking it over many years. A password KDF is the second kind, so this depends on RustCrypto's argon2 0.5.3 (not a vendored copy, so cargo-deny and cargo-audit can see it). Argon2id is RFC 9106's recommendation and OWASP's first choice.

The argument, the vectors, the bug and the measurements are in credentials/argon2id.md.

Three things a naive verifier gets wrong

  1. The tag comparison is constant-time (subtle::ConstantTimeEq). A verifier that returned on the first differing byte lets an attacker recover the tag one byte at a time.
  2. The identity lookup is constant-time too, and does not stop at the match. Store::select scans every slot, conditionally assigns with ConditionallySelectable, and has no early exit. A scan that short-circuited would leak which identities exist, which is the same oracle by a slower route.
  3. A miss costs one full derivation. An identity nobody provisioned lands on a decoy record whose salt and tag come from the entropy service at start-up, and the KDF runs against it. Without that, "no such user" returns in microseconds and "wrong password" returns in milliseconds, and the store's membership is readable with a stopwatch.

A miss and a wrong password are also the same reply code (MISMATCH). Distinguishing them would turn the verify endpoint into an identity oracle: ask about a thousand names, learn which three exist.

How the constant-time claim is checked

Mostly structurally, and deliberately so. Store::select is branch-free, and a unit test pins its behavior at every slot position and on a miss: the decoy's salt, the decoy's tag, the store's cost, found = 0. That is a deterministic test of the thing that matters.

There is also one timing test, and it is written to be robust rather than precise: 25 runs of each kind, compare the medians, and fail outside a 0.4x–2.5x band. A machine under load inflates both medians together, so the ratio is stable even when the numbers are not. The bug it exists to catch is not subtle: an early exit on "no such identity" skips the whole KDF, which is a ratio near zero. If it ever fails at 0.6, suspect the machine before the code, and re-run it quiet.

The reply carries no data

Every reply is one word, and the second word is always zero. Not as a convention a future opcode might relax: there is nothing about a credential store a caller is entitled to, so the reply channel has no room for it. A service that answered a verify with the stored tag would be a decryption oracle wearing a verifier's clothes, and the shape of the contract makes that a change to the contract rather than a bug in a serve loop.

The reply codes are all small positives (1..=6), which is the trick entropy_contract established: every failure the kernel can return from a CALL is one of its small negatives, which read as enormous u64s. So credential_contract::is_authenticated can collapse "there is no credential service", "the request was malformed", "the service died" and "wrong password" into one false, and no caller has to remember which of six codes were the good ones. A caller that mistook a missing capability for a successful authentication would be the single worst bug this contract could permit, so it is the one made impossible by arithmetic rather than by care.

The shared page, and what is left in it

Bulk rides in a page (DECISIONS §10) because an identity and a passphrase do not fit in two registers. Two frames, never one: the provisioner writes plaintext secrets into its page, and a client sharing that frame would read them.

The service zeroes the request area after reading every request, on every path, including the malformed ones. So after an answer, the frame the client and the service share holds neither the presented secret nor anything else. The wipe uses write_volatile and a compiler fence, because a compiler that can prove nobody reads those bytes again is entitled to delete a plain store, and "the optimizer removed the wipe" is the classic way a zeroing loop turns into a comment.

EXAMPLES

Provision three identities and seal the store

From a provisioner holding the provision endpoint in slot 0 and its page mapped:

use credential_contract as proto;

let page = /* the mapped provision page, 4096 bytes */;
for (identity, secret) in [
    (&b"alice"[..], &b"correct horse battery staple"[..]),
    (b"bob", b"a different secret entirely"),
    (b"carol", b"and a third one"),
] {
    let w0 = proto::place(page, identity, secret, proto::provision::PUT).unwrap();
    let (r0, _) = call(SERVICE, w0, 0);
    assert_eq!(r0, proto::OK);
}

// After this the provision endpoint is dead at both ends.
let w0 = proto::place(page, b"seal", b"seal", proto::provision::SEAL).unwrap();
let (r0, _) = call(SERVICE, w0, 0);
assert_eq!(r0, proto::OK);

Authenticate a client

From anything holding the verify endpoint in slot 0:

let w0 = proto::place(page, b"alice", presented, proto::verify::VERIFY).unwrap();
let (r0, _) = call(SERVICE, w0, 0);
if proto::is_authenticated(r0) {
    // let them in
}

is_authenticated is the whole client-side API. There is no way to ask "does this identity exist", "what is the salt", or "how many identities are there", because there is no message that would answer.

Check a secret without a service (host, in a test)

use credentialer::{Block, Cost, Store, Verdict};

let cost = Cost::new(256, 2, 1).unwrap();          // cheap, for a test
let mut scratch = vec![Block::default(); cost.blocks()];
let mut store = Store::<3>::new(cost, decoy_salt, decoy_tag);
store.put(b"alice", b"correct horse", salt, &mut scratch).unwrap();

assert_eq!(store.verify(b"alice", b"correct horse", &mut scratch).unwrap(), Verdict::Match);
assert_eq!(store.verify(b"alice", b"wrong",         &mut scratch).unwrap(), Verdict::Mismatch);
assert_eq!(store.verify(b"nobody", b"correct horse", &mut scratch).unwrap(), Verdict::Mismatch);

There is no store.get(), no store.record_for(), no iterator. The absence is the API expressing what the process boundary enforces.

What is proven, and where

Host tests (cargo test -p credentialer -p credential_contract) pin the known-answer vectors, right and wrong secrets, every single-byte corruption of a record, a hostile cost, and the decoy lookup at every slot. Three Kani harnesses over credential_contract prove that no request word makes the parse read outside the page and that nothing but MATCH authenticates, over all 2^64 words. Guest tests on aarch64 and riscv64 show provisioning sealing, a client with one endpoint getting right answers, the same endowment unable to write the store, the service surviving it, and the shared frame left all zero. Each test and what it pins is listed in credentials/what-is-proven.md.

BUGS