Reverse engineering my laptop's fingerprint sensor on Linux
Contents
My ASUS Vivobook 16X has a built-in ELAN fingerprint sensor (04f3:0c90) with no Linux driver and no published datasheet. I reverse engineered its USB protocol and wrote a userspace driver in Rust that now unlocks my Ubuntu login and lock screens.
I am not a kernel or systems programmer. Before this project, I didn't even know what a USB endpoint was. If you're comfortable writing code but have never talked directly to hardware, this series walks through how I figured it out, including the dead ends.
Four days in 2023, and coming back in 2026
Fingerprint login worked on Windows 11 for about a month after I bought the laptop (K3605ZF). Then one morning in December 2023, the option vanished in Settings. ASUS's support page offered only a "FOCAL Fingerprint Driver" (V3.00.4901.2753) even though ELAN made the chip, and reinstalling it changed nothing.
Soon after, I switched to Ubuntu and hit a harder wall. Linux had no driver for this reader at all. I spent four days watching C kernel-driver tutorials, got completely lost, and gave up.
For nearly three years the sensor sat idle beside my thumb. I use a long password, so whenever I mistyped one letter in a hurry, I had to retype the whole thing while staring at dead hardware. In September 2026, after one too many typos, I decided to try again.
This time I used OpenCode running Muse Spark 1.3 and Nemotron 3 Ultra. Instead of asking it to write a kernel module from scratch, I broke the problem into four concrete questions:
- How does the sensor read a finger?
- How does that reading travel over USB to Linux?
- Does this driver even belong in the kernel?
- Which part of Ubuntu actually asks for a fingerprint at login?
Why I didn't need a kernel driver
Plug in a USB keyboard and the Linux kernel grabs it right away. The keyboard's USB descriptor advertises HID (class 3), so Linux binds its built-in keyboard driver and takes exclusive control.
Even though this fingerprint reader is soldered inside the laptop, it sits on an internal USB bus too. Running lsusb -d 04f3:0c90 shows what Linux sees:
$ lsusb -d 04f3:0c90
Bus 001 Device 002: ID 04f3:0c90 Elan Microelectronics Corp. ELAN:ARM-M4Every USB device reports two hex IDs: 04f3 for ELAN, and 0c90 for this exact sensor model. On Linux, most fingerprint readers go through libfprint, a shared C library where each driver keeps a list of supported product IDs. Libfprint supports several sibling ELAN IDs, but 0c90 isn't on any of its lists, so Ubuntu ignores the hardware.
That turned out to be an advantage. I ran lsusb -v -d 04f3:0c90 to inspect the USB descriptors the chip reports at startup. Instead of a standard class like HID or mass storage, interface 0 declares class 255: "vendor-specific."
Because the kernel has no generic driver for class 255, it leaves the device unbound. Linux exposes Bus 001 Device 002 as a character device file at /dev/bus/usb/001/002 through usbfs. Any process with permission to open that file can send raw USB transfers straight to the sensor.
That answered question 3 right away. I didn't need C or kernel code at all. The whole driver could live in a normal Rust program.
swipe sideways to see the whole diagram
How the sensor matches prints on the chip
Look at the end of that lsusb line: ELAN:ARM-M4.
Many older laptop sensors act like tiny cameras. They stream a grayscale image of your finger over USB so software on your CPU can run matching. This chip packs its own ARM Cortex-M4 microcontroller and built-in flash memory, so it handles matching on the sensor itself.
When you enroll a finger, the chip turns the touches into a mathematical template and saves it in a numbered flash slot. At login, touching the pad makes the chip compare your finger against every slot and send back two bytes with the slot ID that hit. No fingerprint image ever crosses USB during enrollment or login.
swipe sideways to see the whole diagram
Next was figuring out how bytes actually travel over that USB wire. If you dump lsusb -v -d 04f3:0c90, interface 0 lists eight bulk endpoints, which looks intimidating until you line them up as four outbound/inbound pairs (0x01/0x81 through 0x04/0x84).
Only four of those eight addresses matter here:
0x01OUT carries commands from your laptop to the chip.0x83IN returns immediate status replies and counts.0x84IN returns replies that wait for a finger touch.0x82IN dumps raw debug images, which login doesn't use.
The other four halves (0x81 IN, plus 0x02, 0x03, and 0x04 OUT) sit unused. Because writing random bytes to 0x02, 0x03, or 0x04 would reach unknown firmware handlers, my USB crate (elanprint-usb) hardcodes EP_OUT = 0x01 and exposes an EndpointIn enum with only 0x82, 0x83, and 0x84. The compiler itself prevents writing to those unknown pipes.
swipe sideways to see the whole diagram
Probing the chip without bricking flash
When reverse engineers meet an unknown USB device, they often fuzz it: send guessed byte sequences and watch what changes. I couldn't take that risk.
Microcontrollers with writable flash have internal opcodes for erasing memory, writing registers, and entering bootloader mode. Sending random bytes to a sensor soldered onto my motherboard could brick the chip with no way to reflash it. So I set one hard rule: never guess or loop over unknown opcodes.
Instead, I started from depau/elanpoc, an MIT-licensed proof of concept by Davide Depau for sibling ELAN chips (0c00, 0c4c, 0c5e). It gave me a starting command table even though 0c90 wasn't on its supported list. I copied each opcode into docs/protocol.md tagged documented, and only marked one confirmed after seeing the real reply on my laptop. Opcodes that touch firmware state, like bootloader entry (42 01 52 55 4E 49 41 50) and register writes, stayed on a strict DO NOT SEND list.
To see what crossed the wire, I captured packets with usbmon, Linux's kernel USB sniffer. Usbmon dumps traffic for your mouse, keyboard, and Bluetooth chip all together, and I didn't have tshark installed. So I wrote tools/usbmon_filter.py to isolate 04f3:0c90 packets and print their timestamps and kernel status codes.
Testing physical hardware with an AI agent had one obvious catch. OpenCode could write Rust and decode usbmon logs, but it didn't have fingers. If a test waited for a touch and captured silence, the agent couldn't tell whether the firmware had ignored the command or nobody had touched the pad. Whenever a test needed a scan, OpenCode paused, asked me to touch the sensor, and waited for me to type confirmation before reading the log.
With logging and safety rules in place, I sent three read-only queries first:
OUT 0x01: 40 19 -> IN 0x83: 01 08 # firmware 1.8, matching bcdDevice 1.08
OUT 0x01: 00 0c -> IN 0x83: 4f 00 4f 00 # width 79+1, height 79+1 (80x80 pixels)
OUT 0x01: 40 ff 04 -> IN 0x83: 40 00 # enrolled_num: echoes 0x40, count = 0Watch that third reply, 40 00. Byte 0 simply echoes the command's 0x40 prefix, and byte 1 carries the count (00). Read those two bytes together as a 16-bit integer (0x4000) and your driver thinks the user enrolled 16,384 fingers.
All three replies matched what the 0c4c notes predicted. The chip was healthy and responding on 0x83, so I moved on to scanning a finger.
Four firmware behaviors the docs missed
Read-only queries worked on the first try. Trouble started the moment I tried verifying a finger and enrolling a new one. My 0c90 firmware broke four assumptions from the 0c4c reference.
Touch commands hang unless you arm the chip
I sent verify (40 ff 03), pressed my finger onto the sensor, and waited. Three minutes later, the read timed out with zero bytes received.
I wrote down three explanations:
- The sensor was replying on
0x83instead of0x84. verifyexpected another command ahead of it.40 ff 03wasn't the verify opcode on 0c90.
My no-fuzzing rule took explanation 3 off the table. Explanation 1 needed careful handling because USB doesn't let a chip push bytes unprompted. Your laptop has to queue an IN read first and wait for the chip to fill it. If the chip replies on an endpoint with no read waiting, the host drops it and usbmon records nothing.
So I posted IN reads on both 0x83 and 0x84 in the same millisecond, sent 40 ff 03, and touched the sensor. In this usbmon log, S marks when Linux submitted a request, C marks completion, -115 means waiting on the device, and -2 (ENOENT) means Linux canceled its own read after timing out:
5.896 S bulk OUT 0x01 -115 3 40 ff 03 # host sends verify
5.896 S bulk IN 0x83 -115 64 # waiting on 0x83
5.896 S bulk IN 0x84 -115 64 # waiting on 0x84
185.898 C bulk IN 0x83 -2 0 # 180s later, host timed out
185.899 C bulk IN 0x84 -2 0 # 180s later, host timed outI ran fw_ver (40 19) right afterward and it answered normally, so the sensor hadn't crashed. I had listened on both IN endpoints and the hardware stayed alive, which left explanation 2.
Checking elanpoc line by line, I noticed every working verify ran right after enrolled_num (40 ff 04), whereas my script had opened the device and sent verify cold. I sent 40 ff 04 right before 40 ff 03 on the same open connection, then touched the pad 20.9 seconds later. This time 0x84 answered 40 fd: touch detected, finger not enrolled.
5.966 S bulk OUT 0x01 -115 3 40 ff 04 # arm chip with enrolled_num
5.966 C bulk IN 0x83 0 2 40 00 # saved count = 0
5.967 S bulk OUT 0x01 -115 3 40 ff 03 # now send verify
5.967 S bulk IN 0x83 -115 64
5.967 S bulk IN 0x84 -115 64
26.838 C bulk IN 0x84 0 2 40 fd # touch arrived, finger not enrolledOpening a device through usbfs locks interface 0 for exclusive access, known as claiming it. On firmware 1.8, any command that waits for a touch stays silent forever unless enrolled_num has run at least once on that open claim. Once armed, the chip stays ready across pauses, even through a 12.7-second gap between enrollment touches, until you close the USB handle or hit an error.
Send
enrolled_num(40 ff 04) once per USB claim before any touch-wait command, and hold that claim open across the whole flow. (elanpocnotes that its own enrollment is broken, and skipping this arming step is likely why.)
One related quirk turned up when resetting a session: the 0c4c docs say abort (40 ff 02) returns two bytes on 0x83. On 0c90, abort sends back nothing. Waiting for those two bytes stalled every error path until timeout, so the driver sends abort and moves on.
swipe sideways to see the whole diagram
finger_info returns 40 ff even when a slot is full
On 0c4c, querying a slot with finger_info (40 ff 12 plus the slot ID) returns a 70-byte metadata record when a slot holds a print. A short 40 ff reply meant the sensor was stuck and needed a verify call to clear it.
When I queried slots 0 through 15 on my sensor, all sixteen returned 40 ff. Running verify changed nothing. Even after I enrolled my finger into slot 0 and watched enrolled_num climb from 0 to 1, slot 0 still answered 40 ff. (Across roughly fifteen later checks, one transient 70-byte reply did appear once and never reproduced, so the parser accepts both lengths.)
On 0c90, 40 ff simply means "no record to give you," not "stuck." Because full and empty slots give the exact same two bytes, Linux cannot scan flash to discover which slots are taken. Any driver that scans finger_info looking for an empty slot will conclude slot 0 is free and overwrite a real fingerprint.
swipe sideways to see the whole diagram
verify checks every slot without knowing who asked
Suppose Bob enrolled his thumb on this laptop last month, or a previous owner sold you the laptop without wiping the chip. Today Alice sits down at the login screen.
Look at the verify packet (40 ff 03): three fixed bytes, with no user ID and no finger field. The sensor matches a touch against every template in flash, including other accounts and orphaned prints left behind by an earlier OS install, and answers 40 00 for slot 0, 40 01 for slot 1, or 40 fd when nothing hits. Uninstalling the driver never erases flash.
If a Linux daemon forwards the chip's raw reply without filtering it first, Bob's thumb unlocks Alice's account. Host software has to track slot ownership itself.
Enrollment switches endpoints halfway through
Enrolling a new finger runs in three stages:
- Collect eight
enrollsamples, resending the same attempt counter whenever the sensor returns a retry hint (0x41–0x44to recenter,0xfbfor a dirty pad,0xfefor too small a contact). - Run
check_enrolled_collisionto verify this finger isn't already stored in another slot. - Send a 72-byte
commitpacket to write the template to flash.
In my quick CLI script, enrollment worked on the first try because the script chose the reply pipe per command. When I moved that same loop into the background login daemon for Part 2, I tapped the sensor eight times, watched the collision check fire, and watched the daemon time out without saving anything.
Same commands, same bytes. Why did it hang?
Because enrollment switches IN pipes halfway through. The eight touch samples arrive on 0x84, while the collision check and commit run inside the chip and reply on 0x83:
# 1. Repeat 8 times. Touch 8 of 8: slot=00, total=08, index=07.
OUT 0x01: 40 ff 01 00 08 07 00 -> IN 0x84: 40 00
# 2. Check if this finger matches an existing slot.
OUT 0x01: 40 ff 10 -> IN 0x83: 40 00 ff # byte 1 = 0x00 means no clash
# 3. Commit template to flash (72 bytes: opcode + sub-ID + 68 zero bytes).
# sub-ID = 0xf0 | (slot + 5), which is 0xf5 for slot 0.
OUT 0x01: 40 ff 11 f5 00 ... -> IN 0x83: 40 00 # saves in ~102 msReading the wrong USB endpoint doesn't throw an error; it just sits waiting until timeout. My early daemon kept reading 0x84 after the eighth scan, so it hung on the collision check every single time.
swipe sideways to see the whole diagram
Eight commands confirmed on hardware
Eight of the sixteen commands in docs/protocol.md are confirmed on firmware 1.8:
| Command | Sent | Reply | Endpoint |
|---|---|---|---|
fw_ver | 40 19 | 01 08 | 0x83 |
sensor_size | 00 0c | 4f 00 4f 00 | 0x83 |
enrolled_num | 40 ff 04 | 40 00, 40 01, ... | 0x83 |
finger_info | 40 ff 12 + slot | 40 ff | 0x83 |
verify | 40 ff 03 | 40 00, 40 01, 40 fd | 0x84 |
enroll | 40 ff 01 + 4 bytes | 40 00 per touch | 0x84 |
check_enrolled_collision | 40 ff 10 | 40 00 ff | 0x83 |
commit | 40 ff 11 + 69 bytes | 40 00 | 0x83 |
Two caveats remain in docs/protocol.md. First, the commit sub-ID formula 0xf0 | (slot + 5) produces 0xf5 through 0xff for slots 0 through 10, then overflows the low four bits at slot 11 and above. Second, delete hasn't run under the current driver code, and wipe_all (40 ff 99) has never run on this sensor.
That answers the first three questions we started with: the chip matches on hardware, talks raw USB from userspace without a kernel driver, and speaks those eight commands on Ubuntu 24.04.4. Next, in Part 2, I answer question 4 by tracing Ubuntu's login stack and replacing its fingerprint daemon in Rust.











