From 1d9ef6d3a1fe24716d54d23a0cd0ab985cb49f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jun 2020 21:17:40 +0200 Subject: [PATCH] vfs0090: Add supports for 138a:0097 as well Given that we can do proper DB check in 0090, we can enable the same code for 0097 as well now. --- README.md | 24 ++++++++++++++++++++---- meson.build | 12 +++++++----- vfs0090.c | 37 ++++++++++++++++++++++++++++++------- 3 files changed, 57 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ff2d266..f60883c 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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.
+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. @@ -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 ``` @@ -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 diff --git a/meson.build b/meson.build index 0bc9e13..54a7ca4 100644 --- a/meson.build +++ b/meson.build @@ -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') ) diff --git a/vfs0090.c b/vfs0090.c index 6d42164..8034faf 100644 --- a/vfs0090.c +++ b/vfs0090.c @@ -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" @@ -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) { @@ -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)) @@ -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; @@ -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++) { @@ -2228,6 +2237,7 @@ 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; @@ -2235,6 +2245,7 @@ finger_image_submit (FpDevice *dev, 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; @@ -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); @@ -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) @@ -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