No description
  • Rust 95.7%
  • Nix 4.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Marcus Ramberg 2fa24c1f85
fix: MC_IO_NOTIFY takes the session id by value
It is an _IO ioctl, so the id is the argument itself rather than a
pointer to it; the lookup answered ENXIO and no session ever got past
its first transact.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dm7YmwbHNhmhHoYRUpgFC4
2026-10-20 09:02:21 +02:00
data chore: Ship D-Bus, systemd and polkit files, and a NixOS module 2026-10-12 11:04:31 +02:00
nix fix: force the fprintd package, which device modules often set 2026-10-12 11:05:22 +02:00
src fix: MC_IO_NOTIFY takes the session id by value 2026-10-20 09:02:21 +02:00
.gitignore chore: Ship D-Bus, systemd and polkit files, and a NixOS module 2026-10-12 11:04:31 +02:00
Cargo.lock feat: Serve net.reactivated.Fprint 2026-10-12 11:02:47 +02:00
Cargo.toml feat: Serve net.reactivated.Fprint 2026-10-12 11:02:47 +02:00
flake.lock Add a nix flake for development and distribution 2026-10-12 11:01:58 +02:00
flake.nix chore: Ship D-Bus, systemd and polkit files, and a NixOS module 2026-10-12 11:04:31 +02:00
README.md feat: Drive the FPC1560 through Trustonic Kinibi 2026-10-19 17:46:42 +02:00

tee-fprintd

A drop-in for fprintd on laptops whose fingerprint sensor sits behind a trusted execution environment. It serves fprintd's D-Bus API (net.reactivated.Fprint), so pam_fprintd, GDM, GNOME Settings and the fprintd-* tools work unchanged.

Two match-on-chip sensors are supported, both driven through their vendor trusted application. The sensor's SPI bus belongs to the secure world in each case: this daemon never sees an image, it only asks the application to capture, enrol and match.

  • the FocalTech sensor found on Snapdragon laptops, through QSEE
  • the FPC1560 found in the power key of some MediaTek phones, through Trustonic Kinibi

Whichever is present is picked at startup; Kinibi wins if both are.

Requirements

FocalTech (QSEE)

  • The focaltech_fp misc device (drivers/misc/focaltech-fp.c), exposing the trusted application's name in firmware_name.
  • A QSEECOM TEE driver, as /dev/teeN with implementation id 5.
  • The trusted application already loaded, and its storage served, by a separate supplicant. Loading it is privileged and is not done here.

FPC1560 (Kinibi)

  • Trustonic's mcDrvModule, as /dev/mobicore-user.
  • mcDriverDaemon running: the kernel driver cannot load a trustlet by itself, so the registry has to be served. Without it, opening a session fails.
  • The two trustlet binaries, as /etc/tee-fprintd/fpc.tlbin and gk.tlbin (the FPC application and the gatekeeper it needs).

Unlike the FocalTech path, this application keeps no storage of its own: the whole template database comes out as one encrypted blob, which is kept in /var/lib/tee-fprintd/fpc-db.bin and loaded back at every open. Lose that file and every enrolled finger goes with it.

tee-fprintd takes the net.reactivated.Fprint bus name, so it replaces fprintd rather than running beside it.

Installing

NixOS

{
  inputs.tee-fprintd.url = "github:…/tee-fprintd";
  outputs = { nixpkgs, tee-fprintd, ... }: {
    nixosConfigurations.laptop = nixpkgs.lib.nixosSystem {
      modules = [
        tee-fprintd.nixosModules.default
        { services.tee-fprintd.enable = true; }
      ];
    };
  };
}

The module enables services.fprintd with this daemon in place of fprintd's package, so PAM and GDM fingerprint login are set up the usual NixOS way. Don't also set services.fprintd.package.

Elsewhere

cargo build --release
install -Dm755 target/release/tee-fprintd /usr/libexec/tee-fprintd
for f in data/*; do sed "s|@bindir@|/usr/libexec|" "$f" > "/tmp/${f#data/}"; done
install -Dm644 /tmp/net.reactivated.Fprint.conf -t /usr/share/dbus-1/system.d/
install -Dm644 /tmp/net.reactivated.Fprint.service -t /usr/share/dbus-1/system-services/
install -Dm644 /tmp/net.reactivated.fprint.device.policy -t /usr/share/polkit-1/actions/
install -Dm644 /tmp/tee-fprintd.service -t /usr/lib/systemd/system/

Uninstall fprintd's daemon first: its D-Bus service file claims the same name. Keep pam_fprintd and the fprintd-* clients.

Security

Both applications refuse to enrol a finger without a token from Android's Gatekeeper. The FocalTech one can be told not to ask, and is (enable_trusted_enrollment); the FPC one cannot (3.06 answers PARAMETER), so the daemon opens the gatekeeper trustlet alongside it and mints a token with a constant password. Either way the check stops being a check: anything that can open a session on the application can enrol. The daemon's polkit checks are what stands in for it, and they use fprintd's actions and defaults:

Action Allows Default for the active session
net.reactivated.fprint.device.verify claiming, listing, verifying yes
net.reactivated.fprint.device.enroll enrolling, deleting the user's password
net.reactivated.fprint.device.setusername acting on another user an admin's password

Root is always allowed. A verification only matches a finger enrolled by the claiming user (and only the named finger, unless it asked for any): the application matches against every stored template, so the daemon checks what it matched against its own record of who enrolled what.

That record lives in /var/lib/tee-fprintd/prints, readable by root only.

Configuration

Only the FocalTech path is configured this way. The application is sent a JSON configuration on every start. The built-in one fits the FT9362 on the machines this was developed on. A board that needs different values can supply /etc/focaltech/ff_config.json instead; keep max_enrolling_samples at 12, which the enrolment progress is scaled to.

Debugging

Set TEE_FPRINTD_DEBUG=1 in the service's environment to log every event and the trusted application's own log output.

With the daemon stopped, the binary also drives the sensor directly:

sudo systemctl stop tee-fprintd
sudo TEE_FPRINTD_DEBUG=1 tee-fprintd enroll
sudo tee-fprintd identify
sudo tee-fprintd list
sudo tee-fprintd delete <id>

Development

nix develop
cargo test          # needs dbus-daemon on PATH; the dev shell has it
nix flake check     # also builds the package and runs a NixOS VM test

The daemon tests run it end to end on a private bus, with a fake polkit, a fake logind and a scripted sensor.

Limitations

  • finger-present and finger-needed always read false.
  • Enrolling a finger that is already enrolled, by anyone, is not detected.
  • All users' templates share one group in the application. With five fingers enrolled it is configured (max_enrolling_fingers) to refuse more.
  • On Kinibi, finger-present/finger-needed aside, a touch is found by polling the application rather than waiting on the sensor's interrupt, which stock does host-side; a touch is noticed within ~60 ms.
  • The FPC application's match rates have not been characterised.
  • While polkit waits for a password, the daemon answers no other client.

Licence

LGPL-2.1-or-later. The protocol code is a port of the focaltechqsee libfprint driver.