- Rust 95.7%
- Nix 4.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
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 |
||
| data | ||
| nix | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
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_fpmisc device (drivers/misc/focaltech-fp.c), exposing the trusted application's name infirmware_name. - A QSEECOM TEE driver, as
/dev/teeNwith 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. mcDriverDaemonrunning: 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.tlbinandgk.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-presentandfinger-neededalways 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-neededaside, 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.