Skip to content

Commit

Permalink
vfs0090: Add supports for 138a:0097 as well
Browse files Browse the repository at this point in the history
Given that we can do proper DB check in 0090, we can enable the same code
for 0097 as well now.
  • Loading branch information
3v1n0 committed Jun 16, 2020
1 parent 55b7cbe commit 1d9ef6d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## Validity Sensor `138a:0090` libfprint driver
## Validity Sensor `138a:0090` and `138a:0097` libfprint driver
#### A linux driver for 2016 ThinkPad's fingerprint readers

[![See it in action!](https://img.youtube.com/vi/dYe8eKaoUSE/0.jpg)](https://www.youtube.com/watch?v=dYe8eKaoUSE)`

Thanks to the amazing work that [nmikhailov](https://github.com/nmikhailov) did in his [prototype](https://github.com/nmikhailov/Validity90/) and [uunicorn](https://github.com/uunicorn/) in [python-validity](https://github.com/uunicorn/python-validity) and [synaWudfBioUsb-sandbox](https://github.com/uunicorn/synaWudfBioUsb-sandbox), I spent some time in getting a libfprint driver for the `138a:0090` device up...
Thanks to the amazing work that [nmikhailov](https://github.com/nmikhailov) did in his [prototype](https://github.com/nmikhailov/Validity90/) and [uunicorn](https://github.com/uunicorn/) in [python-validity](https://github.com/uunicorn/python-validity) and [synaWudfBioUsb-sandbox](https://github.com/uunicorn/synaWudfBioUsb-sandbox), I spent some time in getting a libfprint driver for the `138a:0090` (and `138a:0097`) device up...

* It only works if the device has been initialized using [validity-sensors-tools/](https://snapcraft.io/validity-sensors-tools/)
- Alernatively, but it's less secure, you can use a Windows installation with VirtualBox (sharing USB) guest or with a Windows installation in bare metal
Expand All @@ -30,12 +30,22 @@ sudo validity-sensors-tools.initializer
# Test the device
sudo validity-sensors-tools.led_test

# See other avilable tools
# This is needed and only works in 138a:0097:
sudo validity-sensors-tools.enroll --finger-id [0-9]

# See other available tools
validity-sensors-tools --help
```

[![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/validity-sensors-tools)

#### Match on Chip

This is the only supported way by `138a:0097`, so once you've enrolled your fingers with `validity-sensors-tools.enroll` you will be able to re-enroll your fingers in fprintd to use them in linux as well.

This unfortunately can't be done in `138a:0090`, but you can still use a Windows installation (even in VirtualBox) to enroll the prints to save them in the chip and enable the match-on-sensor, this can make the verification faster, safer and higher quality.<br />
Unfortunately there's currently no easy way to implement this in this driver without reverse-engineer the fingerprint template creation that the windows drivers does in host.

#### Ubuntu installation

If you're using ubuntu just use [this PPA](https://launchpad.net/~3v1n0/+archive/ubuntu/libfprint-vfs0090) to get the libfprint TOD packages with vfs0090 sensor support.
Expand All @@ -49,7 +59,7 @@ sudo snap install validity-sensors-tools
sudo snap connect validity-sensors-tools:raw-usb
sudo validity-sensors-tools.initializer

# Add the repository and install the tod package
# Add the repository and install the tod package (supports both chips)
sudo add-apt-repository -u ppa:3v1n0/libfprint-vfs0090
sudo apt install libfprint-2-tod-vfs0090
```
Expand All @@ -68,6 +78,12 @@ for finger in {left,right}-{thumb,{index,middle,ring,little}-finger}; do fprintd

#### Help testing

##### `138a:0097`

I've no hardware using that device, so any help is appreciated.

##### `138a:0090`

It would be nice if you could help in tuning the value of the `bz3_threshold`, as that's the value that defines how different should be the prints, and so it's important for having better security. I've set it to `12` currently, but of course increasing the number of prints we enroll or the image quality that could be increased.

Using `fprint_demo` or monitor fprintd from journalctl you should be able to see the values such as `fpi_img_detect_minutiae` and `fpi_img_compare_print_data` in the log, like
Expand Down
12 changes: 7 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ project('libfprint-tod-vfs0090', [ 'c' ],
],
meson_version: '>= 0.46.0')

vfs009x_deps = []
vfs0090_deps = []

libfprint_tod_dep = dependency('libfprint-2-tod-1')
udev_dep = dependency('udev')

vfs0090_deps += libfprint_tod_dep
vfs0090_deps += dependency('nss')
vfs0090_deps += dependency('openssl')
vfs009x_deps += libfprint_tod_dep
vfs009x_deps += dependency('nss')
vfs009x_deps += dependency('openssl')

vfs0090_deps += dependency('pixman-1')

fake_driver = shared_module('fprint-tod-vfs0090',
shared_module('fprint-tod-vfs009x',
sources: [
'vfs0090.c',
],
dependencies: vfs0090_deps,
dependencies: vfs009x_deps + vfs0090_deps,
install: true,
install_dir: libfprint_tod_dep.get_pkgconfig_variable('tod_driversdir')
)
Expand Down
37 changes: 30 additions & 7 deletions vfs0090.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#define FP_COMPONENT "vfs0090"
#define FP_COMPONENT "vfs009x"

#include "drivers_api.h"

Expand Down Expand Up @@ -1651,6 +1651,15 @@ restart_scan_or_deactivate (FpiDeviceVfs0090 *vdev)
dev_deactivate (dev);
}

static gboolean
vfs_device_supports_capture (FpDevice *dev)
{
if (!fp_device_supports_capture (dev))
return FALSE;

return fpi_device_get_driver_data (dev) == FPI_DEVICE_ACTION_CAPTURE;
}

static gboolean
scan_action_succeeded (FpiDeviceVfs0090 *vdev)
{
Expand All @@ -1663,7 +1672,7 @@ finger_db_check_fallbacks_to_image (FpiDeviceVfs0090 *vdev)
FpDevice *dev = FP_DEVICE (vdev);
FpiDeviceAction action;

if (!fp_device_supports_capture (dev))
if (!vfs_device_supports_capture (dev))
return FALSE;

if (scan_action_succeeded (vdev))
Expand Down Expand Up @@ -1765,7 +1774,7 @@ handle_db_match_reply (FpiDeviceVfs0090 *vdev, FpiMatchResult result)
{
fp_dbg ("Finger doesn't match any enrolled finger in DB");

if (fp_device_supports_capture (dev))
if (vfs_device_supports_capture (dev))
/* Returning here will cause fallig back to image enrolling */
return;

Expand Down Expand Up @@ -1851,7 +1860,7 @@ handle_db_match_reply (FpiDeviceVfs0090 *vdev, FpiMatchResult result)
fpi_device_get_identify_data (dev, &templates);

have_image_prints = FALSE;
if (fp_device_supports_capture (dev))
if (vfs_device_supports_capture (dev))
{
for (i = 0; i < templates->len; i++)
{
Expand Down Expand Up @@ -2228,13 +2237,15 @@ finger_image_submit (FpDevice *dev,
img->flags = FPI_IMAGE_H_FLIPPED;
memcpy (img->data, imgdown->image, VFS_IMAGE_SIZE * VFS_IMAGE_SIZE);

#if HAVE_PIXMAN
if (VFS_IMAGE_RESCALE > 1)
{
g_autoptr(FpImage) resized = NULL;

resized = fpi_image_resize (img, VFS_IMAGE_RESCALE, VFS_IMAGE_RESCALE);
g_set_object (&img, resized);
}
#endif

minutiae_data = g_new0 (VfsMinutiaeDetection, 1);
minutiae_data->dev = dev;
Expand Down Expand Up @@ -2621,7 +2632,7 @@ finger_scan_ssm (FpiSsm *ssm, FpDevice *dev)
break;

case SCAN_STATE_SUCCESS:
if (fp_device_supports_capture (dev))
if (vfs_device_supports_capture (dev))
start_finger_image_download_subsm (dev, ssm);
else
start_finger_db_check_subsm (dev, ssm);
Expand Down Expand Up @@ -2794,6 +2805,13 @@ dev_activate (FpDevice *dev)
{
gboolean wait_for_finger;

if (!vfs_device_supports_capture (dev))
{
fpi_device_action_error (dev,
fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED));
return;
}

fpi_device_get_capture_data (dev, &wait_for_finger);

if (!wait_for_finger)
Expand Down Expand Up @@ -3088,13 +3106,18 @@ dev_cancel (FpDevice *dev)

/* Usb id table of device */
static const FpIdEntry id_table[] = {
{ .vid = 0x138a, .pid = 0x0090 },
{ .vid = 0x138a, .pid = 0x0090, .driver_data = FPI_DEVICE_ACTION_CAPTURE },
{ .vid = 0x138a, .pid = 0x0097, .driver_data = FPI_DEVICE_ACTION_NONE },
{ .vid = 0, .pid = 0, .driver_data = 0 },
};

static void
fpi_device_vfs0090_init (FpiDeviceVfs0090 *self)
fpi_device_vfs0090_init (FpiDeviceVfs0090 *vdev)
{
FpDevice *dev = FP_DEVICE (vdev);

if (!vfs_device_supports_capture (dev))
fpi_device_set_nr_enroll_stages (dev, 1);
}

static void
Expand Down

0 comments on commit 1d9ef6d

Please sign in to comment.