Three things, found while chasing two intermittent failures that turned out
to be the test harness tapping the app.
`ensureLabelKey` put the request label back with
`defer { Task { await api.setLabel(previous) } }`, which reads like a
restore and is not one: the task is detached, so the label goes back at
some later moment of the runtime's choosing. Until then every request
carries the wrong area, and when it lands it can undo a label some other
call has since set. Android and the browser both restore synchronously in
a `finally` — only this port drifted. The label is now not moved at all:
storing a grant carries its own label for that one request, so anything in
flight alongside it still goes out under the area the caller is in.
`currentLabelKey` threw `notCleared` — "You aren't cleared for this" — when
the truth was that this device has not minted a key for the area yet, which
is every account before its first write. In a system built on clearance,
telling a properly cleared newcomer they are not cleared is both wrong and
alarming. It now says what is true and what to do about it.
A folder whose name will not decrypt is now checked the same way a file is.
Opening one navigated into somebody else's folder and then complained about
a missing key, which is a confusing way to say "this is not yours" — and
the file branch has always checked.
Also translates CryptoKit's authentication failures, which reached people
as "(CryptoKit.CryptoKitError error 3.)".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Three bugs, all of which only appear the second time somebody needs the
account.
The passphrase field was `.textContentType(.newPassword)`, which invites
iOS to generate and insert a strong password. Accounts created through
this screen could then not be signed into with the passphrase that had
been typed into them — verified both ways with filesctl. Nothing looks
wrong at the time, because the app signs in with the same value it
registered with; it comes apart at the next sign-in. For a passphrase that
derives the keys and cannot be reset, a secret the person never read
leaves them with a recovery code as their only way back.
Recovery minted the replacement code twice — one for the account service,
a different one wrapped into the identity record and shown on screen. The
first recovery looked perfect and left the account openable only with a
code nobody had ever seen. One code now reaches both writes.
`EngineError` did not conform to `LocalizedError`, so a mistyped recovery
code reached the person who had just lost their passphrase as "The
operation couldn't be completed. (FilesEngine.EngineError error 1.)". The
reasons were always sentences at the throw site; now they survive.
Also: the recovery code is laid out four groups to a line so a group never
wraps in the middle — this is copied onto paper by hand, once — the
recovery screen scrolls so its only exit cannot sit off screen, and rows
this device can read come before the ones it cannot, so a new account does
not arrive at a screenful of "Encrypted for another key".
The UI suites are new: registration, sign-in, recovering (twice, which is
what catches the above), folders, upload, share links with the secret
asserted to be in the fragment, and a visual tour that photographs each
screen — the recovery code wrapping was found by looking, not by asserting.
⚠️ ProductionTourTests no longer carries a live credential for the
deployment. It was committed in plain text to a public repository, so the
account it belonged to has to be treated as compromised and its passphrase
changed; removing it here stops the leak continuing, it does not undo it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The default was the clearance maximum, which is usually the wrong choice
for this command: the recipient has to be cleared for the same area, and
the reason to hand one over is often to meet somebody lower down. Sharing
with an account cleared one level below returned a bare "Not found" and no
way to aim lower.
Until now every account was an island: two people cleared for the same
label could see each other's rows and decrypt none of them, because each
had minted its own key for that label on first use. That is the first
thing a two-person test hits.
The key is wrapped to the recipient's public key on this device. The
server stores a blob it cannot open and never sees the label key, which is
why this cannot be an administrative action performed on somebody's
behalf — it has to happen where the key already is.
The recipient is resolved by handle rather than by id. An "is this person
cleared?" endpoint keyed by id is a membership oracle, and who else holds
a compartment is exactly what the file server's read policy refuses to
disclose; keyed by handle, every kind of no returns the same answer.
The sheet says "give them the key" rather than "share", because that is
what it does: durable read access to everything filed at the label, now
and in future, and there is no revocation yet. A delete button would imply
otherwise.
The web client defaults its picker to the clearance maximum; both apps
were defaulting to the minimum, and the difference is not cosmetic.
The error is asymmetric. Start low and a sensitive file lands in the open
area because nobody touched a picker — and once it has been read, that
cannot be undone. Start high and everything is over-classified, which is
irritating and reversible.
The server's default is the opposite, for the opposite reason: a request
that arrives without a label header should get the least privilege it
could have asked for, never the most. Both defaults are deliberate and
they are not in conflict.
Sign in, register with a recovery code shown once, browse, switch area,
upload, download through a share sheet, and create password-protected
links. All of it sits on FilesClient, which filesctl already exercises end
to end against both a self-hosted stack and files.flamenet.io.
The area banner is always on screen rather than tucked into a menu. Which
area you are working in decides where a new file lands and who can ever
read it, and finding that out afterwards is too late. Rows this session
cannot decrypt are shown, and say so — hiding them would be a lie about
what the server knows.
The project file is generated by XcodeGen and not committed, so it cannot
become a merge hazard.
UI tests drive the real app, which is how the first real bug here was
found: the mode picker and the submit button carry the same three words,
so matching on the visible label tapped the picker and the form never
submitted. Both are addressed by identifier now, which VoiceOver benefits
from as much as the tests do.
Everything between the engine and an app: server discovery, the account
service, the file API, and a session that ties them together.
Recovery codes and share links move into the engine, and both agree with
the browser character for character — the vectors file now carries codes
generated by the JavaScript implementation, including one containing a Q,
because folding Q is the mistake that once corrupted a third of all codes.
`filesctl` exists so the cryptography can be exercised without an app, a
simulator, or a person tapping. `smoke` registers, signs in fresh so the
stored record has to actually open, uploads across four chunks, reads the
name back, compares bytes, and checks a password-protected link is refused
without its password. Verified against the Android engine as well: one
uploads, the other downloads, and the digests match.
Registration now sends the identity with the account rather than after it,
and a session with no identity for this product enrols one instead of
refusing — which is what an account created before Files existed needs.
MIT, matching the server. CI runs the suite on a Linux Swift image, which
is the point of keeping the crypto in a package rather than in app code.
Implements the published specification in CryptoKit: the lattice and its
canonical encoding, two-stage key derivation, the key hierarchy, keyed filename
digests, and chunked content encryption with truncation and reorder resistance.
Built as a Swift package rather than app code so `swift test` runs from the
command line. Requiring Xcode to run the crypto tests would mean they get run
rarely, and this is the part that must not be wrong.
The suite is interop, not self-consistency: nine tests decrypt material produced
by the JavaScript reference implementation, including an identity record written
in a browser, the whole key hierarchy beneath it, a filename, and file content.
A framing, authenticated-data or hierarchy mistake fails there.
Two interop details the specification needed to spell out. WebCrypto exports an
X25519 private key as PKCS#8 while CryptoKit uses raw form, so a browser-written
record is unreadable here without conversion. And PBKDF2 comes from
CommonCrypto, because CryptoKit has no password-based KDF.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>