fingerprintd/implementations/main.cpp

50 lines
1.9 KiB
C++
Raw Normal View History

Initial commit: the gpfile wire format, pinned by two real containers fingerprintd will own the FP6's fingerprint sensor: the rail, the QTEE session, the storage callbacks QTEE makes back into the normal world, and net.reactivated.Fprint so pam_fprintd and the desktop need no changes. None of that runs yet. What is here is the first core module and the machinery around it. Fingerprintd:Sfs is the gpfile listener's frame -- the callback that carries 47 of 66 storage requests during an enrolment. It is parse, reply and root mapping only: no file I/O, no TEE, no allocation of the shared buffer. The daemon shell supplies those, which is what lets every byte-level decision be tested on a dev box with no phone. The module exists mainly to hold one fact. READ answers at req+0x00c and WRITE reads its payload from req+0x110, because the frame is a union: a WRITE still needs its path while the payload is copied out, so it sits past the 256-byte path field, while a READ has consumed the path and packs its reply over it. Conflating them is wrong in both directions with the same symptom -- the container does not round-trip, QTEE's HMAC check fails, and the file is unlinked as tampered on the next session. So the tests do not assert the constants against themselves. They load two real containers off the phone -- one written correctly, one written with the offsets conflated -- and re-derive the bug: the broken one opens with ASCII path text rather than a binary HMAC, that text is the group name from character 8 because the read offset is 8 bytes into the path field, and the real container sits exactly 0x104 further in. Then a write-store-read round trip must be the identity, and the same round trip through a single offset must not be. O_TRUNC gets a static_assert of its own. QTEE writes a container as write(0,4096), write(4096,N), write(0,4096), so truncating on open leaves 4096 bytes where a 258850-byte template belongs; it unlinks a file it means to shorten rather than relying on the opener. Verified by mutation: conflating the offsets, making DataOffset return the read offset for writes, and setting O_TRUNC each fail the suite.
2026-09-02 16:02:46 +02:00
// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
// lint-disable-file fixed-width-types
/*
fingerprintd the daemon shell.
Nothing here talks to hardware yet. The core (Fingerprintd:Sfs and the modules
that follow it) is being ported from the fp6 harness one wire format at a time,
each landing with tests that run without a phone; this entry point exists so
the executable target builds alongside them and so the version constant that
gates a package publish has a home.
What this will own, and why it has to be one long-lived process:
* the sensor rail (gpio29), reset (gpio74) and IRQ (gpio75) one sensor
reset buys exactly one trustlet init, so whatever powers the sensor must
also hold the session;
* the QTEE session on /dev/tee0: client env, the QSEECOM-compat loader, and
the focal64 trustlet, loaded once;
* the storage listeners QTEE calls back into gpfile 0x7000 and RPMB
0x2000 served from a supplicant thread that must outlive every request,
because QTEE's listener table is global and an id is taken for as long as
the registration is held;
* net.reactivated.Fprint, so pam_fprintd and the desktop need no changes.
*/
import std;
import Fingerprintd;
namespace {
// Bumping this is what publishes a package: the registry answers 409 for a
// version it already has, which a build treats as a no-op.
constexpr const char* Version = "0.0.1";
}
int main(int argc, char** argv) {
std::span<char*> args(argv, static_cast<std::size_t>(argc));
for (std::string_view a : args.subspan(1)) {
if (a == "--version") {
std::println("fingerprintd {}", Version);
return 0;
}
}
std::println(std::cerr,
"fingerprintd {}: no runtime yet -- the core is still being "
"ported. Run `crafter-build test` for what does work.",
Version);
return 1;
}