Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions PR_BODY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Summary
This PR introduces native Linux driver support for the **Synaptics WBDI 06cb:008a** fingerprint sensor (Viper family, ASIC 57K0 FM-154-124, ROM 6.20), as found on Toshiba / Dynabook Tecra X40-D, Portégé, and related models.

Resolves #4

### Background & Hardware Reality
1. **Match-on-Host (MoH) Architecture**:
Unlike the 0090/0097/009a devices, the 008a sensor is strictly Match-on-Host. `GetFirmwareInfo (0x4302)` returns `0x04af` ("no firmware detected"), and Match-on-Chip commands (`0x68`, `0x5e`) return error `0401` (invalid command). The sensor does not require or use a `.xpfwext` firmware extension.
2. **Flash Disconnect Avoidance**:
Attempting to write biometric templates directly to the SPI flash table triggers bus contention and USB device disconnects (`USBError 19: No such device`). Moving template storage to the host filesystem completely stabilizes the device.

### Implementation Details
- **Frame Acquisition**: Calibrated using sensor initialization sequence and passive interrupt awaiting on EP `0x83` to stream full 56×144 8-bit grayscale matrix frames (8,064 bytes).
- **Matching Engine**: 2D Phase Correlation (`numpy.fft.fft2`) with 2D Hann window filtering (eliminating boundary edge step artifacts) and an angular tilt search (`[-12° .. +12°]`) with calibrated threshold `0.12`.
- **Multi-Touch Template Storage**: Host filesystem persistence in `/var/lib/python-validity/templates/{uid}_{subtype}.dat`.
- **Backward Compatibility**: Fully preserved for existing 0090, 0097, 009a, and 009d devices (conditioned on `device_info.type in [0x121, 0x2449]`).
- **Dependencies**: Added `numpy` to `setup.py` and `python3-numpy` to `debian/control`.

### Hardware Verification
Tested and fully verified on Ubuntu 24.04 LTS (Toshiba Tecra X40-D, `PT474U-06P001`). Native `fprintd-enroll`, `fprintd-verify`, and PAM authentication (`sudo -k && sudo whoami`, lock screen) are working reliably.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# python-validity
Validity fingerprint sensor driver.
# python-validity (with Synaptics Viper 06cb:008a Support)

> **🎉 Update:** Added native Linux **Match-on-Host** driver support for **Synaptics WBDI `06cb:008a`** (Viper family, ASIC 57K0 FM-154-124, ROM 6.20) as found on Toshiba / Dynabook Tecra X40-D, Portégé, and related laptops!

### Quick Install for 06cb:008a (Ubuntu / Debian):
Download the prebuilt `.deb` packages from the [Latest Release](https://github.com/the-muzammilali/python-validity/releases/latest) and install:
```bash
sudo apt update
sudo apt install -y python3-usb python3-cryptography python3-numpy python3-pil python3-yaml python3-dbus python3-gi fprintd libpam-fprintd
sudo dpkg -i open-fprintd_*.deb python3-validity_*.deb
fprintd-enroll
fprintd-verify
```

Table of Contents
=================
Expand Down
69 changes: 54 additions & 15 deletions dbus_service/dbus-service
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ from validitysensor.init_data_dir import PYTHON_VALIDITY_DATA_DIR, init_data_dir
from validitysensor.sensor import sensor, RebootException
from validitysensor.sid import sid_from_string
from validitysensor.tls import tls
from validitysensor.usb import usb
from validitysensor.usb import usb, CancelledException
from validitysensor.fingerprint_constants import finger_ids

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
Expand Down Expand Up @@ -73,43 +73,81 @@ class Device(dbus.service.Object):
logging.debug('In Resume')
tls.reset()
try:
init.open_common()
init.open()
except:
init.open_common()
init.open()

@dbus.service.method(dbus_interface=INTERFACE_NAME, in_signature="s", out_signature="as")
def ListEnrolledFingers(self, user):
try:
logging.debug('In ListEnrolledFingers %s' % user)
import glob
from validitysensor.sensor import get_templates_dir
tdir = get_templates_dir()
try:
uid = pwd.getpwnam(user).pw_uid
user_patterns = [f"{uid}_*.dat", f"{user}_*.dat", f"*-{uid}_*.dat"]
except:
user_patterns = [f"{user}_*.dat", "*_*.dat"]

enrolled = []
for pat in user_patterns:
for fpath in glob.glob(os.path.join(tdir, pat)):
fname = os.path.basename(fpath)[:-4]
parts = fname.rsplit('_', 1)
if len(parts) == 2:
try:
st = int(parts[1])
f_name = subtype_to_string(st)
if f_name not in enrolled and f_name != 'Unknown':
enrolled.append(f_name)
except ValueError:
pass
if enrolled:
logging.debug('Enrolled from host templates: %s' % repr(enrolled))
return enrolled

usr = self.user2record(user)

if usr is None:
return []

rc = [subtype_to_string(f['subtype']) for f in usr.fingers]
logging.debug(repr(rc))
return rc
except Exception as e:
raise e
logging.exception(e)
return []

@dbus.service.method(dbus_interface=INTERFACE_NAME, in_signature='s', out_signature='')
def DeleteEnrolledFingers(self, user):
logging.debug('In DeleteEnrolledFingers %s' % user)
usr = self.user2record(user)

if usr is None:
return
import glob
from validitysensor.sensor import get_templates_dir
tdir = get_templates_dir()
try:
uid = pwd.getpwnam(user).pw_uid
for pat in [f"{uid}_*.dat", f"{user}_*.dat", f"*-{uid}_*.dat"]:
for fpath in glob.glob(os.path.join(tdir, pat)):
try:
os.remove(fpath)
except:
pass
except:
pass

db.del_record(usr.dbid)
usr = self.user2record(user)
if usr is not None:
try:
db.del_record(usr.dbid)
except:
pass

@dbus.service.method(dbus_interface=INTERFACE_NAME, in_signature='ss', out_signature='')
def VerifyStart(self, user, finger):
logging.debug('In VerifyStart for %s, %s' % (user, finger))

usr = self.user2record(user)

if usr is None:
enrolled = self.ListEnrolledFingers(user)
if not enrolled:
raise NoEnrolledPrints()

self.VerifyFingerSelected('any')
Expand All @@ -119,12 +157,13 @@ class Device(dbus.service.Object):

def run():
try:
# TODO: pass down the user db record id and implement a proper Sensor.verify() method
usrid, subtype, hsh = sensor.identify(update_cb)
if usr.dbid == usrid:
if usrid != 0:
self.VerifyStatus('verify-match', True)
else:
self.VerifyStatus('verify-no-match', True)
except CancelledException:
logging.info('Verification cancelled by client')
except usb_core.USBError as e:
logging.exception(e)
self.VerifyStatus('verify-no-match', True)
Expand Down
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Depends: ${python3:Depends},
python3-dbus,
python3-usb,
python3-yaml,
python3-numpy,
dbus,
open-fprintd (>= 0.6~),
innoextract (>= 1.6~)
Expand Down
5 changes: 3 additions & 2 deletions debian/python3-validity.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ After=open-fprintd.service

[Service]
Type=simple
ExecStart=/usr/lib/python-validity/dbus-service --debug
Restart=no
ExecStart=/usr/lib/python-validity/dbus-service
Restart=on-failure
RestartSec=2

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions debian/python3-validity.udev
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ENV{DEVTYPE}!="usb_device", GOTO="python_validity_end"
ATTRS{idVendor}=="138a", ATTRS{idProduct}=="0090", GOTO="python_validity_match"
ATTRS{idVendor}=="138a", ATTRS{idProduct}=="0097", GOTO="python_validity_match"
ATTRS{idVendor}=="06cb", ATTRS{idProduct}=="009a", GOTO="python_validity_match"
ATTRS{idVendor}=="06cb", ATTRS{idProduct}=="008a", GOTO="python_validity_match"

GOTO="python_validity_end"

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'bin/validity-led-dance',
'bin/validity-sensors-firmware',
],
install_requires=['cryptography >= 2.1.4', 'pyusb >= 1.0.0', 'pyyaml >= 3.12'],
install_requires=['cryptography >= 2.1.4', 'pyusb >= 1.0.0', 'pyyaml >= 3.12', 'numpy'],
data_files=[
('share/dbus-1/system.d/', ['dbus_service/io.github.uunicorn.Fprint.conf']),
('lib/python-validity/', ['dbus_service/dbus-service']),
Expand Down
7 changes: 6 additions & 1 deletion validitysensor/blobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def __load_blob(blob: str) -> bytes:
elif usb.usb_dev().idProduct == 0x009d:
from . import blobs_9d as blobs
elif usb.usb_dev().idVendor == 0x06cb:
if usb.usb_dev().idProduct == 0x009a:
if usb.usb_dev().idProduct == 0x008a:
from . import blobs_8a as blobs
elif usb.usb_dev().idProduct == 0x009a:
from . import blobs_9a as blobs

globals()[blob] = getattr(blobs, blob)
Expand All @@ -20,3 +22,6 @@ def __load_blob(blob: str) -> bytes:
init_hardcoded_clean_slate = lambda: __load_blob('init_hardcoded_clean_slate')
reset_blob = lambda: __load_blob('reset_blob')
db_write_enable = lambda: __load_blob('db_write_enable')
cmd_02_chunk_30 = lambda: __load_blob('cmd_02_chunk_30')
cmd_02_chunk_43 = lambda: __load_blob('cmd_02_chunk_43')
cmd_06 = lambda: __load_blob('cmd_06')
25 changes: 25 additions & 0 deletions validitysensor/blobs_8a.py

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions validitysensor/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ def get_record_children(self, dbid: int):

def del_record(self, dbid: int):
assert_status(tls.cmd(pack('<BH', 0x48, dbid)))
try:
import glob, os
for p in ['/var/lib/python-validity/templates', '/tmp/python-validity/templates']:
if os.path.isdir(p):
for f in glob.glob(os.path.join(p, f"{dbid}_*.dat")):
try:
os.remove(f)
except:
pass
except:
pass

def db_info(self):
rsp = tls.cmd(b'\x45')
Expand Down
22 changes: 22 additions & 0 deletions validitysensor/generated_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@
calibration_blob=
'0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40414243'
),
SensorTypeInfo(
sensor_type=0x2449,
bytes_per_line=0x98,
repeat_multiplier=2,
lines_per_calibration_data=56,
line_width=144,
calibration_blob=
'0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40414243'
),
SensorTypeInfo(
sensor_type=0x0b4b,
bytes_per_line=0xa0,
Expand Down Expand Up @@ -553,6 +562,19 @@
'330064030000008064200000a10c642000109f0c64200020a20c642000309e0c64200040a30c642000509d0c64200060a40c642000709c0c64200080a60c642000909b0c642000a0a70c642000b09a0c642000c0a80c642000d0990c642000e0a90c642000f0980c64200000af0c64200010950c64200020b00c64200030940c64200040b10c64200050930c64200060b20c64200070920c64200080b30c642000908b0c642000a0b70c642000b08a0c642000c0b80c642000d0890c642000e0b90c642000f0880c64200000ba0c64200010870c64200020bb0c64200030810c64200040bf0c64200050800c64200060c00c642000707f0c64200080c10c642000907e0c642000a0c20c642000b07d0c642000c0c50c642000d0720c642000e0c60c642000f0710c64200000c70c64200010700c64200020c80c642000306f0c64200040c90c642000506d0c642000607a0c642000706c0c64200080790c642000906b0c642000a0780c642000b06a0c642000c06e0c642000d0690c642000e0630c642000f05e0c64200000620c642000105d0c64200020610c642000305c0c64200040600c642000505b0c642000605f0c642000705a0c64200080310c642000904a0c642000a0300c642000b0490c642000c02f0c642000d0480c642000e02e0c642000f0470c642000002d0c64200010460c64200020ca0c642000303b0c64200040cb0c642000503a0c64200060cc0c64200070390c64200080cd0c64200090380c642000a0ce0c642000b02c0c642000c0d00c642000d02b0c642000e0d10c642000f02a0c64200000d20c64200010290c64200020d30c64200030280c64200040d60c642000501c0c64200060d70c642000701b0c64200080d80c642000901a0c642000a0d90c642000b0190c642000c0da0c642000d0150c642000e0df0c642000f0140c64200000e00c64200010130c64200020e10c64200030120c64200040e20c64200050110c64200060e40c642000700e0c64200080e50c642000900d0c642000a0e60c642000b00c0c642000c0e70c642000d00b0c642000e0e80c642000f00a0c64200000ea0c64200010070c64200020eb0c64200030060c64200040ec0c64200050050c64200060ed0c64200070040c64200080ee0c64200090030c642000a0ef0c642000b0020c642000c0f00c642000d0010c642000e0f10c642000f0000c',
'32000c000000008068110100641126003400180200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007e007e0102a13102a13102a120100000620102d0101000007c8078c060b5d00005e00004f80005080006d030059940b07010000240308a1089f08a2089e08a3089d08a4089c08a6089b08a7089a08a8089908a90898c0102c0308af089508b0089408b1089308b2089208b3088b08b7088a08b8088908b90888c0100308ba088708bb088108bf088008c0087f08c1087e08c2087d08c5087208c60871c010062807010308c7087008c8086f08c9086d087a086c0879086b0878086a086e08690863085ec010030862085d0861085c0860085b085f085a0831084a08300849082f0848082e0847c01003082d084608ca083b08cb083a08cc083908cd083808ce082c08d0082b08d1082ac010063007010308d2082908d3082808d6081c08d7081b08d8081a08d9081908da081508df0814c01059940b0308e0081308e1081208e2081108e4080e08e5080d08e6080c08e7080b08e8080ac010240308ea080708eb080608ec080508ed080408ee080308ef080208f0080108f10800c0100c0720070c2003040200004200080002089000000000002f00040038000000290004009000000035000400a0000000'
]),
SensorCaptureProg(
major=0x6,
minor=0x14,
build=0x0,
u1=0x0,
dev_type=0x2449,
a0=0x18,
a1=0x19,
blobs=[
'2300000020000800002000800000010032005c00000000802020040024200000382000002820df0b2c20df0b302000003420000050200a015c200000602000004c2003006c20700070207000742000007820000084202000b4200000bc201400c0200200c4200100c820020074030002330028000000008054202a2203005820272f03004420898103004820868e0300cc200000ef03d0200000ef033200400000000080dc20fa00e020fa00e420b400e820b400f0200500f8200500b8203a00002804001428000008280000082800001428300008280000142831001c281a00',
'330064030000008064200000a10c642000109f0c64200020a20c642000309e0c64200040a30c642000509d0c64200060a40c642000709c0c64200080a60c642000909b0c642000a0a70c642000b09a0c642000c0a80c642000d0990c642000e0a90c642000f0980c64200000af0c64200010950c64200020b00c64200030940c64200040b10c64200050930c64200060b20c64200070920c64200080b30c642000908b0c642000a0b70c642000b08a0c642000c0b80c642000d0890c642000e0b90c642000f0880c64200000ba0c64200010870c64200020bb0c64200030810c64200040bf0c64200050800c64200060c00c642000707f0c64200080c10c642000907e0c642000a0c20c642000b07d0c642000c0c50c642000d0720c642000e0c60c642000f0710c64200000c70c64200010700c64200020c80c642000306f0c64200040c90c642000506d0c642000607a0c642000706c0c64200080790c642000906b0c642000a0780c642000b06a0c642000c06e0c642000d0690c642000e0630c642000f05e0c64200000620c642000105d0c64200020610c642000305c0c64200040600c642000505b0c642000605f0c642000705a0c64200080310c642000904a0c642000a0300c642000b0490c642000c02f0c642000d0480c642000e02e0c642000f0470c642000002d0c64200010460c64200020ca0c642000303b0c64200040cb0c642000503a0c64200060cc0c64200070390c64200080cd0c64200090380c642000a0ce0c642000b02c0c642000c0d00c642000d02b0c642000e0d10c642000f02a0c64200000d20c64200010290c64200020d30c64200030280c64200040d60c642000501c0c64200060d70c642000701b0c64200080d80c642000901a0c642000a0d90c642000b0190c642000c0da0c642000d0150c642000e0df0c642000f0140c64200000e00c64200010130c64200020e10c64200030120c64200040e20c64200050110c64200060e40c642000700e0c64200080e50c642000900d0c642000a0e60c642000b00c0c642000c0e70c642000d00b0c642000e0e80c642000f00a0c64200000ea0c64200010070c64200020eb0c64200030060c64200040ec0c64200050050c64200060ed0c64200070040c64200080ee0c64200090030c642000a0ef0c642000b0020c642000c0f00c642000d0010c642000e0f10c642000f0000c',
'32000c00000000806811010064112600340018020cddc9abce0ce00fc9c700ece5eafef1baabc9ceaea404d1fbf90afee0e20a16f9cceaefbfe7d3e2fbe7a4c2f9b8baeaf419251e1b1907dd2a0c25dd1ef6390ccefe11dde0e5efe7fed3e70c07f4fb073700025a160a0abf1e430cf42d32160a11ef11eae7ddf6e2192316ea04ef2afb55524632e5c9281907ef2dfe3c32751e041125f62ffe0f2f16fe19fb00c416e007e007e0102b26102b26102b240100000620102d0101000007c8078c060b5d00005e00004f80005080006d030059940b07010000240308a1089f08a2089e08a3089d08a4089c08a6089b08a7089a08a8089908a90898c0102c0308af089508b0089408b1089308b2089208b3088b08b7088a08b8088908b90888c0100308ba088708bb088108bf088008c0087f08c1087e08c2087d08c5087208c60871c010062807010308c7087008c8086f08c9086d087a086c0879086b0878086a086e08690863085ec010030862085d0861085c0860085b085f085a0831084a08300849082f0848082e0847c01003082d084608ca083b08cb083a08cc083908cd083808ce082c08d0082b08d1082ac010063007010308d2082908d3082808d6081c08d7081b08d8081a08d9081908da081508df0814c01059940b0308e0081308e1081208e2081108e4080e08e5080d08e6080c08e7080b08e8080ac010240308ea080708eb080608ec080508ed080408ee080308ef080208f0080108f10800c0100c0720070c2003040200004200080002089000000000002f00040038000000290004009000000035000400a0000000'
]),
SensorCaptureProg(
major=0x6,
minor=0x15,
Expand Down
25 changes: 22 additions & 3 deletions validitysensor/init_data_dir.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
import os

PYTHON_VALIDITY_DATA_DIR = '/var/run/python-validity/'
PYTHON_VALIDITY_DATA_DIR = '/var/lib/python-validity/'

def init_data_dir():
if not os.path.isdir(PYTHON_VALIDITY_DATA_DIR):
os.mkdir(PYTHON_VALIDITY_DATA_DIR)
global PYTHON_VALIDITY_DATA_DIR
candidates = [
'/var/lib/python-validity/',
os.path.expanduser('~/.cache/python-validity/'),
'/tmp/python-validity/'
]
for d in candidates:
try:
if not os.path.isdir(d):
os.makedirs(d, mode=0o755, exist_ok=True)
templates_dir = os.path.join(d, 'templates')
if not os.path.isdir(templates_dir):
os.makedirs(templates_dir, mode=0o755, exist_ok=True)
PYTHON_VALIDITY_DATA_DIR = d
return
except PermissionError:
continue
except Exception:
continue

init_data_dir()

Loading