Skip to content

aurora-sep: set up the Touch ID calibration on demand with aurora-touchid-setup - #52

Merged
RyanTheTide merged 4 commits into
mainfrom
aurora-sep/touchid-setup
Oct 30, 2026
Merged

RyanTheTide merged 4 commits into
mainfrom
aurora-sep/touchid-setup

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

This replaces the every-boot prepare-sep-calibration with aurora-touchid-setup, a tool in the aurora-sep package that sets up this Mac's Touch ID files from its own factory data. It runs by itself only when something is wrong, and the owner can run it any time, much like widevine-installer.

What it builds

The sensor's driver loads two per-device files named by the fingerprint node's firmware-name list: the calibration (first entry) and, on sensors with a nonce session, the signed root key (second entry, apple/msrk-j700.bin by default). The tool reads the list the same way, which also fixes the J616s two-name list (#50).

  • J700, J713, J616s. The factory cache holds an FSC2 record. Each file is rebuilt from the factory records on the Hardware volume of the iBoot System Container, read-only, as comb { fdrd: IMG4 { IM4P, [0] seal-<CHIP>-<ECID> }, secb: trust bundle }. The seal must name the running Mac's chip, ECID and serial number and cover the record. The root key is rebuilt the same way from the MSRk record. No macOS is needed.
  • M1, M2. The container holds a comb record, which is installed as carved, as before.

When it runs

  1. A file is missing. aurora-touchid-setup.service runs once at boot, before Touch ID starts. Its ExecCondition only tests that the files it recorded still exist, so a boot with Touch ID in place skips it. The name comes from the device tree and differs per model, so a static ConditionPathExists=! cannot name it; the condition script is a few file tests. The first boot after this update runs the tool once to record what is there.
  2. The enclave refused a file. When the sensor did not attach, aurora-sep-ready looks in this boot's kernel log for a refused LOAD_CALIBRATION or SENSOR_ROOT_KEY (for example status 0x1c or 0x12e), or a missing file. It then runs systemctl start --no-block aurora-touchid-setup.service. The tool replaces the file and the driver loads it again at its own retry about 10 s later, or at the next enrolment or verify. One automatic rebuild per boot: a marker in /run/aurora-sep stops a loop, and a second refusal is only logged. A boot whose sensor attached never reads the log.
  3. The owner runs it. sudo aurora-touchid-setup --check reports and writes nothing. sudo aurora-touchid-setup sets up what is missing. --force-rebuild rebuilds and replaces what differs. --json prints a machine-readable result.

Safety

  • A file the tool did not install is never replaced, unless the enclave refused it this boot or --force-rebuild asks for it (the rule from fedora-aurora#47). The old helper's record and cache count as installed by this tool.
  • Every replacement keeps the old bytes in /var/lib/aurora-sep/rollback. New files are written atomically, mode 0600, and read back.
  • A bare FSC2 image is never installed. A link at the target is moved aside without being followed.
  • The last result is in /var/lib/aurora-sep/touchid-setup.json, with one JSON line per run in touchid-setup.log, and every step is in the journal.
  • SEP trusted keys start either way. Macs without a reader record that once and are never checked again.

The keystore wait from #42 is already on main and unchanged.

NixOS

The kernel's firmware path is on /run here, so the tool keeps the files in /var/lib/aurora-sep/firmware and links each into the firmware path. aurora-sep.service relinks them at each boot through touchid-publish, which only creates links and builds nothing. The unit is systemd.services.aurora-touchid-setup in modules/sep.nix. Bumps the package to 1.8.

A note for Erik

Erik Bourget (erikwb) wrote the part that makes this possible: the narrow checksummed APFS reader, the strict DER walk and the admission against the running Mac's identity, in #27. His commit is the first commit here, with his authorship, applied as he wrote it. The second commit runs his rebuild on demand instead of at every start, extends it to the root key, and leaves out the per-boot readiness marker, since nothing now runs at every boot to write it. The tool's header credits him. Thank you, Erik: this is what lets a Mac get Touch ID without macOS.

Supersedes #27 and #50. Those are left open for review.

Testing

  • tests/test_touchid_setup.py: 45 tests on synthetic APFS images, manifests, records and device trees. Erik's container, manifest, admission and identity tests are kept. New tests cover the firmware-name list, install, --check writing nothing, keeping identical and foreign files, --force-rebuild and refusal replacements with rollback copies, the old helper's records, the bare image, FSCl records, sensorless Macs, unknown identity, links, a failed write, the boot condition script, the once-per-boot trigger, and aurora-sep-ready starting the rebuild only after a refusal.
  • --check on four Macs, read-only, nothing written:
Mac Path Calibration Root key
MacBook Neo (J700) resealed from factory records byte-identical to the working file byte-identical
M4 Pro (J616s) resealed from factory records byte-identical byte-identical
M1 Pro (J316s) carved comb record byte-identical not used
M2 (J413) carved comb record byte-identical not used

Not tested yet: an install on hardware, the boot-time unit and the refusal path on a real refusal. These Macs were read-only for this work. A good first hardware test is the Neo: move mesacal-j700.bin aside, reboot, and check that the unit rebuilds it and Touch ID restores.
No Nix is available on the build host, so nix flake check and the package build were not run locally; CI runs both.

Parity

Fedora Arch NixOS
PR aurora-silicon/fedora-aurora#64 aurora-silicon/alarm-aurora#49 #52
Tool /usr/sbin/aurora-touchid-setup /usr/bin/aurora-touchid-setup aurora-touchid-setup in the system profile
Files /usr/lib/firmware/apple /usr/lib/firmware/apple /var/lib/aurora-sep/firmware, linked into the firmware path on /run

🤖 Generated with Claude Code

erikwb and others added 2 commits October 30, 2026 21:19
The enclave loads a standalone FSC2 calibration (J700, J713) only
resealed with the Mac's own factory records:

  comb { fdrd: IMG4 { IM4P, [0] seal-<CHIP>-<ECID> }, secb: trust bundle }

prepare-sep-calibration cached the carved image by partition identity
and wrote it over that record at every start.

Every start now reads the factory cache read-only from the Hardware
volume of the iBoot System Container, and rebuilds the record from it.
The APFS reader is bounded: the newest checksummed checkpoint, the
object maps, the file-system tree and uncompressed regular files only.
The rebuild takes:
- the FSC2 calibration's IM4P;
- the one seal, which must name the running Mac's CHIP and ECID from
  the boot's local policy manifest, carry its serial number, and list
  the IM4P's SHA-384 as its FSC2 digest;
- the trust bundle whose named copy matches trustobject-current.
IM4M properties are walked as strict DER, with limits on size, depth
and element count.

The installed record is replaced only when it differs. The replacement
is written atomically with mode 0600 and read back, and the old bytes
are kept as private rollback evidence. When the records cannot be
admitted, the bare image is never installed, a wrong-device or
malformed record moves to private quarantine, and Touch ID stays
unready. An FSCl comb record is still installed as carved, checked as
the extractor checks it.

Readiness is a per-boot marker in /run/aurora-sep that names the
admitted digests. aurora-sep-ready.service and fprintd now also require
calibration-ready, which checks the installed bytes against the marker.
SEP trusted keys start either way. These are provenance and structure
checks; the enclave verifies the signatures.

(cherry picked from commit 0986e4c, #27)
[Ryan Murray: applied to the current main with only the helper, calibration-ready
 and the tests, as written; the packaging and module changes are left out
 because the next commit runs the rebuild on demand instead of at every start]
prepare-sep-calibration ran before aurora-sep.service on every boot and
carved the calibration again, although it is constant for a Mac. On the
MacBook Neo and the M4 Air it found a bare FSC2 image the enclave refuses.

aurora-touchid-setup replaces it. It builds the files the sensor's driver
loads from this Mac's own data, read-only, with Erik Bourget's reader
from the previous commit:
- the calibration and, where the factory cache has an MSRk record, the
  sensor's signed root key, both resealed from the factory records on
  the Hardware volume (J700, J713, J616s);
- elsewhere (M1, M2), the comb record carved from the container, as is.

The names come from the fingerprint node's firmware-name list, read as
the driver reads it: the calibration first, the root key second, with
the driver's defaults.

It runs only when something is wrong or when asked:
1. A file is missing. aurora-touchid-setup.service runs before Touch ID
   starts. Its ExecCondition only tests that the files it recorded
   exist, so a boot with Touch ID in place skips it. The first boot
   after installation runs it once to record what is there.
2. The enclave refused a file. When the sensor did not attach,
   aurora-sep-ready looks for a refused LOAD_CALIBRATION or
   SENSOR_ROOT_KEY in this boot's kernel log and starts the service
   once. The driver loads the file again at its retry about 10 s later.
   A second refusal in the same boot is only logged.
3. The owner runs it, with --check (writes nothing) or --force-rebuild,
   and --json for a machine-readable result.

A file it did not install is kept unless the enclave refused it or
--force-rebuild asks. Replaced bytes go to /var/lib/aurora-sep/rollback.
New files are written atomically, mode 0600, and read back. The result
is kept in /var/lib/aurora-sep/touchid-setup.json with a JSON line per
run in touchid-setup.log.

NixOS keeps the kernel's firmware path on /run, so the files are kept
in /var/lib/aurora-sep/firmware. The tool links each file into that
path, and aurora-sep.service relinks them at each boot (touchid-publish
creates links only and builds nothing).

The firmware-name list parsing from nixos-aurora#50 is part of this.
The per-boot readiness marker of the previous commit is left out,
because nothing runs at every boot to write it; the driver's diag
attributes already tell aurora-sep-ready whether the sensor attached.

Tested with --check on the Neo, the J616s, the M1 Pro and the M2: each
rebuild is byte-identical to the file installed and working there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RyanTheTide and others added 2 commits October 30, 2026 22:34
Two fixes found while checking what a fresh image does on each Mac.

The tool took any node with the apple,mesa-fingerprint compatible as a
reader. The SoC device trees carry that node disabled on Macs without
one (Mac mini, Mac Studio), and aura disables the SPI controller on a
J700 sold without the sensor. Those Macs found no calibration, failed,
and ran the unit again on every boot. A node now counts only when it and
every node above it are enabled, as the kernel decides before probing.

On Arch the boot points firmware_class.path at the vendor firmware it
unpacks on /run, and the tool kept its files there. They were gone
after a reboot, so the setup ran at every boot on Macs whose package has
no Touch ID files, and a rebuild after a refusal never lasted. The files
are now always kept in /usr/lib/firmware, or AURORA_TOUCHID_FIRMWARE_DIR
(NixOS), and only linked into a custom search path. The kernel falls
back to /lib/firmware, so nothing else changes. Fedora has no custom
path and is unaffected.

Tested with the unit tests (new cases fail on the previous tool) and
with --check on the Neo, J616s, M1 Pro and M2: each still finds its
enabled sensor and reports the installed files identical to the rebuild.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main changed prepare-sep-calibration to read the fingerprint firmware-name
as a string list (#50). This branch removes that helper; aurora-touchid-setup
reads the same list the way the driver does, so the J616s, which also names
its MSRk record, still gets its calibration. Keep the removal and raise the
package version to 1.9, above main's 1.8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RyanTheTide
RyanTheTide merged commit e49ce67 into main Oct 30, 2026
22 checks passed
@RyanTheTide
RyanTheTide deleted the aurora-sep/touchid-setup branch October 30, 2026 12:47
RyanTheTide added a commit that referenced this pull request Nov 5, 2026
The v2 tip: speakerguardd#51, #52, #53, #54. The packaged files are unchanged.
Fleet gate (gate.json, upstream's, unchanged here): units at parity: spp3, lsm2; spp3: J316s, J413, J616s; lsm2: J700.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
Assisted-by: LLM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants