Fully slopped proof of concept of an attested fingerprint driver for the 04f3:0c4c Elan Microelectronics Corp. ELAN:ARM-M4.
  • Rust 95.2%
  • Nix 3.7%
  • Shell 1.1%
Find a file
ToxicMushroom f5fa2dacef Add a Nix flake with a NixOS module
flake.nix builds the workspace with crane (nix/package.nix), mirroring
the PKGBUILD's three separate cargo builds so the PAM module's zbus does
not pick up tokio, and exposes a NixOS module (nix/module.nix) that runs
elan-fprintd as an fprintd drop-in and wires pam_elan_keyring into the
generated PAM services.

The screen-lock watcher also recognises NixOS's wrapped prompter binary
(.gcr-prompter-wrapped) when closing a stale keyring prompt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:52:34 +01:00
crates Add a Nix flake with a NixOS module 2026-11-22 12:52:34 +01:00
dbus Hardware enroll fixes, Arch packaging, SDCP crypto hardening 2026-11-11 13:19:09 +01:00
docs Add greeter-hint option so dms-greeter starts fingerprint login 2026-11-22 12:52:34 +01:00
nix Add a Nix flake with a NixOS module 2026-11-22 12:52:34 +01:00
packaging/arch Add greeter-hint option so dms-greeter starts fingerprint login 2026-11-22 12:52:34 +01:00
pam Use sensor mode 3 so SDCP fingers survive power-off; lock keyring on screen lock 2026-11-15 13:45:45 +01:00
systemd Refresh stale install and PAM docs 2026-11-15 17:57:35 +01:00
udev Refresh stale install and PAM docs 2026-11-15 17:57:35 +01:00
.gitignore Initial commit: plaintext protocol core + research 2026-11-11 03:05:48 +01:00
Cargo.lock Clean up dead code paths and split large modules 2026-11-15 17:35:23 +01:00
Cargo.toml Clean up dead code paths and split large modules 2026-11-15 17:35:23 +01:00
flake.lock Add a Nix flake with a NixOS module 2026-11-22 12:52:34 +01:00
flake.nix Add a Nix flake with a NixOS module 2026-11-22 12:52:34 +01:00
INSTALL.md Add greeter-hint option so dms-greeter starts fingerprint login 2026-11-22 12:52:34 +01:00
LICENSE.md Initial commit: plaintext protocol core + research 2026-11-11 03:05:48 +01:00
PLAN.md Pin the sensor's model certificate and Microsoft chain in the build 2026-11-15 17:52:40 +01:00
README.md Pin the sensor's model certificate and Microsoft chain in the build 2026-11-15 17:52:40 +01:00

elan-arm-m4-crypto-rs

A Rust fprintd drop-in for the ELAN ARM-M4 fingerprint sensor (04f3:0c4c, match-on-chip), with a path to using the sensor's Microsoft SDCP secure mode so a fingerprint can guard the GNOME keyring without being spoofable by a swapped or injected USB device.

Status: working on the author's 0c4c (firmware 3.04).

  • The daemon replaces fprintd for login, sudo and the lock screen.
  • The sensor runs in SDCP mode (mode 3).
  • An attested match unlocks the GNOME keyring, also after a full power-off.

Polkit checks, suspend/resume handling and fuzz tests are still open. See PLAN.md for the status of each phase and docs/hardware-notes.md for what was measured on the sensor.

Why SDCP

The sensor cannot store or release a secret — match-on-chip returns only a slot index (plaintext) or an id + MAC (SDCP). So any keyring secret stays TPM-sealed on the host and is released by the daemon on a verified match. The value of SDCP is a gate that cannot be spoofed by cheap USB hardware: a fake sensor cannot produce the Microsoft-signed device claim or MAC a fresh nonce. In plaintext mode a €5 USB device that answers "slot 0 matched" defeats the gate, which is why keyring unlock will be offered only in SDCP mode. See docs/crypto-dependencies.svg.

Workspace

Crate Role
elan-proto Sans-IO command table, framing, status codes. No I/O, no unsafe. Fully unit-tested.
elan-usb BulkTransport trait, the arming rule, a scriptable mock. Real nusb backend behind the hardware feature.
elan-device Enroll / identify / delete flows driving a transport. Tested against the mock.
elan-sdcp Host-side Microsoft SDCP crypto: P-256 ECDH/ECDSA, HMAC-SHA256, SP800-108 KDF, claim verification, enroll/identify MACs, and cert_m X.509 chain validation, and the model certificate and Microsoft chain pinned in the build. Sans-IO.
elan-keyring Seal a secret at rest and release it on demand: a Sealer trait, an insecure in-memory software backend (tests / TPM-less dev), and a TPM2 backend (tss-esapi, PCR-policy bound) behind the tpm feature.
pam-elan-keyring pam_elan_keyring.so: fingerprint auth that also sets PAM_AUTHTOK to the TPM-sealed keyring password, plus password capture. Root PAM stacks only. See docs/pam-setup.md.
fprint-store Host-side (user, finger) → slot map. No biometric data. Atomic 0600 JSON.
elan-fprintd The net.reactivated.Fprint D-Bus daemon (Manager + Device), driven by a SensorBackend + the store. Runs with a NullBackend out of the box.
elan-secure The SDCP wire layer: the confirmed message layouts, framing with an opcode allowlist, and an authenticated Channel (Connect, Identify, enroll, Reconnect).
elanctl Debug CLI: the command table and encoder offline; probe, verify, wipe and an sdcp check on the sensor (hardware feature).

Every SDCP Connect checks two pins. The sensor's model certificate must be one embedded in the build (elan_sdcp::pinned) and must chain through the Windows Hello CAs to the Microsoft ECC Devices Root, so its key vouches for the device key. The daemon also pins that device key pk_d on first use, in /var/lib/elan-fprintd/sdcp-device-key, so only this physical sensor can connect afterwards.

Plain fingerprint login needs no extra module: stock pam_fprintd talks to elan-fprintd over D-Bus. Keyring unlock does, because pam_fprintd gives pam_gnome_keyring no password. For that, the daemon serves a private, root-only net.reactivated.Fprint.Elan.Keyring1 object. Its VerifyAndRelease method verifies the finger and unseals the user's TPM-sealed password in one call, and pam_elan_keyring.so sets that password as PAM_AUTHTOK. The secret is released only on an attested (SDCP) match unless root opts out, and the TPM binds it to the Secure Boot PCRs. Lock screens that run PAM unprivileged (DankMaterialShell, swaylock) keep stock pam_fprintd. When a user's finger matches while their logind session has LockedHint, the daemon unlocks their keyring itself over gnome-keyring's control socket, through a helper that runs as that user. Setup: docs/pam-setup.md.

Running the daemon

To install it for real on Arch Linux, see INSTALL.md.

# Serve on the session bus (no root) with the null backend, then introspect it:
ELAN_FPRINTD_BUS=session ELAN_FPRINTD_STATE_DIR=/tmp/elan-state cargo run -p elan-fprintd
busctl --user introspect net.reactivated.Fprint /net/reactivated/Fprint/Device/0

With --features hardware it opens the sensor if available and falls back to the null backend otherwise. The system-bus install uses systemd/elan-fprintd.service and the files under dbus/; it Conflicts with fprintd.service.

Safety discipline

Command bytes live in exactly one place (elan-proto::command). Every command is tagged with a confidence level and a safety class; encode refuses unconfirmed commands and anything on the DO-NOT-SEND list (bootloader entry, register writes, EC-pin, any sensor mode other than 0 and 3, unknown flash writes). Destructive commands (delete, wipe_all) are tagged so callers can gate them behind an explicit user action. Commands seen working on the 0c4c are at confidence confirmed. The SDCP opcodes are sent only by elan-secure, which has its own allowlist.

Never send mode 0 (40 ff 14 00) to a sensor in mode 3: it erases every template. The daemon sets mode 3 and never sends mode 0.

Build

cargo build --workspace
cargo test --workspace
cargo run -p elanctl -- table
cargo run -p elanctl -- encode enroll 02 08 00 00

Credits

Builds on the reverse-engineering of depau/elanpoc (MIT), the libfprint elanmoc2 / Backware elanmoc_0c4c drivers (LGPL), and prawesh-12/elanprint-rs (MIT). No code is copied from those projects; the protocol knowledge is credited in docs/phase0-findings.md.

License

Apache-2.0 OR MIT, at your option.