├── .ci └── check-abi ├── .gitignore ├── .gitlab-ci.yml ├── .gitlab-ci ├── libfprint-templates.yaml └── scan-build ├── .gitmodules ├── AUTHORS ├── COPYING ├── HACKING.md ├── INSTALL ├── MAINTAINERS ├── NEWS ├── README ├── README.md ├── THANKS ├── TODO ├── code-of-conduct.md ├── demo ├── gtk-libfprint-test.c ├── gtk-libfprint-test.gresource.xml ├── gtk-libfprint-test.ui ├── meson.build ├── org.freedesktop.libfprint.Demo.appdata.xml ├── org.freedesktop.libfprint.Demo.desktop ├── org.freedesktop.libfprint.Demo.json └── org.freedesktop.libfprint.Demo.png ├── doc ├── advanced-topics.xml ├── getting-started.xml ├── intro.xml ├── libfprint-2-sections.txt ├── libfprint-docs.xml ├── libfprint-sections.txt-new-manual ├── meson.build └── xml │ ├── gtkdocentities.ent.in │ └── meson.build ├── examples ├── cpp-test.cpp ├── enroll.c ├── manage-prints.c ├── meson.build ├── prints │ ├── README │ ├── arch.jpg │ ├── arch.png │ ├── loop-right.jpg │ ├── loop-right.png │ ├── tented_arch.jpg │ ├── tented_arch.png │ ├── whorl.jpg │ └── whorl.png ├── sendvirtimg.py ├── storage.c ├── storage.h ├── utilities.c ├── utilities.h └── verify.c ├── libfprint ├── drivers │ ├── aes1610.c │ ├── aes1660.c │ ├── aes1660.h │ ├── aes2501.c │ ├── aes2501.h │ ├── aes2550.c │ ├── aes2550.h │ ├── aes2660.c │ ├── aes2660.h │ ├── aes3500.c │ ├── aes3k.c │ ├── aes3k.h │ ├── aes4000.c │ ├── aeslib.c │ ├── aeslib.h │ ├── aesx660.c │ ├── aesx660.h │ ├── elan.c │ ├── elan.h │ ├── etes603.c │ ├── synaptics │ │ ├── bmkt.h │ │ ├── bmkt_message.c │ │ ├── bmkt_message.h │ │ ├── bmkt_response.h │ │ ├── sensor.h │ │ ├── synaptics.c │ │ └── synaptics.h │ ├── upek_proto.c │ ├── upek_proto.h │ ├── upeksonly.c │ ├── upeksonly.h │ ├── upektc.c │ ├── upektc.h │ ├── upektc_img.c │ ├── upektc_img.h │ ├── upekts.c │ ├── uru4000.c │ ├── vcom5s.c │ ├── vfs0050.c │ ├── vfs0050.h │ ├── vfs101.c │ ├── vfs301.c │ ├── vfs301.h │ ├── vfs301_proto.c │ ├── vfs301_proto_fragments.h │ ├── vfs5011.c │ ├── vfs5011_proto.h │ └── virtual-image.c ├── drivers_api.h ├── empty_file ├── fp-context.c ├── fp-context.h ├── fp-device-private.h ├── fp-device.c ├── fp-device.h ├── fp-image-device-private.h ├── fp-image-device.c ├── fp-image-device.h ├── fp-image.c ├── fp-image.h ├── fp-print-private.h ├── fp-print.c ├── fp-print.h ├── fpi-assembling.c ├── fpi-assembling.h ├── fpi-byte-reader.c ├── fpi-byte-reader.h ├── fpi-byte-utils.h ├── fpi-byte-writer.c ├── fpi-byte-writer.h ├── fpi-compat.h ├── fpi-context.h ├── fpi-device.c ├── fpi-device.h ├── fpi-image-device.c ├── fpi-image-device.h ├── fpi-image.c ├── fpi-image.h ├── fpi-log.h ├── fpi-minutiae.h ├── fpi-print.c ├── fpi-print.h ├── fpi-ssm.c ├── fpi-ssm.h ├── fpi-usb-transfer.c ├── fpi-usb-transfer.h ├── fprint-list-supported-devices.c ├── fprint-list-udev-rules.c ├── fprint.h ├── libfprint.ver ├── meson.build └── nbis │ ├── bozorth3 │ ├── bozorth3.c │ ├── bz_alloc.c │ ├── bz_drvrs.c │ ├── bz_gbls.c │ ├── bz_io.c │ └── bz_sort.c │ ├── fix-scan-build-reports.patch │ ├── glib-mem-warning.patch │ ├── glib-memory.cocci │ ├── include │ ├── bozorth.h │ ├── bz_array.h │ ├── defs.h │ ├── lfs.h │ ├── log.h │ ├── meson.build │ ├── morph.h │ ├── mytime.h │ └── sunrast.h │ ├── lfs.h.patch │ ├── libfprint-include │ ├── meson.build │ ├── nbis-helpers.h │ └── nbis.h │ ├── mindtct │ ├── binar.c │ ├── block.c │ ├── chaincod.c │ ├── contour.c │ ├── detect.c │ ├── dft.c │ ├── free.c │ ├── getmin.c │ ├── globals.c │ ├── imgutil.c │ ├── init.c │ ├── line.c │ ├── link.c │ ├── log.c │ ├── loop.c │ ├── maps.c │ ├── matchpat.c │ ├── minutia.c │ ├── morph.c │ ├── quality.c │ ├── remove.c │ ├── ridges.c │ ├── shape.c │ ├── sort.c │ ├── util.c │ └── xytreps.c │ ├── remove-function.lua │ ├── remove-global-y.cocci │ ├── remove-perimeter-pts.patch │ └── update-from-nbis.sh ├── meson.build ├── meson_options.txt ├── scripts ├── uncrustify.cfg └── uncrustify.sh └── tests ├── README-umockdev ├── README.md ├── capture.py ├── elan ├── capture.ioctl ├── capture.ioctl-recording ├── capture.png └── device ├── meson.build ├── synaptics ├── custom-recorded.ioctl ├── custom.ioctl ├── custom.py └── device ├── test-device-fake.c ├── test-device-fake.h ├── test-fp-context.c ├── test-fp-device.c ├── test-fpi-assembling.c ├── test-fpi-device.c ├── test-fpi-ssm.c ├── test-runner.sh ├── test-utils.c ├── test-utils.h ├── umockdev-test.py ├── unittest_inspector.py ├── valgrind-python.supp ├── vfs0050 ├── capture-recorded.ioctl ├── capture.ioctl ├── capture.png └── device ├── vfs5011 ├── capture.ioctl ├── capture.png └── device └── virtual-image.py /.ci/check-abi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | 4 | import argparse 5 | import contextlib 6 | import os 7 | import shutil 8 | import subprocess 9 | import sys 10 | 11 | 12 | def format_title(title): 13 | box = { 14 | 'tl': '╔', 'tr': '╗', 'bl': '╚', 'br': '╝', 'h': '═', 'v': '║', 15 | } 16 | hline = box['h'] * (len(title) + 2) 17 | 18 | return '\n'.join([ 19 | f"{box['tl']}{hline}{box['tr']}", 20 | f"{box['v']} {title} {box['v']}", 21 | f"{box['bl']}{hline}{box['br']}", 22 | ]) 23 | 24 | 25 | def rm_rf(path): 26 | try: 27 | shutil.rmtree(path) 28 | except FileNotFoundError: 29 | pass 30 | 31 | 32 | def sanitize_path(name): 33 | return name.replace('/', '-') 34 | 35 | 36 | def get_current_revision(): 37 | revision = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], 38 | encoding='utf-8').strip() 39 | 40 | if revision == 'HEAD': 41 | # This is a detached HEAD, get the commit hash 42 | revision = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip().decode('utf-8') 43 | 44 | return revision 45 | 46 | 47 | @contextlib.contextmanager 48 | def checkout_git_revision(revision): 49 | current_revision = get_current_revision() 50 | subprocess.check_call(['git', 'checkout', '-q', revision]) 51 | 52 | try: 53 | yield 54 | finally: 55 | subprocess.check_call(['git', 'checkout', '-q', current_revision]) 56 | 57 | 58 | def build_install(revision): 59 | build_dir = '_build' 60 | dest_dir = os.path.abspath(sanitize_path(revision)) 61 | print(format_title(f'# Building and installing {revision} in {dest_dir}'), 62 | end='\n\n', flush=True) 63 | 64 | with checkout_git_revision(revision): 65 | rm_rf(build_dir) 66 | rm_rf(revision) 67 | 68 | subprocess.check_call(['meson', build_dir, 69 | '--prefix=/usr', '--libdir=lib', 70 | '-Dx11-examples=false', '-Ddoc=false', '-Dgtk-examples=false']) 71 | subprocess.check_call(['ninja', '-v', '-C', build_dir]) 72 | subprocess.check_call(['ninja', '-v', '-C', build_dir, 'install'], 73 | env={'DESTDIR': dest_dir}) 74 | 75 | return dest_dir 76 | 77 | 78 | def compare(old_tree, new_tree): 79 | print(format_title(f'# Comparing the two ABIs'), end='\n\n', flush=True) 80 | 81 | old_headers = os.path.join(old_tree, 'usr', 'include') 82 | old_lib = os.path.join(old_tree, 'usr', 'lib', 'libfprint.so') 83 | 84 | new_headers = os.path.join(new_tree, 'usr', 'include') 85 | new_lib = os.path.join(new_tree, 'usr', 'lib', 'libfprint.so') 86 | 87 | subprocess.check_call([ 88 | 'abidiff', '--headers-dir1', old_headers, '--headers-dir2', new_headers, 89 | '--drop-private-types', '--fail-no-debug-info', '--no-added-syms', old_lib, new_lib]) 90 | 91 | 92 | if __name__ == '__main__': 93 | parser = argparse.ArgumentParser() 94 | 95 | parser.add_argument('old', help='the previous revision, considered the reference') 96 | parser.add_argument('new', help='the new revision, to compare to the reference') 97 | 98 | args = parser.parse_args() 99 | 100 | if args.old == args.new: 101 | print("Let's not waste time comparing something to itself") 102 | sys.exit(0) 103 | 104 | old_tree = build_install(args.old) 105 | new_tree = build_install(args.new) 106 | 107 | try: 108 | compare(old_tree, new_tree) 109 | 110 | except Exception: 111 | sys.exit(1) 112 | 113 | print(f'Hurray! {args.old} and {args.new} are ABI-compatible!') 114 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.swp 3 | _build 4 | -------------------------------------------------------------------------------- /.gitlab-ci/libfprint-templates.yaml: -------------------------------------------------------------------------------- 1 | .libfprint_common_variables: 2 | LIBFPRINT_DEPENDENCIES: 3 | doxygen 4 | flatpak-builder 5 | gcc 6 | gcc-c++ 7 | gcovr 8 | git 9 | glib2-devel 10 | glibc-devel 11 | gobject-introspection-devel 12 | gtk-doc 13 | gtk3-devel 14 | libabigail 15 | libgusb-devel 16 | libX11-devel 17 | libXv-devel 18 | meson 19 | nss-devel 20 | pixman-devel 21 | python3-cairo 22 | python3-gobject 23 | systemd 24 | umockdev 25 | uncrustify 26 | valgrind 27 | clang-analyzer 28 | -------------------------------------------------------------------------------- /.gitlab-ci/scan-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This wrapper just disables the malloc checker 4 | exec /usr/bin/scan-build -disable-checker unix.Malloc "$@" -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vfs0090 driver"] 2 | path = libfprint/drivers/vfs0090 3 | url = https://github.com/3v1n0/libfprint-tod-vfs0090.git 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Copyright (C) 2007 Daniel Drake 2 | Copyright (C) 2006-2007 Timo Hoenig 3 | Copyright (C) 2006 Pavel Machek 4 | Copyright (C) 1999 Erik Walthinsen 5 | Copyright (C) 2004,2006 Thomas Vander Stichele 6 | Copyright (C) 2007 Cyrille Bagard 7 | Copyright (C) 2007-2008,2012 Vasily Khoruzhick 8 | Copyright (C) 2007 Jan-Michael Brummer 9 | Copyright (C) 2007 Anthony Bretaudeau 10 | Copyright (C) 2010 Hugo Grostabussiat 11 | Copyright (C) 2012 Timo Teräs 12 | Copyright (C) 2017 Nikita Mikhailov 13 | Copyright (C) 2018 Marco Trevisan 14 | -------------------------------------------------------------------------------- /HACKING.md: -------------------------------------------------------------------------------- 1 | # Contributing to libfprint 2 | 3 | ## GLib 4 | 5 | Although the library uses GLib internally, libfprint is designed to provide 6 | a completely neutral interface to its application users. So, the public 7 | APIs should never return GLib data types. 8 | 9 | ## License clarification 10 | 11 | Although this library's license could allow for shims that hook up into 12 | proprietary blobs to add driver support for some unsupported devices, the 13 | intent of the original authors, and of current maintainers of the library, 14 | was for this license to allow _integration into_ proprietary stacks, not 15 | _integration of_ proprietary code in the library. 16 | 17 | As such, no code to integrate proprietary drivers will be accepted in libfprint 18 | upstream. Proprietary drivers would make it impossible to debug problems in 19 | libfprint, as we wouldn't know what the proprietary driver does behind the 20 | library's back. The closed source nature of drivers is usually used to hide 21 | parts of the hardware setup, such as encryption keys, or protocols, in order 22 | to protect the hardware's integrity. Unfortunately, this is only [security through 23 | obscurity](https://en.wikipedia.org/wiki/Security_through_obscurity). 24 | 25 | We however encourage potential contributors to take advantage of libfprint's 26 | source availability to create such shims to make it easier to reverse-engineer 27 | proprietary drivers in order to create new free software drivers, to the extent 28 | permitted by local laws. 29 | 30 | ## Two-faced-ness 31 | 32 | Like any decent library, this one is designed to provide a stable and 33 | documented API to its users: applications. Clear distinction is made between 34 | data available internally in the library, and data/functions available to 35 | the applications. 36 | 37 | This library is confused a little by the fact that there is another 'interface' 38 | at hand: the internal interface provided to drivers. So, we effectively end 39 | up with 2 APIs: 40 | 41 | 1. The [external-facing API for applications](libfprint/fprint.h) 42 | 2. The [internal API for fingerprint drivers](libfprint/drivers_api.h) 43 | 44 | Non-static functions which are intended for internal use only are prepended 45 | with the "fpi_" prefix. 46 | 47 | ## Documentation 48 | 49 | All additions of public API functions must be accompanied with gtk-doc 50 | comments. 51 | 52 | All changes which potentially change the behaviour of the public API must 53 | be reflected by updating the appropriate gtk-doc comments. 54 | 55 | 56 | ## Contributing 57 | 58 | Patches should be sent as merge requests to the gitlab page: 59 | https://gitlab.freedesktop.org/libfprint/libfprint/merge_requests 60 | 61 | Drivers are not usually written by libfprint developers, but when they 62 | are, we require: 63 | - 3 stand-alone devices. Not in a laptop or another embedded device, as 64 | space is scarce, unless the device has special integration with that 65 | hardware. 66 | - specifications of the protocol. 67 | 68 | If you are an end-user, you can file a feature request with the "Driver Request" 69 | tag on [libfprint's issue page](https://gitlab.freedesktop.org/libfprint/libfprint/issues?scope=all&utf8=%E2%9C%93&state=opened&label_name[]=Driver%20Request), 70 | or subscribe to an existing feature request there. 71 | 72 | If you are an enterprising hacker, please file a new merge request with 73 | the driver patches integrated. 74 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | libfprint uses the Meson build system. See 2 | http://mesonbuild.com/Quick-guide.html for details on how to 3 | compile libfprint. 4 | 5 | The "meson configure" command will give you a list of available 6 | command-line options. 7 | -------------------------------------------------------------------------------- /MAINTAINERS: -------------------------------------------------------------------------------- 1 | Current maintainers of libfprint are: 2 | 3 | * Benjamin Berg 4 | * Marco Trevisan (Treviño) 5 | 6 | Many drivers are not actively maintained and may not be fully functional. 7 | We are happy to receive contributions, but the support we can give is 8 | limitted unfortunately. For many drivers we may not even have test devices. 9 | 10 | Maintained drivers are: 11 | * synaptics: 12 | Contributed and maintained by Synaptics Inc. 13 | Contact: Vincent Huang 14 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | libfprint 2 | ========= 3 | 4 | libfprint is part of the fprint project: 5 | https://fprint.freedesktop.org/ 6 | 7 | libfprint was originally developed as part of an academic project at the 8 | University of Manchester with the aim of hiding differences between different 9 | consumer fingerprint scanners and providing a single uniform API to application 10 | developers. The ultimate goal of the fprint project is to make fingerprint 11 | scanners widely and easily usable under common Linux environments. 12 | 13 | The academic university project runs off a codebase maintained separately 14 | from this one, although I try to keep them as similar as possible (I'm not 15 | hiding anything in the academic branch, it's just the open source release 16 | contains some commits excluded from the academic project). 17 | 18 | THE UNIVERSITY OF MANCHESTER DOES NOT ENDORSE THIS THIS SOFTWARE RELEASE AND 19 | IS IN NO WAY RESPONSIBLE FOR THE CODE CONTAINED WITHIN, OR ANY DAMAGES CAUSED 20 | BY USING OR DISTRIBUTING THE SOFTWARE. Development does not happen on 21 | university computers and the project is not hosted at the university either. 22 | 23 | For more information on libfprint, supported devices, API documentation, etc., 24 | see the homepage: 25 | https://fprint.freedesktop.org/ 26 | 27 | libfprint is licensed under the GNU LGPL version 2.1. See the COPYING file 28 | for the license text. 29 | 30 | Section 6 of the license states that for compiled works that use this 31 | library, such works must include libfprint copyright notices alongside the 32 | copyright notices for the other parts of the work. We have attempted to 33 | make this process slightly easier for you by grouping these all in one place: 34 | the AUTHORS file. 35 | 36 | libfprint includes code from NIST's NBIS software distribution: 37 | http://fingerprint.nist.gov/NBIS/index.html 38 | We include bozorth3 from the US export controlled distribution. We have 39 | determined that it is fine to ship bozorth3 in an open source project, 40 | see https://fprint.freedesktop.org/us-export-control.html 41 | 42 | ## Historical links 43 | 44 | Older versions of libfprint are available at: 45 | https://sourceforge.net/projects/fprint/files/ 46 | 47 | Historical mailing-list archives: 48 | http://www.reactivated.net/fprint_list_archives/ 49 | 50 | Historical website: 51 | http://web.archive.org/web/*/https://www.freedesktop.org/wiki/Software/fprint/ 52 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | Tony Vroon - hardware donations 2 | Gerrie Mansur from Security Database BV (http://www.securitydatabase.net/) - hardware donations 3 | Joaquin Custodio - hardware donations 4 | TimeTrex (http://www.timetrex.com/) - hardware donations 5 | Craig Watson (NIST) 6 | James Vasile (SFLC) 7 | Toby Howard (University of Manchester) 8 | Seemant Kulleen 9 | Pavel Herrman 10 | Bastien Nocera 11 | Greg Kerr and Martin Konecny from AuthenTec Inc - hardware donations (AES2550 device), datasheets for AES2550 and AES2810 12 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | ======= 3 | test suite against NFIQ compliance set 4 | make library optionally asynchronous and maybe thread-safe 5 | nbis cleanups 6 | API function to determine if img device supports uncond. capture 7 | race-free way of saying "save this print but don't overwrite" 8 | 9 | NEW DRIVERS 10 | =========== 11 | Sunplus 895 driver 12 | AES3400/3500 driver 13 | ID Mouse driver 14 | Support for 2nd generation MS devices 15 | Support for 2nd generation UPEK devices 16 | 17 | IMAGING 18 | ======= 19 | ignore first frame or two with aes2501 20 | aes2501: increase threshold "sum" for end-of-image detection 21 | aes2501 gain calibration 22 | aes4000 gain calibration 23 | aes4000 resampling 24 | PPMM parameter to get_minutiae seems to have no effect 25 | nbis minutiae should be stored in endian-independent format 26 | 27 | PORTABILITY 28 | =========== 29 | OpenBSD can't do -Wshadow or visibility 30 | OpenBSD: add compat codes for ENOTSUP ENODATA and EPROTO 31 | -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | This project and its community follow the [Freedesktop.org code of conduct] 2 | 3 | [Freedesktop.org code of conduct]: https://www.freedesktop.org/wiki/CodeOfConduct/ 4 | -------------------------------------------------------------------------------- /demo/gtk-libfprint-test.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | gtk-libfprint-test.ui 5 | 6 | 7 | -------------------------------------------------------------------------------- /demo/meson.build: -------------------------------------------------------------------------------- 1 | gtk_test_resources = gnome.compile_resources('gtk-test-resources', 2 | 'gtk-libfprint-test.gresource.xml', 3 | source_dir : '.', 4 | c_name : 'gtk_test') 5 | 6 | prefix = get_option('prefix') 7 | bindir = join_paths(prefix, get_option('bindir')) 8 | datadir = join_paths(prefix, get_option('datadir')) 9 | 10 | executable('gtk-libfprint-test', 11 | [ 'gtk-libfprint-test.c', gtk_test_resources ], 12 | dependencies: [ 13 | gtk_dep, 14 | libfprint_dep, 15 | ], 16 | c_args: '-DPACKAGE_VERSION="' + meson.project_version() + '"', 17 | install: true, 18 | install_dir: bindir) 19 | 20 | appdata = 'org.freedesktop.libfprint.Demo.appdata.xml' 21 | install_data(appdata, 22 | install_dir: join_paths(datadir, 'metainfo')) 23 | 24 | desktop = 'org.freedesktop.libfprint.Demo.desktop' 25 | install_data(desktop, 26 | install_dir: join_paths(datadir, 'applications')) 27 | 28 | icon = 'org.freedesktop.libfprint.Demo.png' 29 | install_data(icon, 30 | install_dir: join_paths(datadir, 'icons')) 31 | -------------------------------------------------------------------------------- /demo/org.freedesktop.libfprint.Demo.appdata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.freedesktop.libfprint.Demo.desktop 4 | Fingerprint Reader Demo 5 | Test fingerprint readers 6 | CC0-1.0 7 | LGPL-2.1+ 8 | 9 |

10 | Fingerprint Reader Demo is a test application for the libfprint 11 | fingerprint reader library. Its purpose is to test drivers, new and old, 12 | in a sandbox, to make sure that the drivers and associated functions 13 | work correctly. 14 |

15 |

16 | Fingerprint Reader Demo does not modify the system, or replace integration 17 | in desktop environments. 18 |

19 |
20 | https://fprint.freedesktop.org 21 | 22 | https://git.gnome.org/browse/totem/plain/data/appdata/ss-main.png 23 | https://git.gnome.org/browse/totem/plain/data/appdata/ss-music-playlist.png 24 | 25 | hadess@hadess.net 26 | 27 | libfprint 28 |
29 | -------------------------------------------------------------------------------- /demo/org.freedesktop.libfprint.Demo.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Fingerprint Reader Demo 3 | Comment=Test fingerprint readers 4 | Keywords=finger;print;fingerprint;fprint;demo;driver;reader; 5 | Exec=gtk-libfprint-test 6 | Icon=org.freedesktop.libfprint.Demo 7 | Terminal=false 8 | Type=Application 9 | Categories=GTK;GNOME;Development;System; 10 | StartupNotify=true 11 | -------------------------------------------------------------------------------- /demo/org.freedesktop.libfprint.Demo.json: -------------------------------------------------------------------------------- 1 | { 2 | "app-id": "org.freedesktop.libfprint.Demo", 3 | "runtime": "org.gnome.Platform", 4 | "runtime-version": "3.32", 5 | "sdk": "org.gnome.Sdk", 6 | "command": "gtk-libfprint-test", 7 | "finish-args": [ 8 | /* X11 + XShm access */ 9 | "--share=ipc", "--socket=x11", 10 | /* Wayland access */ 11 | "--socket=wayland", 12 | /* OpenGL access */ 13 | "--device=dri", 14 | /* USB access */ 15 | "--device=all" 16 | ], 17 | "cleanup": [ "/include", "/lib/pkgconfig/" ], 18 | "modules": [ 19 | { 20 | "name": "libusb", 21 | "config-opts": [ "--disable-static", "--disable-udev" ], 22 | "cleanup": [ 23 | "/lib/*.la", 24 | "/lib/pkgconfig", 25 | "/include" 26 | ], 27 | "sources": [ 28 | { 29 | "type": "archive", 30 | "url": "https://github.com/libusb/libusb/archive/v1.0.22.tar.gz", 31 | "sha256": "3500f7b182750cd9ccf9be8b1df998f83df56a39ab264976bdb3307773e16f48" 32 | } 33 | ], 34 | "post-install": [ 35 | "install -Dm644 COPYING /app/share/licenses/libgusb/COPYING" 36 | ] 37 | }, 38 | { 39 | "name": "libgusb", 40 | "buildsystem": "meson", 41 | "config-opts": [ "-Dtests=false", "-Dvapi=false", "-Ddocs=false", "-Dintrospection=false" ], 42 | "sources": [ 43 | { 44 | "type": "archive", 45 | "url": "https://github.com/hughsie/libgusb/archive/0.3.0.tar.gz", 46 | "sha256": "b36310f8405d5fd68f6caf4a829f7ab4c627b38fd3d02a139d411fce0f3a49f1" 47 | } 48 | ] 49 | }, 50 | { 51 | "name": "libfprint", 52 | "buildsystem": "meson", 53 | "config-opts": [ "-Dudev_rules=false", "-Dx11-examples=false", "-Dgtk-examples=true", "-Ddrivers=all" ], 54 | "sources": [ 55 | { 56 | "type": "git", 57 | "url": "https://gitlab.freedesktop.org/libfprint/libfprint.git", 58 | "branch": "wip/benzea/v2" 59 | } 60 | ] 61 | } 62 | ] 63 | } 64 | -------------------------------------------------------------------------------- /demo/org.freedesktop.libfprint.Demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/demo/org.freedesktop.libfprint.Demo.png -------------------------------------------------------------------------------- /doc/getting-started.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Getting Started 7 | 8 | 9 | libfprint includes several simple functional examples under the examples/ 10 | directory in the libfprint source distribution. Those are good starting 11 | points. 12 | 13 | 14 | 15 | Usually the first thing you want to do is determine which fingerprint 16 | devices are present. This is done using the FpContext object. 17 | 18 | 19 | 20 | Once you have found a device you would like to operate, you should open it. 21 | Refer to device operations. This section also details enrollment, 22 | image capture, and verification. 23 | 24 | 25 | 26 | That should be enough to get you started, but do remember there are 27 | documentation pages on other aspects of libfprint's API (see the modules 28 | page). 29 | 30 | 31 | -------------------------------------------------------------------------------- /doc/intro.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Introduction 7 | 8 | 9 | libfprint is an open source library to provide access to fingerprint 10 | scanning devices. For more info, see the 11 | libfprint project homepage. 12 | 13 | 14 | 15 | This documentation is aimed at application developers who wish to integrate 16 | fingerprint-related functionality into their software. libfprint has been 17 | designed so that you only have to do this once – by integrating your 18 | software with libfprint, you'll be supporting all the fingerprint readers 19 | that we have got our hands on. As such, the API is rather general (and 20 | therefore hopefully easy to comprehend!), and does its best to hide the 21 | technical details that required to operate the hardware. 22 | 23 | 24 | 25 | This documentation is not aimed at developers wishing to develop and 26 | contribute fingerprint device drivers to libfprint. 27 | 28 | 29 | 30 | Feedback on this API and its associated documentation is appreciated. Was 31 | anything unclear? Does anything seem unreasonably complicated? Is anything 32 | missing? Let us know on the 33 | mailing list. 34 | 35 | 36 | 37 | Enrollment 38 | 39 | 40 | Before you dive into the API, it's worth introducing a couple of concepts. 41 | 42 | 43 | 44 | The process of enrolling a finger is where you effectively scan your 45 | finger for the purposes of teaching the system what your finger looks like. 46 | This means that you scan your fingerprint, then the system processes it and 47 | stores some data about your fingerprint to refer to later. 48 | 49 | 50 | 51 | 52 | Verification 53 | 54 | 55 | Verification is what most people think of when they think about fingerprint 56 | scanning. The process of verification is effectively performing a fresh 57 | fingerprint scan, and then comparing that scan to a finger that was 58 | previously enrolled. 59 | 60 | 61 | 62 | As an example scenario, verification can be used to implement what people 63 | would picture as fingerprint login (i.e. fingerprint replaces password). 64 | For example: 65 | 66 | 67 | 68 | I enroll my fingerprint through some software that trusts I am who I say 69 | I am. This is a prerequisite before I can perform fingerprint-based 70 | login for my account. 71 | 72 | 73 | Some time later, I want to login to my computer. I enter my username, 74 | but instead of prompting me for a password, it asks me to scan my finger. 75 | I scan my finger. 76 | 77 | 78 | The system compares the finger I just scanned to the one that was 79 | enrolled earlier. If the system decides that the fingerprints match, 80 | I am successfully logged in. Otherwise, the system informs me that I am 81 | not authorised to login as that user. 82 | 83 | 84 | 85 | 86 | 87 | Identification 88 | 89 | 90 | Identification is the process of comparing a freshly scanned fingerprint 91 | to a collection of previously enrolled fingerprints. For example, 92 | imagine there are 100 people in an organisation, and they all have enrolled 93 | their fingerprints. One user walks up to a fingerprint scanner and scans 94 | their finger. With no other knowledge of who that user might be, 95 | the system examines their fingerprint, looks in the database, and determines 96 | that the user is user number #61. 97 | 98 | 99 | 100 | In other words, verification might be seen as a one-to-one fingerprint 101 | comparison where you know the identity of the user that you wish to 102 | authenticate, whereas identification is a one-to-many comparison where you 103 | do not know the identity of the user that you wish to authenticate. 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /doc/libfprint-docs.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | ]> 7 | 8 | 9 | libfprint Reference Manual 10 | 11 | This document is the API reference for the libfprint library. 12 | 13 | The latest version of libfprint, as well as the latest version of 14 | this API reference, is available online. 15 | 16 | 17 | 18 | 19 | 20 | Library Overview 21 | 22 | 23 | 24 | 25 | 26 | 27 | Library API Documentation 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | Writing Drivers 37 | 38 | Device methods for drivers 39 | 40 | 41 | 42 | 43 | 44 | USB and State Machine helpers 45 | 46 | 47 | 48 | 49 | 50 | 51 | Image manipulation 52 | 53 | 54 | 55 | 56 | 57 | Print handling 58 | 59 | 60 | 61 | 62 | Listing drivers 63 | 64 | 65 | 66 | 67 | 68 | API Index 69 | 70 | 71 | 72 | Index of deprecated API 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /doc/libfprint-sections.txt-new-manual: -------------------------------------------------------------------------------- 1 | 2 |
3 | fprint.h 4 | context 5 | Device discovery and hotplugging 6 | FP_TYPE_CONTEXT 7 | FpContext 8 | fp_context_new 9 | fp_context_enumerate 10 | fp_context_get_devices 11 |
12 | 13 | 14 |
15 | fprint.h 16 | device 17 | Device 18 | FP_TYPE_DEVICE 19 | FpDevice 20 | FpDeviceType 21 | FpScanType 22 | FpDeviceRetry 23 | FpDeviceError 24 | FP_DEVICE_ERROR 25 | FP_DEVICE_RETRY 26 | fp_device_get_driver 27 | fp_device_get_device_id 28 | fp_device_get_name 29 | fp_device_get_scan_type 30 | 31 | fp_device_open 32 | fp_device_open_finish 33 | fp_device_open_sync 34 | 35 | fp_device_close 36 | fp_device_close_finish 37 | fp_device_close_sync 38 | 39 | fp_device_enroll 40 | fp_device_enroll_finish 41 | fp_device_enroll_sync 42 | 43 | fp_device_identify 44 | fp_device_identify_finish 45 | fp_device_identify_sync 46 | 47 | fp_device_capture 48 | fp_device_capture_finish 49 | fp_device_capture_sync 50 | 51 | fp_device_verify 52 | fp_device_verify_finish 53 | fp_device_verify_sync 54 | 55 | _fp_device_get_cancellable 56 |
57 | 58 | 59 |
60 | fprint.h 61 | print 62 | Fingerprint handling 63 | FpPrint 64 | fp_print_new 65 |
66 | 67 | 68 |
69 | fprint.h 70 | image 71 | Image handling 72 | FP_TYPE_IMAGE 73 | FpImage 74 | fp_image_new 75 | fp_image_detect_minutiae 76 | fp_image_detect_minutiae_finish 77 | fp_image_device_new 78 | fp_image_get_binarized 79 | fp_image_get_data 80 | fp_image_get_height 81 | fp_image_get_minutiae 82 | fp_image_get_ppmm 83 | fp_image_get_width 84 |
85 | 86 | 87 |
88 | internal-image-device 89 | drivers_api.h 90 | Base class for image devices 91 | FpImageDevice 92 | FpImageDeviceClass 93 | FpiImageDeviceState 94 |
95 | 96 |
97 | internal-usb-transfers 98 | drivers_api.h 99 | USB Transfers 100 | FpUsbTransfer 101 | fp_usb_transfer_fill_bulk 102 | fp_usb_transfer_fill_bulk_full 103 | fp_usb_transfer_fill_control 104 | fp_usb_transfer_fill_interrupt 105 | fp_usb_transfer_fill_interrupt_full 106 | fp_usb_transfer_get_type 107 | fp_usb_transfer_new 108 | fp_usb_transfer_ref 109 | fp_usb_transfer_set_short_error 110 | fp_usb_transfer_submit 111 | fp_usb_transfer_submit_sync 112 | fp_usb_transfer_unref 113 | FpUsbTransferCallback 114 | FP_USB_ENDPOINT_IN 115 | FP_USB_ENDPOINT_OUT 116 |
117 | -------------------------------------------------------------------------------- /doc/meson.build: -------------------------------------------------------------------------------- 1 | subdir('xml') 2 | 3 | private_headers = [ 4 | 'config.h', 5 | 'nbis-helpers.h', 6 | 'fprint.h', 7 | 8 | # Subdirectories to ignore 9 | 'drivers', 10 | 'nbis', 11 | ] 12 | 13 | html_images = [ 14 | ] 15 | 16 | content_files = [ 17 | 'intro.xml' 18 | ] 19 | 20 | expand_content_files = content_files 21 | 22 | glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix') 23 | glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html') 24 | docpath = join_paths(get_option('datadir'), 'gtk-doc', 'html') 25 | 26 | gnome.gtkdoc(versioned_libname, 27 | main_xml: 'libfprint-docs.xml', 28 | src_dir: join_paths(meson.source_root(), 'libfprint'), 29 | dependencies: libfprint_dep, 30 | content_files: content_files, 31 | expand_content_files: expand_content_files, 32 | ignore_headers: private_headers, 33 | fixxref_args: [ 34 | '--html-dir=@0@'.format(docpath), 35 | '--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')), 36 | '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')), 37 | ], 38 | html_assets: html_images, 39 | install: true) 40 | -------------------------------------------------------------------------------- /doc/xml/gtkdocentities.ent.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /doc/xml/meson.build: -------------------------------------------------------------------------------- 1 | ent_conf = configuration_data() 2 | ent_conf.set('PACKAGE', versioned_libname) 3 | ent_conf.set('PACKAGE_BUGREPORT', 'https://gitlab.freedesktop.org/libfprint/libfprint/issues') 4 | ent_conf.set('PACKAGE_NAME', versioned_libname) 5 | ent_conf.set('PACKAGE_STRING', versioned_libname) 6 | ent_conf.set('PACKAGE_TARNAME', 'libfprint-' + meson.project_version()) 7 | ent_conf.set('PACKAGE_URL', 'https://fprint.freedesktop.org/') 8 | ent_conf.set('PACKAGE_VERSION', meson.project_version()) 9 | ent_conf.set('PACKAGE_API_VERSION', '1.0') 10 | configure_file(input: 'gtkdocentities.ent.in', 11 | output: 'gtkdocentities.ent', 12 | configuration: ent_conf) 13 | -------------------------------------------------------------------------------- /examples/cpp-test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | int main (int argc, char **argv) 8 | { 9 | FpContext *ctx; 10 | 11 | ctx = fp_context_new (); 12 | g_object_unref (ctx); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /examples/meson.build: -------------------------------------------------------------------------------- 1 | 2 | examples = [ 'enroll', 'verify', 'manage-prints' ] 3 | foreach example: examples 4 | executable(example, 5 | [ example + '.c', 'storage.c', 'utilities.c' ], 6 | dependencies: [ 7 | libfprint_dep, 8 | glib_dep, 9 | ], 10 | ) 11 | endforeach 12 | 13 | executable('cpp-test', 14 | 'cpp-test.cpp', 15 | dependencies: libfprint_dep, 16 | ) 17 | -------------------------------------------------------------------------------- /examples/prints/README: -------------------------------------------------------------------------------- 1 | These are example images from NIST and are in the public domain. 2 | 3 | The PNG files have been generated by using the greyscale data as a mask. 4 | -------------------------------------------------------------------------------- /examples/prints/arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/examples/prints/arch.jpg -------------------------------------------------------------------------------- /examples/prints/arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/examples/prints/arch.png -------------------------------------------------------------------------------- /examples/prints/loop-right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/examples/prints/loop-right.jpg -------------------------------------------------------------------------------- /examples/prints/loop-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/examples/prints/loop-right.png -------------------------------------------------------------------------------- /examples/prints/tented_arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/examples/prints/tented_arch.jpg -------------------------------------------------------------------------------- /examples/prints/tented_arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/examples/prints/tented_arch.png -------------------------------------------------------------------------------- /examples/prints/whorl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/examples/prints/whorl.jpg -------------------------------------------------------------------------------- /examples/prints/whorl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/examples/prints/whorl.png -------------------------------------------------------------------------------- /examples/sendvirtimg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # This script can be used together with the virtual_imgdev to simulate an 4 | # image based fingerprint reader. 5 | # 6 | # To use, set the FP_VIRTUAL_IMAGE environment variable for both the 7 | # libfprint using program (e.g. fprintd) and this script. 8 | # 9 | # Usually this would work by adding it into the systemd unit file. The 10 | # best way of doing so is to create 11 | # /etc/systemd/system/fprintd.service.d/fprintd-test.conf 12 | # 13 | # [Service] 14 | # RuntimeDirectory=fprint 15 | # Environment=FP_VIRTUAL_IMAGE=/run/fprint/virtimg_sock 16 | # Environment=G_MESSAGES_DEBUG=all 17 | # ReadWritePaths=$RUNTIME_DIR 18 | # 19 | # After that run: 20 | # 21 | # systemctl daemon-reload 22 | # systemctl restart fprintd.service 23 | # 24 | # You may also need to disable selinux. 25 | # 26 | # Then run this script with e.g. 27 | # FP_VIRTUAL_IMAGE=/run/fprint/virtimg_sock ./sendvirtimg.py prints/whorl.png 28 | 29 | 30 | 31 | import cairo 32 | import sys 33 | import os 34 | import socket 35 | import struct 36 | 37 | if len(sys.argv) != 2: 38 | sys.stderr.write('You need to pass a PNG with an alpha channel!\n') 39 | sys.exit(1) 40 | 41 | # Just copied from the C file, we could also use the introspection data for 42 | # this. Also, most of them do *not* make any sense. 43 | commands = { 44 | 'retry' : struct.pack('ii', -1, 0), 45 | 'retry-too-short' : struct.pack('ii', -1, 1), 46 | 'retry-center-finger' : struct.pack('ii', -1, 2), 47 | 'retry-remove-finger' : struct.pack('ii', -1, 3), 48 | 49 | 'error' : struct.pack('ii', -2, 0), 50 | 'error-not-supported' : struct.pack('ii', -2, 1), 51 | 'error-not-open' : struct.pack('ii', -2, 2), 52 | 'error-already-open' : struct.pack('ii', -2, 3), 53 | 'error-busy' : struct.pack('ii', -2, 4), 54 | 'error-proto' : struct.pack('ii', -2, 5), 55 | 'error-data-invalid' : struct.pack('ii', -2, 6), 56 | 'error-data-not-found' : struct.pack('ii', -2, 7), 57 | 'error-data-full' : struct.pack('ii', -2, 8), 58 | } 59 | 60 | 61 | if sys.argv[1] in commands: 62 | command = commands[sys.argv[1]] 63 | else: 64 | png = cairo.ImageSurface.create_from_png(sys.argv[1]) 65 | 66 | # Cairo wants 4 byte aligned rows, so just add a few pixel if necessary 67 | w = png.get_width() 68 | h = png.get_height() 69 | w = (w + 3) // 4 * 4 70 | h = (h + 3) // 4 * 4 71 | img = cairo.ImageSurface(cairo.Format.A8, w, h) 72 | cr = cairo.Context(img) 73 | 74 | cr.set_source_rgba(1, 1, 1, 1) 75 | cr.paint() 76 | 77 | cr.set_source_rgba(0, 0, 0, 0) 78 | cr.set_operator(cairo.OPERATOR_SOURCE) 79 | 80 | cr.set_source_surface(png) 81 | cr.paint() 82 | 83 | mem = img.get_data() 84 | mem = mem.tobytes() 85 | assert len(mem) == img.get_width() * img.get_height() 86 | 87 | command = struct.pack('ii', img.get_width(), img.get_height()) 88 | command += mem 89 | 90 | 91 | 92 | def write_dbg_img(): 93 | dbg_img_rgb = cairo.ImageSurface(cairo.Format.RGB24, img.get_width(), img.get_height()) 94 | dbg_cr = cairo.Context(dbg_img_rgb) 95 | dbg_cr.set_source_rgb(0, 0, 0) 96 | dbg_cr.paint() 97 | dbg_cr.set_source_rgb(1, 1, 1) 98 | dbg_cr.mask_surface(img, 0, 0) 99 | 100 | dbg_img_rgb.write_to_png('/tmp/test.png') 101 | 102 | #write_dbg_img() 103 | 104 | # Send image through socket 105 | sockaddr = os.environ['FP_VIRTUAL_IMAGE'] 106 | 107 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 108 | sock.connect(sockaddr) 109 | 110 | sock.sendall(command) 111 | 112 | -------------------------------------------------------------------------------- /examples/storage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Trivial storage driver for example programs 3 | * 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | int print_data_save (FpPrint *print, 24 | FpFinger finger); 25 | FpPrint * print_data_load (FpDevice *dev, 26 | FpFinger finger); 27 | FpPrint * print_create_template (FpDevice *dev, 28 | FpFinger finger); 29 | gboolean print_image_save (FpPrint *print, 30 | const char *path); 31 | -------------------------------------------------------------------------------- /examples/utilities.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Utilities for example programs 3 | * 4 | * Copyright (C) 2019 Marco Trevisan 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #define FP_COMPONENT "example-utilities" 22 | 23 | #include 24 | #include 25 | 26 | #include "utilities.h" 27 | 28 | FpDevice * 29 | discover_device (GPtrArray * devices) 30 | { 31 | FpDevice *dev; 32 | int i; 33 | 34 | if (!devices->len) 35 | return NULL; 36 | 37 | if (devices->len == 1) 38 | { 39 | i = 0; 40 | } 41 | else 42 | { 43 | g_print ("Multiple devices found, choose one\n"); 44 | 45 | for (i = 0; i < devices->len; ++i) 46 | { 47 | dev = g_ptr_array_index (devices, i); 48 | g_print ("[%d] %s (%s) - driver %s\n", i, 49 | fp_device_get_device_id (dev), fp_device_get_name (dev), 50 | fp_device_get_driver (dev)); 51 | } 52 | 53 | g_print ("> "); 54 | if (!scanf ("%d%*c", &i)) 55 | return NULL; 56 | 57 | if (i < 0 || i >= devices->len) 58 | return NULL; 59 | } 60 | 61 | dev = g_ptr_array_index (devices, i); 62 | g_print ("Selected device %s (%s) claimed by %s driver\n", 63 | fp_device_get_device_id (dev), fp_device_get_name (dev), 64 | fp_device_get_driver (dev)); 65 | 66 | return dev; 67 | } 68 | 69 | const char * 70 | finger_to_string (FpFinger finger) 71 | { 72 | switch (finger) 73 | { 74 | case FP_FINGER_LEFT_THUMB: 75 | return "left thumb"; 76 | 77 | case FP_FINGER_LEFT_INDEX: 78 | return "left index"; 79 | 80 | case FP_FINGER_LEFT_MIDDLE: 81 | return "left middle"; 82 | 83 | case FP_FINGER_LEFT_RING: 84 | return "left ring"; 85 | 86 | case FP_FINGER_LEFT_LITTLE: 87 | return "left little"; 88 | 89 | case FP_FINGER_RIGHT_THUMB: 90 | return "right thumb"; 91 | 92 | case FP_FINGER_RIGHT_INDEX: 93 | return "right index"; 94 | 95 | case FP_FINGER_RIGHT_MIDDLE: 96 | return "right middle"; 97 | 98 | case FP_FINGER_RIGHT_RING: 99 | return "right ring"; 100 | 101 | case FP_FINGER_RIGHT_LITTLE: 102 | return "right little"; 103 | 104 | default: 105 | return "unknown"; 106 | } 107 | } 108 | 109 | FpFinger 110 | finger_chooser (void) 111 | { 112 | int i = FP_FINGER_UNKNOWN; 113 | 114 | for (i = FP_FINGER_FIRST; i <= FP_FINGER_LAST; ++i) 115 | g_print (" [%d] %s\n", (i - FP_FINGER_FIRST), finger_to_string (i)); 116 | 117 | g_print ("> "); 118 | if (!scanf ("%d%*c", &i)) 119 | return FP_FINGER_UNKNOWN; 120 | 121 | i += FP_FINGER_FIRST; 122 | 123 | if (i < FP_FINGER_FIRST || i > FP_FINGER_LAST) 124 | return FP_FINGER_UNKNOWN; 125 | 126 | return i; 127 | } 128 | -------------------------------------------------------------------------------- /examples/utilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Trivial storage driver for example programs 3 | * 4 | * Copyright (C) 2019 Marco Trevisan 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | FpDevice * discover_device (GPtrArray *devices); 24 | FpFinger finger_chooser (void); 25 | const char * finger_to_string (FpFinger finger); 26 | -------------------------------------------------------------------------------- /libfprint/drivers/aes1660.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthenTec AES1660 driver for libfprint 3 | * Copyright (C) 2012 Vasily Khoruzhick 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #define FP_COMPONENT "aes1660" 21 | 22 | #include "drivers_api.h" 23 | #include "aeslib.h" 24 | #include "aesx660.h" 25 | #include "aes1660.h" 26 | 27 | #define FRAME_WIDTH 128 28 | #define IMAGE_WIDTH (FRAME_WIDTH + (FRAME_WIDTH / 2)) 29 | 30 | struct _FpiDeviceAes1660 31 | { 32 | FpiDeviceAesX660 parent; 33 | }; 34 | G_DECLARE_FINAL_TYPE (FpiDeviceAes1660, fpi_device_aes1660, FPI, 35 | DEVICE_AES1660, FpiDeviceAesX660); 36 | G_DEFINE_TYPE (FpiDeviceAes1660, fpi_device_aes1660, FPI_TYPE_DEVICE_AES_X660); 37 | 38 | static struct fpi_frame_asmbl_ctx assembling_ctx = { 39 | .frame_width = FRAME_WIDTH, 40 | .frame_height = AESX660_FRAME_HEIGHT, 41 | .image_width = IMAGE_WIDTH, 42 | .get_pixel = aes_get_pixel, 43 | }; 44 | 45 | static const FpIdEntry id_table[] = { 46 | { .vid = 0x08ff, .pid = 0x1660, }, 47 | { .vid = 0x08ff, .pid = 0x1680, }, 48 | { .vid = 0x08ff, .pid = 0x1681, }, 49 | { .vid = 0x08ff, .pid = 0x1682, }, 50 | { .vid = 0x08ff, .pid = 0x1683, }, 51 | { .vid = 0x08ff, .pid = 0x1684, }, 52 | { .vid = 0x08ff, .pid = 0x1685, }, 53 | { .vid = 0x08ff, .pid = 0x1686, }, 54 | { .vid = 0x08ff, .pid = 0x1687, }, 55 | { .vid = 0x08ff, .pid = 0x1688, }, 56 | { .vid = 0x08ff, .pid = 0x1689, }, 57 | { .vid = 0x08ff, .pid = 0x168a, }, 58 | { .vid = 0x08ff, .pid = 0x168b, }, 59 | { .vid = 0x08ff, .pid = 0x168c, }, 60 | { .vid = 0x08ff, .pid = 0x168d, }, 61 | { .vid = 0x08ff, .pid = 0x168e, }, 62 | { .vid = 0x08ff, .pid = 0x168f, }, 63 | { .vid = 0, .pid = 0, .driver_data = 0 }, 64 | }; 65 | 66 | static void 67 | fpi_device_aes1660_init (FpiDeviceAes1660 *self) 68 | { 69 | } 70 | static void 71 | fpi_device_aes1660_class_init (FpiDeviceAes1660Class *klass) 72 | { 73 | FpDeviceClass *dev_class = FP_DEVICE_CLASS (klass); 74 | FpImageDeviceClass *img_class = FP_IMAGE_DEVICE_CLASS (klass); 75 | FpiDeviceAesX660Class *aes_class = FPI_DEVICE_AES_X660_CLASS (klass); 76 | 77 | dev_class->id = "aes1660"; 78 | dev_class->full_name = "AuthenTec AES1660"; 79 | dev_class->type = FP_DEVICE_TYPE_USB; 80 | dev_class->id_table = id_table; 81 | dev_class->scan_type = FP_SCAN_TYPE_SWIPE; 82 | 83 | img_class->bz3_threshold = 20; 84 | 85 | img_class->img_width = FRAME_WIDTH + FRAME_WIDTH / 2; 86 | img_class->img_height = -1; 87 | 88 | aes_class->init_seqs[0] = aes1660_init_1; 89 | aes_class->init_seqs_len[0] = G_N_ELEMENTS (aes1660_init_1); 90 | aes_class->init_seqs[1] = aes1660_init_2; 91 | aes_class->init_seqs_len[1] = G_N_ELEMENTS (aes1660_init_2); 92 | aes_class->start_imaging_cmd = (unsigned char *) aes1660_start_imaging_cmd; 93 | aes_class->start_imaging_cmd_len = sizeof (aes1660_start_imaging_cmd); 94 | aes_class->assembling_ctx = &assembling_ctx; 95 | } 96 | -------------------------------------------------------------------------------- /libfprint/drivers/aes2550.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthenTec AES2550/AES2810 driver for libfprint 3 | * Copyright (C) 2012 Vasily Khoruzhick 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | /* Registers bits */ 23 | 24 | #define AES2550_REG80_MASTER_RESET (1 << 0) 25 | #define AES2550_REG80_FORCE_FINGER_PRESENT (1 << 1) 26 | #define AES2550_REG80_LPO_START (1 << 2) 27 | #define AES2550_REG80_HGC_ENABLE (1 << 3) 28 | #define AES2550_REG80_SENSOR_MODE_OFS (4) 29 | #define AES2550_REG80_AUTO_RESTART_FD (1 << 6) 30 | #define AES2550_REG80_EXT_REG_ENABLE (1 << 7) 31 | 32 | #define AES2550_REG81_CONT_SCAN (1 << 0) 33 | #define AES2550_REG81_READ_REG (1 << 1) 34 | #define AES2550_REG81_NSHOT (1 << 2) 35 | #define AES2550_REG81_RUN_FD (1 << 3) 36 | #define AES2550_REG81_READ_ID (1 << 4) 37 | #define AES2550_REG81_RUN_CAL (1 << 5) 38 | #define AES2550_REG81_RUN_TIMER (1 << 6) 39 | #define AES2550_REG81_RUN_BIST (1 << 7) 40 | 41 | #define AES2550_REG83_FINGER_PRESENT (1 << 7) 42 | 43 | #define AES2550_REG85_FLUSH_PER_FRAME (1 << 7) 44 | 45 | #define AES2550_REG8F_EDATA_DISABLE (1 << 1) 46 | #define AES2550_REG8F_AUTH_DISABLE (1 << 2) 47 | #define AES2550_REG8F_EHISTO_DISABLE (1 << 3) 48 | #define AES2550_REG8F_HISTO64 (1 << 4) 49 | #define AES2550_REG8F_SINGLE_REG_ENABLE (1 << 6) 50 | 51 | #define AES2550_REG95_COL_SCANNED_OFS (0) 52 | #define AES2550_REG95_EPIX_AVG_OFS (4) 53 | 54 | #define AES2550_REGA8_DIG_BIT_DATA_OFS (0) 55 | #define AES2550_REGA8_DIG_BIT_EN (1 << 4) 56 | #define AES2550_REGA8_FIXED_BIT_DATA (1 << 5) 57 | #define AES2550_REGA8_INVERT_BIT_DATA (1 << 6) 58 | 59 | #define AES2550_REGAD_LPFD_AVG_OFS (0) 60 | #define AES2550_REGAD_DETECT_FGROFF (1 << 4) 61 | #define AES2550_REGAD_ADVRANGE_2V (1 << 6) 62 | 63 | #define AES2550_REGB1_ATE_CONT_IMAGE (1 << 1) 64 | #define AES2550_REGB1_ANALOG_RESET (1 << 2) 65 | #define AES2550_REGB1_ANALOG_PD (1 << 3) 66 | #define AES2550_REGB1_TEST_EMBD_WORD (1 << 4) 67 | #define AES2550_REGB1_ORIG_EMBD_WORD (1 << 5) 68 | #define AES2550_REGB1_RESET_UHSM (1 << 6) 69 | #define AES2550_REGB1_RESET_SENSOR (1 << 7) 70 | 71 | #define AES2550_REGBD_LPO_IN_15_8_OFS (0) 72 | #define AES2550_REGBE_LPO_IN_7_0_OFS (0) 73 | 74 | #define AES2550_REGBF_RSR_LEVEL_DISABLED (0 << 0) 75 | #define AES2550_REGBF_RSR_LEVEL_LEADING_RSR (1 << 0) 76 | #define AES2550_REGBF_RSR_LEVEL_SIMPLE_RSR (2 << 0) 77 | #define AES2550_REGBF_RSR_LEVEL_SUPER_RSR (3 << 0) 78 | #define AES2550_REGBF_RSR_DIR_DOWN_MOTION (0 << 2) 79 | #define AES2550_REGBF_RSR_DIR_UP_MOTION (1 << 2) 80 | #define AES2550_REGBF_RSR_DIR_UPDOWN_MOTION (2 << 2) 81 | #define AES2550_REGBF_NOISE_FLOOR_MODE (1 << 4) 82 | #define AES2550_REGBF_QUADRATURE_MODE (1 << 5) 83 | 84 | #define AES2550_REGCF_INTERFERENCE_CHK_EN (1 << 0) 85 | #define AES2550_REGCF_INTERFERENCE_AVG_EN (1 << 1) 86 | #define AES2550_REGCF_INTERFERENCE_AVG_OFFS (4) 87 | 88 | #define AES2550_REGDC_BP_NUM_REF_SWEEP_OFS (0) 89 | #define AES2550_REGDC_DEBUG_CTRL2_OFS (3) 90 | 91 | #define AES2550_REGDD_DEBUG_CTRL1_OFS (0) 92 | 93 | /* Commands */ 94 | 95 | enum aes2550_cmds { 96 | AES2550_CMD_SET_IDLE_MODE = 0x00, 97 | AES2550_CMD_RUN_FD = 0x01, 98 | AES2550_CMD_GET_ENROLL_IMG = 0x02, 99 | AES2550_CMD_CALIBRATE = 0x06, 100 | AES2550_CMD_READ_CALIBRATION_DATA = 0x10, 101 | AES2550_CMD_HEARTBEAT = 0x70, 102 | }; 103 | 104 | /* Messages */ 105 | 106 | #define AES2550_STRIP_SIZE (0x31e + 3) 107 | #define AES2550_HEARTBEAT_SIZE (4 + 3) 108 | #define AES2550_EDATA_MAGIC 0xe0 109 | #define AES2550_HEARTBEAT_MAGIC 0xdb 110 | 111 | #define AES2550_EP_IN_BUF_SIZE 8192 112 | -------------------------------------------------------------------------------- /libfprint/drivers/aes2660.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthenTec AES2660 driver for libfprint 3 | * Copyright (C) 2012 Vasily Khoruzhick 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #define FP_COMPONENT "aes2660" 21 | 22 | #include "drivers_api.h" 23 | #include "aeslib.h" 24 | #include "aesx660.h" 25 | #include "aes2660.h" 26 | 27 | #define FRAME_WIDTH 192 28 | #define IMAGE_WIDTH (FRAME_WIDTH + (FRAME_WIDTH / 2)) 29 | 30 | struct _FpiDeviceAes2660 31 | { 32 | FpiDeviceAesX660 parent; 33 | }; 34 | G_DECLARE_FINAL_TYPE (FpiDeviceAes2660, fpi_device_aes2660, FPI, 35 | DEVICE_AES2660, FpiDeviceAesX660); 36 | G_DEFINE_TYPE (FpiDeviceAes2660, fpi_device_aes2660, FPI_TYPE_DEVICE_AES_X660); 37 | 38 | static struct fpi_frame_asmbl_ctx assembling_ctx = { 39 | .frame_width = FRAME_WIDTH, 40 | .frame_height = AESX660_FRAME_HEIGHT, 41 | .image_width = IMAGE_WIDTH, 42 | .get_pixel = aes_get_pixel, 43 | }; 44 | 45 | static const FpIdEntry id_table[] = { 46 | { .vid = 0x08ff, .pid = 0x2660, }, 47 | { .vid = 0x08ff, .pid = 0x2680, }, 48 | { .vid = 0x08ff, .pid = 0x2681, }, 49 | { .vid = 0x08ff, .pid = 0x2682, }, 50 | { .vid = 0x08ff, .pid = 0x2683, }, 51 | { .vid = 0x08ff, .pid = 0x2684, }, 52 | { .vid = 0x08ff, .pid = 0x2685, }, 53 | { .vid = 0x08ff, .pid = 0x2686, }, 54 | { .vid = 0x08ff, .pid = 0x2687, }, 55 | { .vid = 0x08ff, .pid = 0x2688, }, 56 | { .vid = 0x08ff, .pid = 0x2689, }, 57 | { .vid = 0x08ff, .pid = 0x268a, }, 58 | { .vid = 0x08ff, .pid = 0x268b, }, 59 | { .vid = 0x08ff, .pid = 0x268c, }, 60 | { .vid = 0x08ff, .pid = 0x268d, }, 61 | { .vid = 0x08ff, .pid = 0x268e, }, 62 | { .vid = 0x08ff, .pid = 0x268f, }, 63 | { .vid = 0x08ff, .pid = 0x2691, }, 64 | { .vid = 0, .pid = 0, .driver_data = 0 }, 65 | }; 66 | 67 | static void 68 | fpi_device_aes2660_init (FpiDeviceAes2660 *self) 69 | { 70 | } 71 | 72 | static void 73 | fpi_device_aes2660_class_init (FpiDeviceAes2660Class *klass) 74 | { 75 | FpDeviceClass *dev_class = FP_DEVICE_CLASS (klass); 76 | FpImageDeviceClass *img_class = FP_IMAGE_DEVICE_CLASS (klass); 77 | FpiDeviceAesX660Class *aes_class = FPI_DEVICE_AES_X660_CLASS (klass); 78 | 79 | dev_class->id = "aes2660"; 80 | dev_class->full_name = "AuthenTec AES2660"; 81 | dev_class->type = FP_DEVICE_TYPE_USB; 82 | dev_class->id_table = id_table; 83 | dev_class->scan_type = FP_SCAN_TYPE_SWIPE; 84 | 85 | img_class->bz3_threshold = 20; 86 | 87 | img_class->img_width = FRAME_WIDTH + FRAME_WIDTH / 2; 88 | img_class->img_height = -1; 89 | 90 | aes_class->init_seqs[0] = aes2660_init_1; 91 | aes_class->init_seqs_len[0] = G_N_ELEMENTS (aes2660_init_1); 92 | aes_class->init_seqs[1] = aes2660_init_2; 93 | aes_class->init_seqs_len[1] = G_N_ELEMENTS (aes2660_init_2); 94 | aes_class->start_imaging_cmd = (unsigned char *) aes2660_start_imaging_cmd; 95 | aes_class->start_imaging_cmd_len = sizeof (aes2660_start_imaging_cmd); 96 | aes_class->assembling_ctx = &assembling_ctx; 97 | } 98 | -------------------------------------------------------------------------------- /libfprint/drivers/aes3k.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthenTec AES3500/AES4000 common routines 3 | * 4 | * The AES3500 and AES4000 sensors are press-typed, and could capture 5 | * fingerprint images in 128x128 and 96x96 pixels respectively. They 6 | * share a same communication interface: a number of frames are 7 | * transferred and captured, from which a final image could be 8 | * assembled. Each frame has fixed height of 16 pixels. 9 | * 10 | * As the imaging area is a bit small, only a part of finger could be 11 | * captured, the detected minutiae are not so many that the NBIS 12 | * matching works not so good. The verification rate is very low at the 13 | * moment. 14 | * 15 | * This work is derived from Daniel Drake's AES4000 driver. 16 | * 17 | * Copyright (C) 2013 Juvenn Woo 18 | * Copyright (C) 2007-2008 Daniel Drake 19 | * 20 | * This library is free software; you can redistribute it and/or modify 21 | * it under the terms of the GNU Lesser General Public License as 22 | * published by the Free Software Foundation; either version 2.1 of the 23 | * License, or (at your option) any later version. 24 | * 25 | * This library is distributed in the hope that it will be useful, but 26 | * WITHOUT ANY WARRANTY; without even the implied warranty of 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 28 | * Lesser General Public License for more details. 29 | * 30 | * You should have received a copy of the GNU Lesser General Public 31 | * License along with this library; if not, write to the Free Software 32 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 33 | * 02110-1301 USA 34 | * 35 | */ 36 | 37 | #pragma once 38 | #include "fpi-image-device.h" 39 | #include "aeslib.h" 40 | 41 | #define AES3K_FRAME_HEIGHT 16 42 | 43 | G_DECLARE_DERIVABLE_TYPE (FpiDeviceAes3k, fpi_device_aes3k, FPI, 44 | DEVICE_AES3K, FpImageDevice) 45 | 46 | #define FPI_TYPE_DEVICE_AES3K (fpi_device_aes3k_get_type ()) 47 | 48 | struct _FpiDeviceAes3kClass 49 | { 50 | FpImageDeviceClass parent; 51 | 52 | gsize frame_width; /* image size = frame_width x frame_width */ 53 | gsize frame_size; /* 4 bits/pixel: frame_width x AES3K_FRAME_HEIGHT / 2 */ 54 | gsize frame_number; /* number of frames */ 55 | gsize enlarge_factor; 56 | 57 | gsize data_buflen; /* buffer length of usb bulk transfer */ 58 | struct aes_regwrite *init_reqs; /* initial values sent to device */ 59 | gsize init_reqs_len; 60 | }; 61 | -------------------------------------------------------------------------------- /libfprint/drivers/aeslib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Shared functions between libfprint Authentec drivers 3 | * Copyright (C) 2007 Daniel Drake 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | struct aes_regwrite 25 | { 26 | unsigned char reg; 27 | unsigned char value; 28 | }; 29 | 30 | struct fpi_frame; 31 | struct fpi_frame_asmbl_ctx; 32 | 33 | typedef void (*aes_write_regv_cb)(FpImageDevice *dev, 34 | GError *error, 35 | void *user_data); 36 | 37 | void aes_write_regv (FpImageDevice *dev, 38 | const struct aes_regwrite *regs, 39 | unsigned int num_regs, 40 | aes_write_regv_cb callback, 41 | void *user_data); 42 | 43 | unsigned char aes_get_pixel (struct fpi_frame_asmbl_ctx *ctx, 44 | struct fpi_frame *frame, 45 | unsigned int x, 46 | unsigned int y); 47 | -------------------------------------------------------------------------------- /libfprint/drivers/aesx660.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthenTec AES1660/AES2660 common definitions 3 | * Copyright (c) 2012 Vasily Khoruzhick 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #define AESX660_HEADER_SIZE 3 23 | #define AESX660_RESPONSE_TYPE_OFFSET 0x00 24 | #define AESX660_RESPONSE_SIZE_LSB_OFFSET 0x01 25 | #define AESX660_RESPONSE_SIZE_MSB_OFFSET 0x02 26 | 27 | #define AESX660_CALIBRATE_RESPONSE 0x06 28 | #define AESX660_FINGER_DET_RESPONSE 0x40 29 | #define AESX660_FINGER_PRESENT_OFFSET 0x03 30 | #define AESX660_FINGER_PRESENT 0x01 31 | 32 | #define AESX660_IMAGE_OK_OFFSET 0x03 33 | #define AESX660_IMAGE_OK 0x0d 34 | #define AESX660_LAST_FRAME_OFFSET 0x04 35 | #define AESX660_LAST_FRAME_BIT 0x01 36 | 37 | #define AESX660_FRAME_DELTA_X_OFFSET 16 38 | #define AESX660_FRAME_DELTA_Y_OFFSET 17 39 | 40 | #define AESX660_IMAGE_OFFSET 43 41 | #define AESX660_BULK_TRANSFER_SIZE 4096 42 | 43 | #define AESX660_FRAME_HEIGHT 8 44 | 45 | G_DECLARE_DERIVABLE_TYPE (FpiDeviceAesX660, fpi_device_aes_x660, FPI, 46 | DEVICE_AES_X660, FpImageDevice) 47 | 48 | #define FPI_TYPE_DEVICE_AES_X660 (fpi_device_aes_x660_get_type ()) 49 | 50 | struct _FpiDeviceAesX660Class 51 | { 52 | FpImageDeviceClass parent; 53 | 54 | struct aesX660_cmd *init_seqs[2]; 55 | gsize init_seqs_len[2]; 56 | guint8 *start_imaging_cmd; 57 | gsize start_imaging_cmd_len; 58 | struct fpi_frame_asmbl_ctx *assembling_ctx; 59 | }; 60 | 61 | struct aesX660_cmd 62 | { 63 | const guint8 *cmd; 64 | gsize len; 65 | }; 66 | 67 | /* 0x77 cmd seems to control LED, this sequence 68 | * makes LED blink 69 | */ 70 | static const guint8 led_blink_cmd[] = { 71 | 0x77, 0x18, 0x00, 72 | 0x00, 0x3f, 0x00, 0xff, 0x00, 73 | 0x01, 0x01, 0x00, 0x00, 0x00, 0xf3, 0x01, 0x00, 74 | 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0xf3, 75 | 0x01, 0x00, 0x7f 76 | }; 77 | 78 | /* This sequence makes LED light solid 79 | */ 80 | static const guint8 led_solid_cmd[] = { 81 | 0x77, 0x18, 0x00, 0x00, 0x3f, 0x00, 0xff, 0x00, 82 | 0x01, 0x01, 0x00, 0x00, 0x00, 0xe7, 0x03, 0x00, 83 | 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 84 | 0x00, 0x00, 0x7f 85 | }; 86 | 87 | static const guint8 wait_for_finger_cmd[] = { 88 | 0x20, 89 | 0x40, 0x04, 0x00, 0x02, 0x1e, 0x00, 0x32 90 | }; 91 | 92 | /* 0x40 cmd response 93 | * 94 | static const guint8 pkt1371[] = { 95 | 0x40, 0x01, 0x00, 0x01 96 | }; 97 | */ 98 | 99 | static const guint8 set_idle_cmd[] = { 100 | 0x0d, /* Reset or "set idle"? */ 101 | }; 102 | 103 | static const guint8 read_id_cmd[] = { 104 | 0x44, 0x02, 0x00, 0x08, 0x00, /* Max transfer size is 8 */ 105 | 0x07, /* Read ID? */ 106 | }; 107 | 108 | static const guint8 calibrate_cmd[] = { 109 | 0x44, 0x02, 0x00, 0x04, 0x00, 110 | 0x06, 111 | }; 112 | -------------------------------------------------------------------------------- /libfprint/drivers/synaptics/bmkt_message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Synaptics Inc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #pragma once 20 | 21 | #define BMKT_MESSAGE_HEADER_ID 0xFE 22 | #define BMKT_MESSAGE_HEADER_LEN (4) 23 | #define BMKT_MESSAGE_CRC32_LEN (4) 24 | #define BMKT_MESSAGE_HEADER_ID_FIELD 0 25 | #define BMKT_MESSAGE_SEQ_NUM_FIELD 1 26 | #define BMKT_MESSAGE_ID_FIELD 2 27 | #define BMKT_MESSAGE_PAYLOAD_LEN_FIELD 3 28 | #define BMKT_MESSAGE_PAYLOAD_FIELD 4 29 | 30 | // Command messages 31 | #define BMKT_CMD_CONTINUOUS_IMAGE_CAPTURE 0x01 32 | #define BMKT_CMD_CONTINUOUS_IMAGE_CAPTURE_STOP 0x04 33 | #define BMKT_CMD_SENSOR_MODULE_TEST 0x06 34 | #define BMKT_CMD_SENSOR_MODULE_TEST_START 0x08 35 | #define BMKT_CMD_NEXT_TEST_REPORT_CHUNK 0x0B 36 | #define BMKT_CMD_FPS_INIT 0x11 37 | #define BMKT_CMD_GET_FPS_MODE 0x21 38 | #define BMKT_CMD_SET_SECURITY_LEVEL 0x31 39 | #define BMKT_CMD_GET_SECURITY_LEVEL 0x34 40 | #define BMKT_CMD_CANCEL_OP 0x41 41 | #define BMKT_CMD_ENROLL_USER 0x51 42 | #define BMKT_CMD_ENROLL_PAUSE 0x52 43 | #define BMKT_CMD_ENROLL_RESUME 0x53 44 | #define BMKT_CMD_ID_USER 0x61 45 | #define BMKT_CMD_VERIFY_USER 0x65 46 | #define BMKT_CMD_GET_TEMPLATE_RECORDS 0x71 47 | #define BMKT_CMD_GET_NEXT_QUERY_RESPONSE 0x72 48 | #define BMKT_CMD_GET_ENROLLED_FINGERS 0x73 49 | #define BMKT_CMD_GET_DATABASE_CAPACITY 0x74 50 | #define BMKT_CMD_DEL_USER_FP 0x81 51 | #define BMKT_CMD_DEL_FULL_DB 0x84 52 | #define BMKT_CMD_REPEAT_LAST_RSP 0x92 53 | #define BMKT_CMD_POWER_DOWN_NOTIFY 0xA1 54 | #define BMKT_CMD_GET_VERSION 0xB1 55 | #define BMKT_CMD_DISABLE_PAIRING 0xC2 56 | #define BMKT_CMD_QUERY_PAIRING 0xC5 57 | #define BMKT_CMD_SENSOR_STATUS 0xD1 58 | #define BMKT_CMD_ID_USER_IN_ORDER 0xE1 59 | #define BMKT_CMD_ID_NEXT_USER 0xE3 60 | #define BMKT_CMD_VERIFY_USER_IN_ORDER 0xF1 61 | #define BMKT_CMD_VERIFY_FINGERS_IN_ORDER 0xF2 62 | #define BMKT_CMD_GET_FINAL_RESULT 0xE4 63 | 64 | #define BMKT_EVT_FINGER_REPORT 0x91 65 | 66 | #define BMKT_EVT_FINGER_STATE_NOT_ON_SENSOR 0x00 67 | #define BMKT_EVT_FINGER_STATE_ON_SENSOR 0x01 68 | 69 | typedef struct bmkt_msg_resp 70 | { 71 | uint8_t msg_id; 72 | uint8_t seq_num; 73 | uint8_t payload_len; 74 | uint8_t *payload; 75 | int result; 76 | } bmkt_msg_resp_t; 77 | 78 | int bmkt_compose_message (uint8_t *cmd, 79 | int *cmd_len, 80 | uint8_t msg_id, 81 | uint8_t seq_num, 82 | uint8_t payload_size, 83 | const uint8_t *payload); 84 | 85 | int bmkt_parse_message_header (uint8_t *resp_buf, 86 | int resp_len, 87 | bmkt_msg_resp_t *msg_resp); 88 | int bmkt_parse_message_payload (bmkt_msg_resp_t *msg_resp, 89 | bmkt_response_t *resp); 90 | -------------------------------------------------------------------------------- /libfprint/drivers/synaptics/sensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Synaptics Inc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "usb_transport.h" 22 | #define BMKT_MAX_PENDING_SESSIONS 2 23 | 24 | typedef enum bmkt_sensor_state { 25 | BMKT_SENSOR_STATE_UNINIT = 0, 26 | BMKT_SENSOR_STATE_IDLE, 27 | BMKT_SENSOR_STATE_INIT, 28 | BMKT_SENSOR_STATE_EXIT, 29 | } bmkt_sensor_state_t; 30 | 31 | typedef struct bmkt_sensor_drv bmkt_sensor_drv_t; 32 | 33 | typedef struct bmkt_sensor_version 34 | { 35 | uint32_t build_time; 36 | uint32_t build_num; 37 | uint8_t version_major; 38 | uint8_t version_minor; 39 | uint8_t target; 40 | uint8_t product; 41 | uint8_t silicon_rev; 42 | uint8_t formal_release; 43 | uint8_t platform; 44 | uint8_t patch; 45 | uint8_t serial_number[6]; 46 | uint16_t security; 47 | uint8_t iface; 48 | uint8_t device_type; 49 | } bmkt_sensor_version_t; 50 | 51 | typedef struct bmkt_sensor 52 | { 53 | bmkt_usb_transport_t usb_xport; 54 | bmkt_sensor_version_t version; 55 | bmkt_session_ctx_t pending_sessions[BMKT_MAX_PENDING_SESSIONS]; 56 | int empty_session_idx; 57 | int flags; 58 | int seq_num; 59 | bmkt_sensor_state_t sensor_state; 60 | bmkt_event_cb_t finger_event_cb; 61 | void *finger_cb_ctx; 62 | bmkt_general_error_cb_t gen_err_cb; 63 | void *gen_err_cb_ctx; 64 | bmkt_op_state_t op_state; 65 | } bmkt_sensor_t; 66 | 67 | int bmkt_sensor_open (bmkt_sensor_t *sensor, 68 | bmkt_general_error_cb_t err_cb, 69 | void *err_cb_ctx); 70 | int bmkt_sensor_close (bmkt_sensor_t *sensor); 71 | 72 | int bmkt_sensor_init_fps (bmkt_sensor_t *sensor); 73 | 74 | int bmkt_sensor_send_message (bmkt_sensor_t *sensor, 75 | uint8_t msg_id, 76 | uint8_t payload_size, 77 | uint8_t *payload, 78 | bmkt_resp_cb_t resp_cb, 79 | void *resp_data); 80 | int bmkt_sensor_handle_response (bmkt_sensor_t *sensor, 81 | uint8_t *resp_buf, 82 | int resp_len, 83 | bmkt_msg_resp_t *msg_resp); 84 | 85 | int bmkt_sensor_send_async_read_command (bmkt_sensor_t *sensor); 86 | -------------------------------------------------------------------------------- /libfprint/drivers/synaptics/synaptics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Synaptics Inc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "fpi-device.h" 22 | #include "fpi-ssm.h" 23 | 24 | #define SYNAPTICS_VENDOR_ID 0x06cb 25 | 26 | G_DECLARE_FINAL_TYPE (FpiDeviceSynaptics, fpi_device_synaptics, FPI, DEVICE_SYNAPTICS, FpDevice) 27 | 28 | 29 | #define MAX_TRANSFER_LEN 263 + 1 /* SPI Header */ + 2 /* VCSFW header */ 30 | 31 | #define USB_EP_REQUEST 0x01 32 | #define USB_EP_REPLY 0x81 33 | #define USB_EP_FINGERPRINT 0x82 34 | #define USB_EP_INTERRUPT 0x83 35 | 36 | #define USB_ASYNC_MESSAGE_PENDING 0x4 37 | #define USB_INTERRUPT_DATA_SIZE 7 38 | 39 | #define SENSOR_CMD_GET_VERSION 1 40 | #define SENSOR_CMD_ACE_COMMAND 167 41 | #define SENSOR_CMD_ASYNCMSG_READ 168 42 | 43 | #define SENSOR_FW_CMD_HEADER_LEN 1 44 | #define SENSOR_FW_REPLY_HEADER_LEN 2 45 | 46 | 47 | /* Number of enroll stages */ 48 | #define ENROLL_SAMPLES 8 49 | 50 | 51 | #define SYNAPTICS_DRIVER_FULLNAME "Synaptics Sensors" 52 | #include "bmkt.h" 53 | #include "bmkt_response.h" 54 | 55 | 56 | typedef struct bmkt_sensor_version 57 | { 58 | uint32_t build_time; 59 | uint32_t build_num; 60 | uint8_t version_major; 61 | uint8_t version_minor; 62 | uint8_t target; 63 | uint8_t product; 64 | uint8_t silicon_rev; 65 | uint8_t formal_release; 66 | uint8_t platform; 67 | uint8_t patch; 68 | uint8_t serial_number[6]; 69 | uint16_t security; 70 | uint8_t iface; 71 | uint8_t device_type; 72 | } bmkt_sensor_version_t; 73 | 74 | 75 | struct syna_enroll_resp_data 76 | { 77 | int progress; 78 | }; 79 | typedef enum syna_state { 80 | SYNA_STATE_UNINIT = 0, 81 | SYNA_STATE_IDLE, 82 | SYNA_STATE_ENROLL, 83 | SYNA_STATE_IDENTIFY, 84 | SYNA_STATE_IDENTIFY_DELAY_RESULT, 85 | SYNA_STATE_VERIFY, 86 | SYNA_STATE_VERIFY_DELAY_RESULT, 87 | SYNA_STATE_DELETE, 88 | } syna_state_t; 89 | 90 | typedef enum { 91 | SYNAPTICS_CMD_SEND_PENDING = 0, 92 | SYNAPTICS_CMD_GET_RESP, 93 | SYNAPTICS_CMD_WAIT_INTERRUPT, 94 | SYNAPTICS_CMD_SEND_ASYNC, 95 | SYNAPTICS_CMD_RESTART, 96 | SYNAPTICS_CMD_NUM_STATES, 97 | } SynapticsCmdState; 98 | 99 | 100 | typedef void (*SynCmdMsgCallback) (FpiDeviceSynaptics *self, 101 | bmkt_response_t *resp, 102 | GError *error); 103 | 104 | struct _FpiDeviceSynaptics 105 | { 106 | FpDevice parent; 107 | 108 | guint8 cmd_seq_num; 109 | guint8 last_seq_num; 110 | FpiSsm *cmd_ssm; 111 | FpiUsbTransfer *cmd_pending_transfer; 112 | gboolean cmd_complete_on_removal; 113 | 114 | bmkt_sensor_version_t mis_version; 115 | 116 | GCancellable *interrupt_cancellable; 117 | 118 | gint enroll_stage; 119 | gboolean finger_on_sensor; 120 | GPtrArray *list_result; 121 | 122 | 123 | struct syna_enroll_resp_data enroll_resp_data; 124 | syna_state_t state; 125 | }; 126 | -------------------------------------------------------------------------------- /libfprint/drivers/upek_proto.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LGPL CRC code copied from GStreamer-0.10.10: 3 | * Copyright (C) <1999> Erik Walthinsen 4 | * Copyright (C) 2004,2006 Thomas Vander Stichele 5 | 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; version 9 | * 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "upek_proto.h" 22 | 23 | static const uint16_t crc_table[256] = { 24 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 25 | 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 26 | 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 27 | 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 28 | 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 29 | 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 30 | 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 31 | 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 32 | 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 33 | 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 34 | 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 35 | 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 36 | 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 37 | 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 38 | 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 39 | 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 40 | 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 41 | 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 42 | 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 43 | 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 44 | 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 45 | 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 46 | 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 47 | 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 48 | 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 49 | 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 50 | 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 51 | 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 52 | 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 53 | 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 54 | 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 55 | 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 56 | }; 57 | 58 | uint16_t 59 | udf_crc (unsigned char *buffer, size_t size) 60 | { 61 | uint16_t crc = 0; 62 | 63 | while (size--) 64 | crc = (uint16_t) ((crc << 8) ^ 65 | crc_table[((crc >> 8) & 0x00ff) ^ *buffer++]); 66 | return crc; 67 | } 68 | -------------------------------------------------------------------------------- /libfprint/drivers/upek_proto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LGPL CRC code copied from GStreamer-0.10.10: 3 | * Copyright (C) <1999> Erik Walthinsen 4 | * Copyright (C) 2004,2006 Thomas Vander Stichele 5 | 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; version 9 | * 2.1 of the License. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | uint16_t udf_crc (unsigned char *buffer, 25 | size_t size); 26 | -------------------------------------------------------------------------------- /libfprint/drivers/upektc_img.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Upek TouchChip Fingerprint Coprocessor definitions 3 | * Copyright (c) 2013 Vasily Khoruzhick 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | static const unsigned char upek2020_init_1[] = { 23 | 'C', 'i', 'a', 'o', 24 | 0x04, 25 | 0x00, 0x0d, 26 | 0x01, 0x00, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 27 | 0x01, 0x00, 0x00, 0x00, 28 | 0xda, 0xc1 29 | }; 30 | 31 | static const unsigned char upek2020_init_2[] = { 32 | 0x43, 0x69, 0x61, 0x6f, 33 | 0x07, 34 | 0x00, 0x01, 35 | 0x01, 36 | 0x3d, 0x72 37 | }; 38 | 39 | static const unsigned char upek2020_init_3[] = { 40 | 'C', 'i', 'a', 'o', 41 | 0x04, 42 | 0x00, 0x0d, 43 | 0x01, 0x00, 0xbc, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 44 | 0x01, 0x00, 0x00, 0x00, 45 | 0x55, 0x2f 46 | }; 47 | 48 | static const unsigned char upek2020_init_4[] = { 49 | 'C', 'i', 'a', 'o', 50 | 0x00, 51 | 0x00, 0x07, 52 | 0x28, 0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 53 | 0xc0, 0xd6 54 | }; 55 | 56 | static const unsigned char upek2020_deinit[] = { 57 | 'C', 'i', 'a', 'o', 58 | 0x07, 59 | 0x00, 0x01, 60 | 0x01, 61 | 0x3d, 62 | 0x72 63 | }; 64 | 65 | static const unsigned char upek2020_init_capture[] = { 66 | 'C', 'i', 'a', 'o', 67 | 0x00, 68 | 0x00, 0x0e, /* Seq = 7, len = 0x00e */ 69 | 0x28, /* CMD = 0x28 */ 70 | 0x0b, 0x00, /* Inner len = 0x000b */ 71 | 0x00, 0x00, 72 | 0x0e, /* SUBCMD = 0x0e */ 73 | 0x02, 74 | 0xfe, 0xff, 0xff, 0xff, /* timeout = -2 = 0xfffffffe = infinite time */ 75 | 0x02, 76 | 0x00, /* Wait for acceptable finger */ 77 | 0x02, 78 | 0x14, 0x9a /* CRC */ 79 | }; 80 | 81 | #if 0 82 | static const unsigned char finger_status[] = { 83 | 'C', 'i', 'a', 'o', 84 | 0x00, 85 | 0x70, 0x14, /* Seq = 7, len = 0x014 */ 86 | 0x28, /* CMD = 0x28 */ 87 | 0x11, 0x00, /* Inner len = 0x0011 */ 88 | 0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 89 | 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 90 | 0x00, 91 | 0x26, 0x03, /* CRC */ 92 | 0x00, 0x00, 0x00, /* Rest is garbage */ 93 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 94 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 95 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 96 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 97 | }; 98 | #endif 99 | 100 | static const unsigned char upek2020_ack_00_28[] = { 101 | 'C', 'i', 'a', 'o', 102 | 0x00, 103 | 0x80, 0x08, /* Seq = 8, len = 0x008 */ 104 | 0x28, /* CMD = 0x28 */ 105 | 0x05, 0x00, /* Inner len = 0x0005 */ 106 | 0x00, 0x00, 0x00, 0x30, 0x01, 107 | 0x6a, 0xc4 /* CRC */ 108 | }; 109 | 110 | #if 0 111 | /* No seq should be tracked here */ 112 | static const unsigned char got_finger[] = { 113 | 'C', 'i', 'a', 'o', 114 | 0x08, 115 | 0x00, 0x00, /* Seq = 0, len = 0x000 */ 116 | 0xa1, 0xa9, /* CRC */ 117 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Rest is garbage */ 118 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 119 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 120 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 121 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 122 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 123 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 124 | }; 125 | #endif 126 | 127 | /* No seq should be put in there */ 128 | static const unsigned char upek2020_ack_08[] = { 129 | 'C', 'i', 'a', 'o', 130 | 0x09, 131 | 0x00, 0x00, /* Seq = 0, len = 0x0 */ 132 | 0x91, 0x9e /* CRC */ 133 | }; 134 | 135 | static const unsigned char upek2020_ack_frame[] = { 136 | 'C', 'i', 'a', 'o', 137 | 0x00, 138 | 0x50, 0x01, /* Seq = 5, len = 0x001 */ 139 | 0x30, 140 | 0xac, 0x5b /* CRC */ 141 | }; 142 | -------------------------------------------------------------------------------- /libfprint/drivers/vfs301.h: -------------------------------------------------------------------------------- 1 | /* 2 | * vfs301/vfs300 fingerprint reader driver 3 | * https://github.com/andree182/vfs301 4 | * 5 | * Copyright (c) 2011-2012 Andrej Krutak 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "fpi-usb-transfer.h" 25 | #include "fpi-image-device.h" 26 | 27 | enum { 28 | VFS301_DEFAULT_WAIT_TIMEOUT = 300, 29 | 30 | VFS301_SEND_ENDPOINT = 0x01, 31 | VFS301_RECEIVE_ENDPOINT_CTRL = 0x81, 32 | VFS301_RECEIVE_ENDPOINT_DATA = 0x82 33 | }; 34 | 35 | #define VFS301_FP_RECV_LEN_1 (84032) 36 | #define VFS301_FP_RECV_LEN_2 (84096) 37 | 38 | struct _FpDeviceVfs301 39 | { 40 | FpImageDevice parent; 41 | 42 | /* buffer to hold raw scanlines */ 43 | unsigned char *scanline_buf; 44 | int scanline_count; 45 | 46 | enum { 47 | VFS301_ONGOING = 0, 48 | VFS301_ENDED = 1, 49 | VFS301_FAILURE = -1 50 | } recv_progress; 51 | int recv_exp_amt; 52 | }; 53 | 54 | G_DECLARE_FINAL_TYPE (FpDeviceVfs301, fpi_device_vfs301, FPI, DEVICE_VFS301, FpImageDevice) 55 | 56 | enum { 57 | /* Width of the scanned data in px */ 58 | VFS301_FP_WIDTH = 200, 59 | 60 | /* sizeof(fp_line_t) */ 61 | VFS301_FP_FRAME_SIZE = 288, 62 | /* Width of output line */ 63 | #ifndef OUTPUT_RAW 64 | VFS301_FP_OUTPUT_WIDTH = VFS301_FP_WIDTH, 65 | #else 66 | VFS301_FP_OUTPUT_WIDTH = VFS301_FP_FRAME_SIZE, 67 | #endif 68 | 69 | VFS301_FP_SUM_LINES = 3, 70 | 71 | #ifdef SCAN_FINISH_DETECTION 72 | /* TODO: The following changes (seen ~60 and ~80) In that 73 | * case we'll need to calibrate this from empty data somehow... */ 74 | VFS301_FP_SUM_MEDIAN = 60, 75 | VFS301_FP_SUM_EMPTY_RANGE = 5, 76 | #endif 77 | 78 | /* Minimum average difference between returned lines */ 79 | VFS301_FP_LINE_DIFF_THRESHOLD = 15, 80 | 81 | /* Maximum waiting time for a single fingerprint frame */ 82 | VFS301_FP_RECV_TIMEOUT = 2000 83 | }; 84 | 85 | /* Arrays of this structure is returned during the initialization as a response 86 | * to the 0x02D0 messages. 87 | * It seems to be always the same - what is it for? Some kind of confirmation? 88 | */ 89 | typedef struct 90 | { 91 | unsigned char sync_0x01; 92 | unsigned char sync_0xfe; 93 | 94 | unsigned char counter_lo; 95 | unsigned char counter_hi; /* FIXME ? */ 96 | 97 | unsigned char flags[3]; 98 | 99 | unsigned char sync_0x00; 100 | 101 | unsigned char scan[VFS301_FP_WIDTH]; 102 | } vfs301_init_line_t; 103 | 104 | typedef struct 105 | { 106 | unsigned char sync_0x01; 107 | unsigned char sync_0xfe; 108 | 109 | unsigned char counter_lo; 110 | unsigned char counter_hi; 111 | 112 | unsigned char sync_0x08[2]; /* XXX: always? 0x08 0x08 */ 113 | /* 0x08 | 0x18 - Looks like 0x08 marks good quality lines */ 114 | unsigned char flag_1; 115 | unsigned char sync_0x00; 116 | 117 | unsigned char scan[VFS301_FP_WIDTH]; 118 | 119 | /* A offsetted, stretched, inverted copy of scan... probably could 120 | * serve finger motion speed detection? 121 | * Seems to be subdivided to some 10B + 53B + 1B blocks */ 122 | unsigned char mirror[64]; 123 | 124 | /* Some kind of sum of the scan, very low contrast */ 125 | unsigned char sum1[2]; 126 | unsigned char sum2[11]; 127 | unsigned char sum3[3]; 128 | } vfs301_line_t; 129 | 130 | void vfs301_proto_init (FpDeviceVfs301 *dev); 131 | void vfs301_proto_deinit (FpDeviceVfs301 *dev); 132 | 133 | void vfs301_proto_request_fingerprint (FpDeviceVfs301 *dev); 134 | 135 | /** returns 0 if no event is ready, or 1 if there is one... */ 136 | int vfs301_proto_peek_event (FpDeviceVfs301 *dev); 137 | void vfs301_proto_process_event_start (FpDeviceVfs301 *dev); 138 | int vfs301_proto_process_event_poll (FpDeviceVfs301 *dev); 139 | 140 | void vfs301_extract_image (FpDeviceVfs301 *vfs, 141 | unsigned char *output, 142 | int *output_height); 143 | -------------------------------------------------------------------------------- /libfprint/drivers_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Driver API definitions 3 | * Copyright (C) 2007-2008 Daniel Drake 4 | * Copyright (C) 2018 Bastien Nocera 5 | * Copyright (C) 2019 Marco Trevisan 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "fpi-compat.h" 25 | #include "fpi-assembling.h" 26 | #include "fpi-device.h" 27 | #include "fpi-image-device.h" 28 | #include "fpi-image.h" 29 | #include "fpi-log.h" 30 | #include "fpi-print.h" 31 | #include "fpi-usb-transfer.h" 32 | #include "fpi-ssm.h" 33 | -------------------------------------------------------------------------------- /libfprint/empty_file: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libfprint/fp-context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FpContext - A FPrint context 3 | * Copyright (C) 2019 Benjamin Berg 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "fp-device.h" 23 | 24 | G_BEGIN_DECLS 25 | 26 | #define FP_TYPE_CONTEXT (fp_context_get_type ()) 27 | G_DECLARE_DERIVABLE_TYPE (FpContext, fp_context, FP, CONTEXT, GObject) 28 | 29 | /** 30 | * FpContextClass: 31 | * @device_added: Called when a new device is added 32 | * @device_removed: Called when a device is removed 33 | * 34 | * Class structure for #FpContext instances. 35 | */ 36 | struct _FpContextClass 37 | { 38 | GObjectClass parent_class; 39 | 40 | void (*device_added) (FpContext *context, 41 | FpDevice *device); 42 | void (*device_removed) (FpContext *context, 43 | FpDevice *device); 44 | }; 45 | 46 | FpContext *fp_context_new (void); 47 | 48 | void fp_context_enumerate (FpContext *context); 49 | 50 | GPtrArray *fp_context_get_devices (FpContext *context); 51 | 52 | G_END_DECLS 53 | -------------------------------------------------------------------------------- /libfprint/fp-device-private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FpDevice - A fingerprint reader device 3 | * Copyright (C) 2019 Benjamin Berg 4 | * Copyright (C) 2019 Marco Trevisan 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "fpi-device.h" 24 | 25 | typedef struct 26 | { 27 | FpDeviceType type; 28 | 29 | GUsbDevice *usb_device; 30 | const gchar *virtual_env; 31 | 32 | gboolean is_open; 33 | 34 | gchar *device_id; 35 | gchar *device_name; 36 | FpScanType scan_type; 37 | 38 | guint64 driver_data; 39 | 40 | gint nr_enroll_stages; 41 | GSList *sources; 42 | 43 | /* We always make sure that only one task is run at a time. */ 44 | FpiDeviceAction current_action; 45 | GTask *current_task; 46 | GAsyncReadyCallback current_user_cb; 47 | gulong current_cancellable_id; 48 | GSource *current_idle_cancel_source; 49 | GSource *current_task_idle_return_source; 50 | 51 | /* State for tasks */ 52 | gboolean wait_for_finger; 53 | } FpDevicePrivate; 54 | 55 | 56 | typedef struct 57 | { 58 | FpPrint *print; 59 | 60 | FpEnrollProgress enroll_progress_cb; 61 | gpointer enroll_progress_data; 62 | GDestroyNotify enroll_progress_destroy; 63 | } FpEnrollData; 64 | 65 | void enroll_data_free (FpEnrollData *enroll_data); 66 | 67 | typedef struct 68 | { 69 | FpPrint *enrolled_print; /* verify */ 70 | GPtrArray *gallery; /* identify */ 71 | 72 | gboolean result_reported; 73 | FpPrint *match; 74 | FpPrint *print; 75 | GError *error; 76 | 77 | FpMatchCb match_cb; 78 | gpointer match_data; 79 | GDestroyNotify match_destroy; 80 | } FpMatchData; 81 | 82 | void match_data_free (FpMatchData *match_data); 83 | -------------------------------------------------------------------------------- /libfprint/fp-image-device-private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FpImageDevice - An image based fingerprint reader device 3 | * Copyright (C) 2019 Benjamin Berg 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "fpi-image-device.h" 23 | 24 | #define IMG_ENROLL_STAGES 5 25 | 26 | typedef struct 27 | { 28 | FpiImageDeviceState state; 29 | gboolean active; 30 | gboolean cancelling; 31 | 32 | gboolean enroll_await_on_pending; 33 | gint enroll_stage; 34 | 35 | guint pending_activation_timeout_id; 36 | gboolean pending_activation_timeout_waiting_finger_off; 37 | 38 | gint bz3_threshold; 39 | } FpImageDevicePrivate; 40 | 41 | 42 | void fpi_image_device_activate (FpImageDevice *image_device); 43 | void fpi_image_device_deactivate (FpImageDevice *image_device); 44 | -------------------------------------------------------------------------------- /libfprint/fp-image-device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FpImageDevice - An image based fingerprint reader device 3 | * Copyright (C) 2019 Benjamin Berg 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | G_BEGIN_DECLS 25 | 26 | #define FP_TYPE_IMAGE_DEVICE (fp_image_device_get_type ()) 27 | G_DECLARE_DERIVABLE_TYPE (FpImageDevice, fp_image_device, FP, IMAGE_DEVICE, FpDevice) 28 | 29 | G_END_DECLS 30 | -------------------------------------------------------------------------------- /libfprint/fp-image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FPrint Image 3 | * Copyright (C) 2007 Daniel Drake 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | G_BEGIN_DECLS 26 | 27 | #define FP_TYPE_IMAGE (fp_image_get_type ()) 28 | 29 | typedef struct fp_minutia FpMinutia; 30 | 31 | G_DECLARE_FINAL_TYPE (FpImage, fp_image, FP, IMAGE, GObject) 32 | 33 | FpImage *fp_image_new (gint width, 34 | gint height); 35 | 36 | guint fp_image_get_width (FpImage *self); 37 | guint fp_image_get_height (FpImage *self); 38 | gdouble fp_image_get_ppmm (FpImage *self); 39 | 40 | GPtrArray * fp_image_get_minutiae (FpImage *self); 41 | 42 | void fp_image_detect_minutiae (FpImage *self, 43 | GCancellable *cancellable, 44 | GAsyncReadyCallback callback, 45 | gpointer user_data); 46 | gboolean fp_image_detect_minutiae_finish (FpImage *self, 47 | GAsyncResult *result, 48 | GError **error); 49 | 50 | const guchar * fp_image_get_data (FpImage *self, 51 | gsize *len); 52 | const guchar * fp_image_get_binarized (FpImage *self, 53 | gsize *len); 54 | 55 | void fp_minutia_get_coords (FpMinutia *min, 56 | gint *x, 57 | gint *y); 58 | 59 | G_END_DECLS 60 | -------------------------------------------------------------------------------- /libfprint/fp-print-private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FPrint Print handling 3 | * Copyright (C) 2007 Daniel Drake 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "fpi-print.h" 22 | #include "fpi-image.h" 23 | 24 | #include 25 | 26 | struct _FpPrint 27 | { 28 | GInitiallyUnowned parent_instance; 29 | 30 | FpiPrintType type; 31 | 32 | gchar *driver; 33 | gchar *device_id; 34 | gboolean device_stored; 35 | 36 | FpImage *image; 37 | 38 | /* Metadata */ 39 | FpFinger finger; 40 | gchar *username; 41 | gchar *description; 42 | GDate *enroll_date; 43 | 44 | GVariant *data; 45 | GPtrArray *prints; 46 | }; 47 | -------------------------------------------------------------------------------- /libfprint/fp-print.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FPrint Print handling 3 | * Copyright (C) 2007 Daniel Drake 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "fp-image.h" 24 | #include "fp-enums.h" 25 | 26 | G_BEGIN_DECLS 27 | 28 | #define FP_TYPE_PRINT (fp_print_get_type ()) 29 | G_DECLARE_FINAL_TYPE (FpPrint, fp_print, FP, PRINT, GInitiallyUnowned) 30 | 31 | #define FP_FINGER_IS_VALID(finger) \ 32 | ((finger) >= FP_FINGER_FIRST && (finger) <= FP_FINGER_LAST) 33 | 34 | #include "fp-device.h" 35 | 36 | /** 37 | * FpFinger: 38 | * @FP_FINGER_UNKNOWN: The finger is unknown 39 | * @FP_FINGER_LEFT_THUMB: Left thumb 40 | * @FP_FINGER_LEFT_INDEX: Left index finger 41 | * @FP_FINGER_LEFT_MIDDLE: Left middle finger 42 | * @FP_FINGER_LEFT_RING: Left ring finger 43 | * @FP_FINGER_LEFT_LITTLE: Left little finger 44 | * @FP_FINGER_RIGHT_THUMB: Right thumb 45 | * @FP_FINGER_RIGHT_INDEX: Right index finger 46 | * @FP_FINGER_RIGHT_MIDDLE: Right middle finger 47 | * @FP_FINGER_RIGHT_RING: Right ring finger 48 | * @FP_FINGER_RIGHT_LITTLE: Right little finger 49 | * @FP_FINGER_FIRST: The first finger in the fp-print order 50 | * @FP_FINGER_LAST: The last finger in the fp-print order 51 | */ 52 | typedef enum { 53 | FP_FINGER_UNKNOWN = 0, 54 | FP_FINGER_LEFT_THUMB, 55 | FP_FINGER_LEFT_INDEX, 56 | FP_FINGER_LEFT_MIDDLE, 57 | FP_FINGER_LEFT_RING, 58 | FP_FINGER_LEFT_LITTLE, 59 | FP_FINGER_RIGHT_THUMB, 60 | FP_FINGER_RIGHT_INDEX, 61 | FP_FINGER_RIGHT_MIDDLE, 62 | FP_FINGER_RIGHT_RING, 63 | FP_FINGER_RIGHT_LITTLE, 64 | 65 | FP_FINGER_FIRST = FP_FINGER_LEFT_THUMB, 66 | FP_FINGER_LAST = FP_FINGER_RIGHT_LITTLE, 67 | } FpFinger; 68 | 69 | FpPrint *fp_print_new (FpDevice *device); 70 | 71 | FpPrint *fp_print_new_from_data (guchar *data, 72 | gsize length); 73 | gboolean fp_print_to_data (guchar **data, 74 | gsize length); 75 | 76 | const gchar *fp_print_get_driver (FpPrint *print); 77 | const gchar *fp_print_get_device_id (FpPrint *print); 78 | FpImage *fp_print_get_image (FpPrint *print); 79 | 80 | FpFinger fp_print_get_finger (FpPrint *print); 81 | const gchar *fp_print_get_username (FpPrint *print); 82 | const gchar *fp_print_get_description (FpPrint *print); 83 | const GDate *fp_print_get_enroll_date (FpPrint *print); 84 | gboolean fp_print_get_device_stored (FpPrint *print); 85 | 86 | void fp_print_set_finger (FpPrint *print, 87 | FpFinger finger); 88 | void fp_print_set_username (FpPrint *print, 89 | const gchar *username); 90 | void fp_print_set_description (FpPrint *print, 91 | const gchar *description); 92 | void fp_print_set_enroll_date (FpPrint *print, 93 | const GDate *enroll_date); 94 | 95 | gboolean fp_print_compatible (FpPrint *self, 96 | FpDevice *device); 97 | gboolean fp_print_equal (FpPrint *self, 98 | FpPrint *other); 99 | 100 | gboolean fp_print_serialize (FpPrint *print, 101 | guchar **data, 102 | gsize *length, 103 | GError **error); 104 | 105 | FpPrint *fp_print_deserialize (const guchar *data, 106 | gsize length, 107 | GError **error); 108 | 109 | G_END_DECLS 110 | -------------------------------------------------------------------------------- /libfprint/fpi-assembling.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Daniel Drake 3 | * Copyright (C) 2015 Vasily Khoruzhick 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | /** 25 | * fpi_frame: 26 | * @delta_x: X offset of the frame 27 | * @delta_y: Y offset of the frame 28 | * @data: bitmap 29 | * 30 | * #fpi_frame is used to store frames for swipe sensors. Drivers should 31 | * populate delta_x and delta_y if the device supports hardware movement 32 | * estimation. 33 | */ 34 | struct fpi_frame 35 | { 36 | int delta_x; 37 | int delta_y; 38 | unsigned char data[0]; 39 | }; 40 | 41 | /** 42 | * fpi_frame_asmbl_ctx: 43 | * @frame_width: width of the frame 44 | * @frame_height: height of the frame 45 | * @image_width: resulting image width 46 | * @get_pixel: pixel accessor, returns pixel brightness at x,y of frame 47 | * 48 | * #fpi_frame_asmbl_ctx is a structure holding the context for frame 49 | * assembling routines. 50 | * 51 | * Drivers should define their own #fpi_frame_asmbl_ctx depending on 52 | * hardware parameters of scanner. @image_width is usually 25% wider than 53 | * @frame_width to take horizontal movement into account. 54 | */ 55 | struct fpi_frame_asmbl_ctx 56 | { 57 | unsigned int frame_width; 58 | unsigned int frame_height; 59 | unsigned int image_width; 60 | unsigned char (*get_pixel)(struct fpi_frame_asmbl_ctx *ctx, 61 | struct fpi_frame *frame, 62 | unsigned int x, 63 | unsigned int y); 64 | }; 65 | 66 | void fpi_do_movement_estimation (struct fpi_frame_asmbl_ctx *ctx, 67 | GSList *stripes); 68 | 69 | FpImage *fpi_assemble_frames (struct fpi_frame_asmbl_ctx *ctx, 70 | GSList *stripes); 71 | 72 | /** 73 | * fpi_line_asmbl_ctx: 74 | * @line_width: width of line 75 | * @max_height: maximal height of assembled image 76 | * @resolution: scale factor used for line assembling routines. 77 | * @median_filter_size: size of median filter for movement estimation 78 | * @max_search_offset: the number of lines to search for the next line 79 | * @get_deviation: pointer to a function that returns the numerical difference 80 | * between two lines 81 | * @get_pixel: pixel accessor, returns pixel brightness at x of line 82 | * 83 | * #fpi_line_asmbl_ctx is a structure holding the context for line assembling 84 | * routines. 85 | * 86 | * Drivers should define their own #fpi_line_asmbl_ctx depending on 87 | * the hardware parameters of the scanner. Swipe scanners of this type usually 88 | * return two lines, the second line is often narrower than first and is used 89 | * for movement estimation. 90 | * 91 | * The @max_search_offset value indicates how many lines forward the assembling 92 | * routines should look while searching for next line. This value depends on 93 | * how fast the hardware sends frames. 94 | * 95 | * The function pointed to by @get_deviation should return the numerical difference 96 | * between two lines. Higher values means lines are more different. If the reader 97 | * returns two lines at a time, this function should be used to estimate the 98 | * difference between pairs of lines. 99 | */ 100 | struct fpi_line_asmbl_ctx 101 | { 102 | unsigned int line_width; 103 | unsigned int max_height; 104 | unsigned int resolution; 105 | unsigned int median_filter_size; 106 | unsigned int max_search_offset; 107 | int (*get_deviation)(struct fpi_line_asmbl_ctx *ctx, 108 | GSList *line1, 109 | GSList *line2); 110 | unsigned char (*get_pixel)(struct fpi_line_asmbl_ctx *ctx, 111 | GSList *line, 112 | unsigned int x); 113 | }; 114 | 115 | FpImage *fpi_assemble_lines (struct fpi_line_asmbl_ctx *ctx, 116 | GSList *lines, 117 | size_t num_lines); 118 | -------------------------------------------------------------------------------- /libfprint/fpi-compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Benjamin Berg 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #if !GLIB_CHECK_VERSION (2, 57, 0) 24 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (GTypeClass, g_type_class_unref); 25 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (GEnumClass, g_type_class_unref); 26 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (GParamSpec, g_param_spec_unref); 27 | #else 28 | /* Re-define G_SOURCE_FUNC as we are technically not allowed to use it with 29 | * the version we depend on currently. */ 30 | #undef G_SOURCE_FUNC 31 | #endif 32 | 33 | #define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void))(f)) 34 | 35 | #if !GLIB_CHECK_VERSION (2, 63, 3) 36 | typedef struct _FpDeviceClass FpDeviceClass; 37 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpDeviceClass, g_type_class_unref); 38 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (GDate, g_date_free); 39 | #endif 40 | -------------------------------------------------------------------------------- /libfprint/fpi-context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FpContext - A FPrint context 3 | * Copyright (C) 2019 Benjamin Berg 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | #pragma once 20 | 21 | #include 22 | #include "fp-context.h" 23 | #include "fpi-compat.h" 24 | 25 | /** 26 | * fpi_get_driver_types: 27 | * 28 | * This function is purely for private used. It is solely part of the public 29 | * API as it is useful during build time. 30 | * 31 | * Stability: private 32 | * Returns: (element-type GType) (transfer container): a #GArray filled with 33 | * all driver types 34 | */ 35 | GArray *fpi_get_driver_types (void); 36 | -------------------------------------------------------------------------------- /libfprint/fpi-image.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FPrint Image - Private APIs 3 | * Copyright (C) 2007 Daniel Drake 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #define FP_COMPONENT "image" 22 | 23 | #include "fpi-image.h" 24 | #include "fpi-log.h" 25 | 26 | #include 27 | 28 | #if HAVE_PIXMAN 29 | #include 30 | #endif 31 | 32 | /** 33 | * SECTION: fpi-image 34 | * @title: Internal FpImage 35 | * @short_description: Internal image handling routines 36 | * 37 | * Internal image handling routines. See #FpImage for public routines. 38 | */ 39 | 40 | /** 41 | * fpi_std_sq_dev: 42 | * @buf: buffer (usually bitmap, one byte per pixel) 43 | * @size: size of @buffer 44 | * 45 | * Calculates the squared standard deviation of the individual 46 | * pixels in the buffer, as per the following formula: 47 | * |[ 48 | * mean = sum (buf[0..size]) / size 49 | * sq_dev = sum ((buf[0.size] - mean) ^ 2) 50 | * ]| 51 | * This function is usually used to determine whether image 52 | * is empty. 53 | * 54 | * Returns: the squared standard deviation for @buffer 55 | */ 56 | gint 57 | fpi_std_sq_dev (const guint8 *buf, 58 | gint size) 59 | { 60 | guint64 res = 0, mean = 0; 61 | gint i; 62 | 63 | for (i = 0; i < size; i++) 64 | mean += buf[i]; 65 | 66 | mean /= size; 67 | 68 | for (i = 0; i < size; i++) 69 | { 70 | int dev = (int) buf[i] - mean; 71 | res += dev * dev; 72 | } 73 | 74 | return res / size; 75 | } 76 | 77 | /** 78 | * fpi_mean_sq_diff_norm: 79 | * @buf1: buffer (usually bitmap, one byte per pixel) 80 | * @buf2: buffer (usually bitmap, one byte per pixel) 81 | * @size: buffer size of smallest buffer 82 | * 83 | * This function calculates the normalized mean square difference of 84 | * two buffers, usually two lines, as per the following formula: 85 | * |[ 86 | * sq_diff = sum ((buf1[0..size] - buf2[0..size]) ^ 2) / size 87 | * ]| 88 | * 89 | * This functions is usually used to get numerical difference 90 | * between two images. 91 | * 92 | * Returns: the normalized mean squared difference between @buf1 and @buf2 93 | */ 94 | gint 95 | fpi_mean_sq_diff_norm (const guint8 *buf1, 96 | const guint8 *buf2, 97 | gint size) 98 | { 99 | int res = 0, i; 100 | 101 | for (i = 0; i < size; i++) 102 | { 103 | int dev = (int) buf1[i] - (int) buf2[i]; 104 | res += dev * dev; 105 | } 106 | 107 | return res / size; 108 | } 109 | 110 | #if HAVE_PIXMAN 111 | FpImage * 112 | fpi_image_resize (FpImage *orig_img, 113 | guint w_factor, 114 | guint h_factor) 115 | { 116 | int new_width = orig_img->width * w_factor; 117 | int new_height = orig_img->height * h_factor; 118 | pixman_image_t *orig, *resized; 119 | pixman_transform_t transform; 120 | FpImage *newimg; 121 | 122 | orig = pixman_image_create_bits (PIXMAN_a8, orig_img->width, orig_img->height, (uint32_t *) orig_img->data, orig_img->width); 123 | resized = pixman_image_create_bits (PIXMAN_a8, new_width, new_height, NULL, new_width); 124 | 125 | pixman_transform_init_identity (&transform); 126 | pixman_transform_scale (NULL, &transform, pixman_int_to_fixed (w_factor), pixman_int_to_fixed (h_factor)); 127 | pixman_image_set_transform (orig, &transform); 128 | pixman_image_set_filter (orig, PIXMAN_FILTER_BILINEAR, NULL, 0); 129 | pixman_image_composite32 (PIXMAN_OP_SRC, 130 | orig, /* src */ 131 | NULL, /* mask */ 132 | resized, /* dst */ 133 | 0, 0, /* src x y */ 134 | 0, 0, /* mask x y */ 135 | 0, 0, /* dst x y */ 136 | new_width, new_height /* width height */ 137 | ); 138 | 139 | newimg = fp_image_new (new_width, new_height); 140 | newimg->flags = orig_img->flags; 141 | 142 | memcpy (newimg->data, pixman_image_get_data (resized), new_width * new_height); 143 | 144 | pixman_image_unref (orig); 145 | pixman_image_unref (resized); 146 | 147 | return newimg; 148 | } 149 | #endif 150 | -------------------------------------------------------------------------------- /libfprint/fpi-image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FPrint Image 3 | * Copyright (C) 2007 Daniel Drake 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | #include "fp-image.h" 25 | 26 | /** 27 | * FpiImageFlags: 28 | * @FPI_IMAGE_V_FLIPPED: the image is vertically flipped 29 | * @FPI_IMAGE_H_FLIPPED: the image is horizontally flipped 30 | * @FPI_IMAGE_COLORS_INVERTED: the colours are inverted 31 | * 32 | * Flags used in an #FpImage structure to describe the contained image. 33 | * This is useful for image drivers as they can simply set these flags and 34 | * rely on the image to be normalized by libfprint before further processing. 35 | */ 36 | typedef enum { 37 | FPI_IMAGE_V_FLIPPED = 1 << 0, 38 | FPI_IMAGE_H_FLIPPED = 1 << 1, 39 | FPI_IMAGE_COLORS_INVERTED = 1 << 2, 40 | FPI_IMAGE_PARTIAL = 1 << 3, 41 | } FpiImageFlags; 42 | 43 | /** 44 | * FpImage: 45 | * @width: Width of the image 46 | * @height: Height of the image 47 | * @ppmm: Pixels per millimeter 48 | * @flags: #FpiImageFlags for required normalization 49 | * 50 | * Structure holding an image. The public fields are only public for internal 51 | * use by the drivers. 52 | */ 53 | struct _FpImage 54 | { 55 | /*< private >*/ 56 | GObject parent; 57 | 58 | /*< public >*/ 59 | guint width; 60 | guint height; 61 | 62 | gdouble ppmm; 63 | 64 | FpiImageFlags flags; 65 | 66 | /*< private >*/ 67 | guint8 *data; 68 | guint8 *binarized; 69 | 70 | GPtrArray *minutiae; 71 | guint ref_count; 72 | }; 73 | 74 | gint fpi_std_sq_dev (const guint8 *buf, 75 | gint size); 76 | gint fpi_mean_sq_diff_norm (const guint8 *buf1, 77 | const guint8 *buf2, 78 | gint size); 79 | 80 | #if HAVE_PIXMAN 81 | FpImage *fpi_image_resize (FpImage *orig, 82 | guint w_factor, 83 | guint h_factor); 84 | #endif 85 | -------------------------------------------------------------------------------- /libfprint/fpi-log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Daniel Drake 3 | * Copyright (C) 2018 Bastien Nocera 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | /** 23 | * SECTION:fpi-log 24 | * @title: Logging 25 | * @short_description: Logging functions 26 | * 27 | * Logging in libfprint is handled through GLib's logging system, and behave the same 28 | * way as in the GLib [Message Output and Debugging Functions](https://developer.gnome.org/glib/stable/glib-Message-Logging.html) 29 | * documentation. 30 | * 31 | * You should include `fpi-log.h` as early as possible in your sources, just after 32 | * setting the `FP_COMPONENT` define to a string unique to your sources. This will 33 | * set the suffix of the `G_LOG_DOMAIN` used for printing. 34 | */ 35 | 36 | #ifdef FP_COMPONENT 37 | #undef G_LOG_DOMAIN 38 | #ifndef __GTK_DOC_IGNORE__ 39 | #define G_LOG_DOMAIN "libfprint-"FP_COMPONENT 40 | #endif 41 | #endif 42 | 43 | #include 44 | 45 | /** 46 | * fp_dbg: 47 | * 48 | * Same as g_debug(). 49 | * 50 | */ 51 | #define fp_dbg g_debug 52 | 53 | /** 54 | * fp_info: 55 | * 56 | * Same as g_debug(). 57 | */ 58 | #define fp_info g_debug 59 | 60 | /** 61 | * fp_warn: 62 | * 63 | * Same as g_warning(). 64 | */ 65 | #define fp_warn g_warning 66 | 67 | /** 68 | * fp_err: 69 | * 70 | * Same as g_critical(). In the future, this might be changed to a 71 | * g_assert() instead, so bear this in mind when adding those calls 72 | * to your driver. 73 | */ 74 | #define fp_err g_critical 75 | 76 | /** 77 | * BUG_ON: 78 | * @condition: the condition to check 79 | * 80 | * Uses fp_err() to print an error if the @condition is true. 81 | */ 82 | #define BUG_ON(condition) G_STMT_START \ 83 | if (condition) { \ 84 | char *s; \ 85 | s = g_strconcat ("BUG: (", #condition, ")", NULL); \ 86 | fp_err ("%s: %s() %s:%d", s, G_STRFUNC, __FILE__, __LINE__); \ 87 | g_free (s); \ 88 | } G_STMT_END 89 | 90 | /** 91 | * BUG: 92 | * 93 | * Same as BUG_ON() but is always true. 94 | */ 95 | #define BUG() BUG_ON (1) 96 | -------------------------------------------------------------------------------- /libfprint/fpi-minutiae.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Internal/private definitions for libfprint 3 | * Copyright (C) 2007-2008 Daniel Drake 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | /* fp_minutia structure definition */ 23 | struct fp_minutia 24 | { 25 | int x; 26 | int y; 27 | int ex; 28 | int ey; 29 | int direction; 30 | double reliability; 31 | int type; 32 | int appearing; 33 | int feature_id; 34 | int *nbrs; 35 | int *ridge_counts; 36 | int num_nbrs; 37 | }; 38 | 39 | /* fp_minutiae structure definition */ 40 | struct fp_minutiae 41 | { 42 | int alloc; 43 | int num; 44 | struct fp_minutia **list; 45 | }; 46 | -------------------------------------------------------------------------------- /libfprint/fpi-print.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "fpi-enums.h" 4 | #include "fp-device.h" 5 | #include "fp-print.h" 6 | 7 | G_BEGIN_DECLS 8 | 9 | /** 10 | * FpiPrintType: 11 | * @FPI_PRINT_UNDEFINED: Undefined type, this happens prior to enrollment 12 | * @FPI_PRINT_RAW: A raw print where the data is directly compared 13 | * @FPI_PRINT_NBIS: NBIS minutiae comparison 14 | */ 15 | typedef enum { 16 | FPI_PRINT_UNDEFINED = 0, 17 | FPI_PRINT_RAW, 18 | FPI_PRINT_NBIS, 19 | } FpiPrintType; 20 | 21 | /** 22 | * FpiMatchResult: 23 | * @FPI_MATCH_ERROR: An error occurred during matching 24 | * @FPI_MATCH_FAIL: The prints did not match 25 | * @FPI_MATCH_SUCCESS: The prints matched 26 | */ 27 | typedef enum { 28 | FPI_MATCH_ERROR = -1, /* -1 for g_task_propagate_int */ 29 | FPI_MATCH_FAIL, 30 | FPI_MATCH_SUCCESS, 31 | } FpiMatchResult; 32 | 33 | void fpi_print_add_print (FpPrint *print, 34 | FpPrint *add); 35 | 36 | void fpi_print_set_type (FpPrint *print, 37 | FpiPrintType type); 38 | void fpi_print_set_device_stored (FpPrint *print, 39 | gboolean device_stored); 40 | 41 | gboolean fpi_print_add_from_image (FpPrint *print, 42 | FpImage *image, 43 | GError **error); 44 | 45 | FpiMatchResult fpi_print_bz3_match (FpPrint * template, 46 | FpPrint * print, 47 | gint bz3_threshold, 48 | GError **error); 49 | 50 | /* Helpers to encode metadata into user ID strings. */ 51 | gchar * fpi_print_generate_user_id (FpPrint *print); 52 | gboolean fpi_print_fill_from_user_id (FpPrint *print, 53 | const char *user_id); 54 | 55 | G_END_DECLS 56 | -------------------------------------------------------------------------------- /libfprint/fprint-list-supported-devices.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Red Hat 3 | * Copyright (C) 2008 Bastien Nocera 4 | * Copyright (C) 2008 Timo Hoenig , 5 | * Copyright (C) 2019 Benjamin Berg 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "fpi-context.h" 27 | #include "fpi-device.h" 28 | 29 | GHashTable *printed = NULL; 30 | 31 | static GList * 32 | insert_drivers (GList *list) 33 | { 34 | g_autoptr(GArray) drivers = fpi_get_driver_types (); 35 | gint i; 36 | 37 | /* Find the best driver to handle this USB device. */ 38 | for (i = 0; i < drivers->len; i++) 39 | { 40 | GType driver = g_array_index (drivers, GType, i); 41 | g_autoptr(FpDeviceClass) cls = g_type_class_ref (driver); 42 | const FpIdEntry *entry; 43 | 44 | if (cls->type != FP_DEVICE_TYPE_USB) 45 | continue; 46 | 47 | for (entry = cls->id_table; entry->vid; entry++) 48 | { 49 | char *key; 50 | 51 | key = g_strdup_printf ("%04x:%04x", entry->vid, entry->pid); 52 | 53 | if (g_hash_table_lookup (printed, key) != NULL) 54 | { 55 | g_free (key); 56 | continue; 57 | } 58 | 59 | g_hash_table_insert (printed, key, GINT_TO_POINTER (1)); 60 | 61 | list = g_list_prepend (list, g_strdup_printf ("%s | %s\n", key, cls->full_name)); 62 | } 63 | } 64 | 65 | return list; 66 | } 67 | 68 | int 69 | main (int argc, char **argv) 70 | { 71 | GList *list, *l; 72 | 73 | setlocale (LC_ALL, ""); 74 | 75 | printed = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); 76 | 77 | g_print ("%% lifprint — Supported Devices\n"); 78 | g_print ("%% Bastien Nocera, Daniel Drake\n"); 79 | g_print ("%% 2018\n"); 80 | g_print ("\n"); 81 | 82 | g_print ("# Supported Devices\n"); 83 | g_print ("\n"); 84 | g_print ("This is a list of supported devices in libfprint's development version. Those drivers might not all be available in the stable, released version. If in doubt, contact your distribution or systems integrator for details.\n"); 85 | g_print ("\n"); 86 | g_print ("## USB devices\n"); 87 | g_print ("\n"); 88 | g_print ("USB ID | Driver\n"); 89 | g_print ("------------ | ------------\n"); 90 | 91 | list = NULL; 92 | list = insert_drivers (list); 93 | 94 | list = g_list_sort (list, (GCompareFunc) g_strcmp0); 95 | for (l = list; l != NULL; l = l->next) 96 | g_print ("%s", (char *) l->data); 97 | 98 | g_list_free_full (list, g_free); 99 | g_hash_table_destroy (printed); 100 | 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /libfprint/fprint-list-udev-rules.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Red Hat 3 | * Copyright (C) 2008 Bastien Nocera 4 | * Copyright (C) 2008 Timo Hoenig , 5 | * Copyright (C) 2019 Benjamin Berg 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | 24 | #include "fpi-context.h" 25 | #include "fpi-device.h" 26 | 27 | static const FpIdEntry whitelist_id_table[] = { 28 | /* Unsupported (for now) Validity Sensors finger print readers */ 29 | { .vid = 0x138a, .pid = 0x0091 }, 30 | { .vid = 0x138a, .pid = 0x0094 }, 31 | { .vid = 0x138a, .pid = 0x0097 }, /* Found on e.g. Lenovo T470s */ 32 | { .vid = 0 }, 33 | }; 34 | 35 | static const FpIdEntry blacklist_id_table[] = { 36 | { .vid = 0x0483, .pid = 0x2016 }, 37 | /* https://bugs.freedesktop.org/show_bug.cgi?id=66659 */ 38 | { .vid = 0x045e, .pid = 0x00bb }, 39 | { .vid = 0 }, 40 | }; 41 | 42 | static const FpDeviceClass whitelist = { 43 | .type = FP_DEVICE_TYPE_USB, 44 | .id_table = whitelist_id_table, 45 | .full_name = "Hardcoded whitelist" 46 | }; 47 | 48 | GHashTable *printed = NULL; 49 | 50 | static void 51 | print_driver (const FpDeviceClass *cls) 52 | { 53 | const FpIdEntry *entry; 54 | gint num_printed = 0; 55 | 56 | if (cls->type != FP_DEVICE_TYPE_USB) 57 | return; 58 | 59 | for (entry = cls->id_table; entry->vid != 0; entry++) 60 | { 61 | const FpIdEntry *bl_entry; 62 | char *key; 63 | 64 | for (bl_entry = blacklist_id_table; bl_entry->vid != 0; bl_entry++) 65 | if (entry->vid == bl_entry->vid && entry->pid == bl_entry->pid) 66 | break; 67 | 68 | if (bl_entry->vid != 0) 69 | continue; 70 | 71 | key = g_strdup_printf ("%04x:%04x", entry->vid, entry->pid); 72 | 73 | if (g_hash_table_lookup (printed, key) != NULL) 74 | { 75 | g_free (key); 76 | continue; 77 | } 78 | 79 | g_hash_table_insert (printed, key, GINT_TO_POINTER (1)); 80 | 81 | if (num_printed == 0) 82 | g_print ("# %s\n", cls->full_name); 83 | 84 | g_print ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ATTRS{dev}==\"*\", TEST==\"power/control\", ATTR{power/control}=\"auto\"\n", 85 | entry->vid, entry->pid); 86 | g_print ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ENV{LIBFPRINT_DRIVER}=\"%s\"\n", 87 | entry->vid, entry->pid, cls->full_name); 88 | num_printed++; 89 | } 90 | 91 | if (num_printed > 0) 92 | g_print ("\n"); 93 | } 94 | 95 | int 96 | main (int argc, char **argv) 97 | { 98 | g_autoptr(GArray) drivers = fpi_get_driver_types (); 99 | guint i; 100 | 101 | printed = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); 102 | 103 | for (i = 0; i < drivers->len; i++) 104 | { 105 | GType driver = g_array_index (drivers, GType, i); 106 | g_autoptr(FpDeviceClass) cls = g_type_class_ref (driver); 107 | 108 | if (cls->type != FP_DEVICE_TYPE_USB) 109 | continue; 110 | 111 | print_driver (cls); 112 | } 113 | 114 | print_driver (&whitelist); 115 | 116 | g_hash_table_destroy (printed); 117 | 118 | return 0; 119 | } 120 | -------------------------------------------------------------------------------- /libfprint/fprint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Main definitions for libfprint 3 | * Copyright (C) 2019 Benjamin Berg 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "fp-context.h" 23 | #include "fp-device.h" 24 | #include "fp-image.h" 25 | -------------------------------------------------------------------------------- /libfprint/libfprint.ver: -------------------------------------------------------------------------------- 1 | LIBFPRINT_2.0.0 { 2 | global: 3 | fp_*; 4 | local: 5 | *; 6 | }; 7 | -------------------------------------------------------------------------------- /libfprint/nbis/bozorth3/bz_alloc.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | /*********************************************************************** 45 | LIBRARY: FING - NIST Fingerprint Systems Utilities 46 | 47 | FILE: BZ_ALLOC.C 48 | ALGORITHM: Allan S. Bozorth (FBI) 49 | MODIFICATIONS: Michael D. Garris (NIST) 50 | Stan Janet (NIST) 51 | DATE: 09/21/2004 52 | 53 | Contains routines responsible for supporting the 54 | Bozorth3 fingerprint matching algorithm. 55 | 56 | *********************************************************************** 57 | 58 | ROUTINES: 59 | #cat: malloc_or_exit - allocates a buffer of bytes from the heap of 60 | #cat: specified length exiting directly upon system error 61 | #cat: malloc_or_return_error - allocates a buffer of bytes from the heap 62 | #cat: of specified length returning an error code upon system error 63 | 64 | ***********************************************************************/ 65 | 66 | #include 67 | #include 68 | #include 69 | 70 | 71 | /***********************************************************************/ 72 | 73 | /***********************************************************************/ 74 | /* returns CNULL on error */ 75 | -------------------------------------------------------------------------------- /libfprint/nbis/fix-scan-build-reports.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libfprint/nbis/mindtct/contour.c b/libfprint/nbis/mindtct/contour.c 2 | index 3e9416c..31f32d0 100644 3 | --- mindtct/contour.c 4 | +++ mindtct/contour.c 5 | @@ -440,6 +440,8 @@ int get_centered_contour(int **ocontour_x, int **ocontour_y, 6 | int *contour_x, *contour_y, *contour_ex, *contour_ey, ncontour; 7 | int i, j, ret; 8 | 9 | + g_assert (half_contour > 0); 10 | + 11 | /* Compute maximum length of complete contour */ 12 | /* (2 half contours + feature point). */ 13 | max_contour = (half_contour<<1) + 1; 14 | diff --git a/libfprint/nbis/mindtct/minutia.c b/libfprint/nbis/mindtct/minutia.c 15 | index 0b29aa0..77cf09d 100644 16 | --- mindtct/minutia.c 17 | +++ mindtct/minutia.c 18 | @@ -1625,7 +1625,7 @@ int process_horizontal_scan_minutia_V2(MINUTIAE *minutiae, 19 | dmapval, bdata, iw, ih, lfsparms); 20 | 21 | /* If minuitia IGNORED and not added to the minutia list ... */ 22 | - if(ret == IGNORE) 23 | + if(ret != 0) 24 | /* Deallocate the minutia. */ 25 | free_minutia(minutia); 26 | 27 | @@ -1776,7 +1776,7 @@ int process_vertical_scan_minutia_V2(MINUTIAE *minutiae, 28 | dmapval, bdata, iw, ih, lfsparms); 29 | 30 | /* If minuitia IGNORED and not added to the minutia list ... */ 31 | - if(ret == IGNORE) 32 | + if(ret != 0) 33 | /* Deallocate the minutia. */ 34 | free_minutia(minutia); 35 | 36 | diff --git a/libfprint/nbis/mindtct/ridges.c b/libfprint/nbis/mindtct/ridges.c 37 | index f0d9cd3..9902585 100644 38 | --- mindtct/ridges.c 39 | +++ mindtct/ridges.c 40 | @@ -147,6 +147,8 @@ int count_minutia_ridges(const int first, MINUTIAE *minutiae, 41 | { 42 | int i, ret, *nbr_list, *nbr_nridges, nnbrs; 43 | 44 | + g_assert (lfsparms->max_nbrs > 0); 45 | + 46 | /* Find up to the maximum number of qualifying neighbors. */ 47 | nbr_list = NULL; 48 | if((ret = find_neighbors(&nbr_list, &nnbrs, lfsparms->max_nbrs, 49 | @@ -407,6 +409,8 @@ int insert_neighbor(const int pos, const int nbr_index, const double nbr_dist2, 50 | { 51 | int i; 52 | 53 | + g_assert (pos >= 0); 54 | + 55 | /* If the desired insertion position is beyond one passed the last */ 56 | /* neighbor in the lists OR greater than equal to the maximum ... */ 57 | /* NOTE: pos is zero-oriented while nnbrs and max_nbrs are 1-oriented. */ 58 | -------------------------------------------------------------------------------- /libfprint/nbis/glib-mem-warning.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libfprint/nbis/mindtct/shape.c b/libfprint/nbis/mindtct/shape.c 2 | index 28bc66c..c399f36 100644 3 | --- mindtct/shape.c 4 | +++ mindtct/shape.c 5 | @@ -86,7 +86,7 @@ int alloc_shape(SHAPE **oshape, const int xmin, const int ymin, 6 | { 7 | SHAPE *shape; 8 | int alloc_rows, alloc_pts; 9 | - int i, j, y; 10 | + int i, y; 11 | 12 | /* Compute allocation parameters. */ 13 | /* First, compute the number of scanlines spanned by the shape. */ 14 | -------------------------------------------------------------------------------- /libfprint/nbis/glib-memory.cocci: -------------------------------------------------------------------------------- 1 | @ free @ 2 | expression ptr; 3 | @@ 4 | - free(ptr); 5 | + g_free(ptr); 6 | @ malloc @ 7 | type ptr_type; 8 | expression ptr; 9 | expression size; 10 | @@ 11 | - ptr = (ptr_type) malloc(size); 12 | + ptr = (ptr_type) g_malloc(size); 13 | ... 14 | ( 15 | - if (ptr == (ptr_type) NULL) { ... } 16 | | 17 | ) 18 | @ realloc @ 19 | type ptr_type; 20 | expression ptr; 21 | expression size; 22 | @@ 23 | - ptr = (ptr_type) realloc(ptr, size); 24 | + ptr = (ptr_type) g_realloc(ptr, size); 25 | ... 26 | ( 27 | - if (ptr == (ptr_type) NULL) { ... } 28 | | 29 | ) 30 | -------------------------------------------------------------------------------- /libfprint/nbis/include/bz_array.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | #ifndef _BZ_ARRAY_H 45 | #define _BZ_ARRAY_H 46 | 47 | #define STATIC static 48 | /* #define BAD_BOUNDS 1 */ 49 | 50 | #define COLP_SIZE_1 20000 51 | #define COLP_SIZE_2 5 52 | 53 | #define COLS_SIZE_2 6 54 | #define SCOLS_SIZE_1 20000 55 | #define FCOLS_SIZE_1 20000 56 | 57 | #define SCOLPT_SIZE 20000 58 | #define FCOLPT_SIZE 20000 59 | 60 | #define SC_SIZE 20000 61 | 62 | 63 | #define RQ_SIZE 20000 64 | #define TQ_SIZE 20000 65 | #define ZZ_SIZE 20000 66 | 67 | 68 | 69 | #define RX_SIZE 100 70 | #define MM_SIZE 100 71 | #define NN_SIZE 20 72 | 73 | 74 | 75 | #define RK_SIZE 20000 76 | 77 | 78 | 79 | #define RR_SIZE 100 80 | #define AVN_SIZE 5 81 | #define AVV_SIZE_1 2000 82 | #define AVV_SIZE_2 5 83 | #define CT_SIZE 2000 84 | #define GCT_SIZE 2000 85 | #define CTT_SIZE 2000 86 | 87 | 88 | #ifdef BAD_BOUNDS 89 | #define CTP_SIZE_1 2000 90 | #define CTP_SIZE_2 1000 91 | #else 92 | #define CTP_SIZE_1 2000 93 | #define CTP_SIZE_2 2500 94 | #endif 95 | 96 | 97 | 98 | /* 99 | rp[x] == ctp[][x] :: sct[x][] 100 | */ 101 | 102 | 103 | 104 | 105 | #define RF_SIZE_1 100 106 | #define RF_SIZE_2 10 107 | 108 | #define CF_SIZE_1 100 109 | #define CF_SIZE_2 10 110 | 111 | #define Y_SIZE 20000 112 | 113 | 114 | 115 | 116 | 117 | 118 | #define YL_SIZE_1 2 119 | #define YL_SIZE_2 2000 120 | 121 | 122 | 123 | 124 | #define YY_SIZE_1 1000 125 | #define YY_SIZE_2 2 126 | #define YY_SIZE_3 2000 127 | 128 | 129 | 130 | #ifdef BAD_BOUNDS 131 | #define SCT_SIZE_1 1000 132 | #define SCT_SIZE_2 1000 133 | #else 134 | #define SCT_SIZE_1 2500 135 | #define SCT_SIZE_2 1000 136 | #endif 137 | 138 | #define CP_SIZE 20000 139 | #define RP_SIZE 20000 140 | 141 | #endif /* !_BZ_ARRAY_H */ 142 | -------------------------------------------------------------------------------- /libfprint/nbis/include/defs.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | #ifndef _DEFS_H 45 | #define _DEFS_H 46 | 47 | /*********************************************************************/ 48 | /* General Purpose Defines */ 49 | /*********************************************************************/ 50 | #ifndef True 51 | #define True 1 52 | #define False 0 53 | #endif 54 | #ifndef TRUE 55 | #define TRUE True 56 | #define FALSE False 57 | #endif 58 | #define Yes True 59 | #define No False 60 | #define Empty NULL 61 | #ifndef None 62 | #define None -1 63 | #endif 64 | #ifndef FOUND 65 | #define FOUND 1 66 | #endif 67 | #define NOT_FOUND_NEG -1 68 | #define EOL EOF 69 | #ifndef DEG2RAD 70 | #define DEG2RAD (double)(57.29578) 71 | #endif 72 | #define max(a, b) ((a) > (b) ? (a) : (b)) 73 | #define min(a, b) ((a) < (b) ? (a) : (b)) 74 | #define sround(x) ((int) (((x)<0) ? (x)-0.5 : (x)+0.5)) 75 | #define sround_uint(x) ((unsigned int) (((x)<0) ? (x)-0.5 : (x)+0.5)) 76 | #define align_to_16(_v_) ((((_v_)+15)>>4)<<4) 77 | #define align_to_32(_v_) ((((_v_)+31)>>5)<<5) 78 | #ifndef CHUNKS 79 | #define CHUNKS 100 80 | #endif 81 | 82 | #endif /* !_DEFS_H */ 83 | -------------------------------------------------------------------------------- /libfprint/nbis/include/log.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | 45 | #ifndef _LOG_H 46 | #define _LOG_H 47 | 48 | /* Definitions and references to support log report files. */ 49 | /* UPDATED: 03/16/2005 by MDG */ 50 | 51 | #include 52 | #include 53 | #include 54 | 55 | #ifdef LOG_REPORT 56 | /* Uncomment the following line to enable logging. */ 57 | #define LOG_FILE "log.txt" 58 | #endif 59 | 60 | 61 | extern int open_logfile(void); 62 | extern int close_logfile(void); 63 | extern void print2log(char *, ...); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /libfprint/nbis/include/meson.build: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/libfprint/nbis/include/meson.build -------------------------------------------------------------------------------- /libfprint/nbis/include/morph.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | 45 | #ifndef __MORPH_H__ 46 | #define __MORPH_H__ 47 | 48 | /* Modified 10/26/1999 by MDG to avoid indisciminate erosion of pixels */ 49 | /* along the edge of the binary image. */ 50 | 51 | extern void erode_charimage_2(unsigned char *, unsigned char *, 52 | const int, const int); 53 | extern void dilate_charimage_2(unsigned char *, unsigned char *, 54 | const int, const int); 55 | extern char get_south8_2(char *, const int, const int, const int, const int); 56 | extern char get_north8_2(char *, const int, const int, const int); 57 | extern char get_east8_2(char *, const int, const int, const int); 58 | extern char get_west8_2(char *, const int, const int); 59 | 60 | #endif /* !__MORPH_H__ */ 61 | -------------------------------------------------------------------------------- /libfprint/nbis/include/mytime.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | 45 | #ifndef _MYTIME_H 46 | #define _MYTIME_H 47 | 48 | /* this file needed to support timer and ticks */ 49 | /* UPDATED: 03/16/2005 by MDG */ 50 | 51 | #ifdef TIMER 52 | #include 53 | #endif 54 | 55 | #ifdef __MSYS__ 56 | #include 57 | #else 58 | #include 59 | #endif 60 | 61 | #ifdef TIMER 62 | #define set_timer(_timer_); \ 63 | { \ 64 | _timer_ = ticks(); 65 | #else 66 | #define set_timer(_timer_); 67 | #endif 68 | 69 | #ifdef TIMER 70 | #define time_accum(_timer_, _var_); \ 71 | _var_ += (ticks() - _timer_)/(float)ticksPerSec(); \ 72 | } 73 | #else 74 | #define time_accum(_timer_, _var_); 75 | #endif 76 | 77 | #ifdef TIMER 78 | #define print_time(_fp_, _fmt_, _var_); \ 79 | fprintf(_fp_, _fmt_, _var_); 80 | #else 81 | #define print_time(_fp_, _fmt_, _var_); 82 | #endif 83 | 84 | extern clock_t ticks(void); 85 | extern int ticksPerSec(void); 86 | 87 | extern clock_t total_timer; 88 | extern float total_time; 89 | 90 | extern clock_t imap_timer; 91 | extern float imap_time; 92 | 93 | extern clock_t bin_timer; 94 | extern float bin_time; 95 | 96 | extern clock_t minutia_timer; 97 | extern float minutia_time; 98 | 99 | extern clock_t rm_minutia_timer; 100 | extern float rm_minutia_time; 101 | 102 | extern clock_t ridge_count_timer; 103 | extern float ridge_count_time; 104 | 105 | #endif 106 | 107 | -------------------------------------------------------------------------------- /libfprint/nbis/include/sunrast.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | 45 | #ifndef _SUNRAST_H 46 | #define _SUNRAST_H 47 | 48 | /************************************************************/ 49 | /* File Name: Sunrast.h */ 50 | /* Package: Sun Rasterfile I/O */ 51 | /* Author: Michael D. Garris */ 52 | /* Date: 8/19/99 */ 53 | /* Updated: 03/16/2005 by MDG */ 54 | /* */ 55 | /************************************************************/ 56 | 57 | /* Contains header information related to Sun Rasterfile images. */ 58 | 59 | typedef struct sunrasterhdr { 60 | int magic; /* magic number */ 61 | int width; /* width (in pixels) of image */ 62 | int height; /* height (in pixels) of image */ 63 | int depth; /* depth (1, 8, or 24 bits) of pixel */ 64 | int raslength; /* length (in bytes) of image */ 65 | int rastype; /* type of file; see SUN_* below */ 66 | int maptype; /* type of colormap; see MAP_* below */ 67 | int maplength; /* length (bytes) of following map */ 68 | /* color map follows for maplength bytes, followed by image */ 69 | } SUNHEAD; 70 | 71 | #define SUN_MAGIC 0x59a66a95 72 | 73 | /* Sun supported ras_type's */ 74 | #define SUN_STANDARD 1 /* Raw pixrect image in 68000 byte order */ 75 | #define SUN_RUN_LENGTH 2 /* Run-length compression of bytes */ 76 | #define SUN_FORMAT_RGB 3 /* XRGB or RGB instead of XBGR or BGR */ 77 | #define SUN_FORMAT_TIFF 4 /* tiff <-> standard rasterfile */ 78 | #define SUN_FORMAT_IFF 5 /* iff (TAAC format) <-> standard rasterfile */ 79 | 80 | /* Sun supported maptype's */ 81 | #define MAP_RAW 2 82 | #define MAP_NONE 0 /* maplength is expected to be 0 */ 83 | #define MAP_EQUAL_RGB 1 /* red[maplength/3],green[],blue[] */ 84 | 85 | /* 86 | * NOTES: 87 | * Each line of a bitmap image should be rounded out to a multiple 88 | * of 16 bits. 89 | */ 90 | 91 | /* sunrast.c */ 92 | extern int ReadSunRaster(const char *, SUNHEAD **, unsigned char **, int *, 93 | unsigned char **, int *, int *, int *, int *); 94 | extern int WriteSunRaster(char *, unsigned char *, const int, const int, 95 | const int); 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /libfprint/nbis/lfs.h.patch: -------------------------------------------------------------------------------- 1 | --- include/lfs.h 2 | +++ include/lfs.h 3 | @@ -66,7 +66,8 @@ of the software. 4 | 5 | #include 6 | #include 7 | -#include /* Needed by to_type9.c */ 8 | +#include 9 | +#include 10 | 11 | /*************************************************************************/ 12 | /* OUTPUT FILE EXTENSIONS */ 13 | @@ -154,26 +155,8 @@ typedef struct rotgrids{ 14 | #define DISAPPEARING 0 15 | #define APPEARING 1 16 | 17 | -typedef struct minutia{ 18 | - int x; 19 | - int y; 20 | - int ex; 21 | - int ey; 22 | - int direction; 23 | - double reliability; 24 | - int type; 25 | - int appearing; 26 | - int feature_id; 27 | - int *nbrs; 28 | - int *ridge_counts; 29 | - int num_nbrs; 30 | -} MINUTIA; 31 | - 32 | -typedef struct minutiae{ 33 | - int alloc; 34 | - int num; 35 | - MINUTIA **list; 36 | -} MINUTIAE; 37 | +typedef struct fp_minutia MINUTIA; 38 | +typedef struct fp_minutiae MINUTIAE; 39 | 40 | typedef struct feature_pattern{ 41 | int type; 42 | @@ -1203,17 +1186,6 @@ extern void bubble_sort_double_inc_2(double *, int *, const int); 43 | extern void bubble_sort_double_dec_2(double *, int *, const int); 44 | extern void bubble_sort_int_inc(int *, const int); 45 | 46 | -/* to_type9.c */ 47 | -extern int minutiae2type_9(RECORD **, const int, MINUTIAE *, const int, 48 | - const int, const double); 49 | -extern int mintiae2field_12(FIELD **, MINUTIAE *, const int, const int, 50 | - const double); 51 | - 52 | -/* update.c */ 53 | -extern int update_ANSI_NIST_lfs_results(ANSI_NIST *, MINUTIAE *, 54 | - unsigned char *, const int, const int, 55 | - const int, const double, const int, const int); 56 | - 57 | /* util.c */ 58 | extern int maxv(const int *, const int); 59 | extern int minv(const int *, const int); 60 | -------------------------------------------------------------------------------- /libfprint/nbis/libfprint-include/meson.build: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/libfprint/nbis/libfprint-include/meson.build -------------------------------------------------------------------------------- /libfprint/nbis/libfprint-include/nbis-helpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Helpers to use within the NBIS copy/paste library 3 | * Copyright (C) 2018 Bastien Nocera 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | 22 | #define ASSERT_SIZE_MUL(a,b) \ 23 | { \ 24 | gsize dest; \ 25 | g_assert(g_size_checked_mul(&dest, a, b)); \ 26 | } 27 | 28 | #define ASSERT_INT_MUL(a, b) \ 29 | { \ 30 | gsize dest; \ 31 | g_assert(g_size_checked_mul(&dest, a, b)); \ 32 | g_assert(dest < G_MAXINT); \ 33 | } 34 | -------------------------------------------------------------------------------- /libfprint/nbis/libfprint-include/nbis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Example fingerprint device prints listing and deletion 3 | * Enrolls your right index finger and saves the print to disk 4 | * Copyright (C) 2019 Marco Trevisan 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #pragma GCC diagnostic push 24 | #pragma GCC diagnostic ignored "-Wredundant-decls" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #pragma GCC diagnostic pop 36 | -------------------------------------------------------------------------------- /libfprint/nbis/mindtct/log.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | 45 | /*********************************************************************** 46 | LIBRARY: LFS - NIST Latent Fingerprint System 47 | 48 | FILE: LOG.C 49 | AUTHOR: Michael D. Garris 50 | DATE: 08/02/1999 51 | 52 | Contains routines responsible for dynamically updating a log file 53 | during the execution of the NIST Latent Fingerprint System (LFS). 54 | 55 | *********************************************************************** 56 | ROUTINES: 57 | open_logfile() 58 | print2log() 59 | close_logfile() 60 | ***********************************************************************/ 61 | 62 | #include 63 | 64 | /* If logging is on, declare global file pointer and supporting */ 65 | /* global variable for logging intermediate results. */ 66 | 67 | /***************************************************************************/ 68 | /***************************************************************************/ 69 | int open_logfile(void) 70 | { 71 | #ifdef LOG_REPORT 72 | fprintf(stderr, "ERROR : open_logfile : fopen : %s\n", LOG_FILE); 73 | return(-1); 74 | } 75 | #endif 76 | 77 | return(0); 78 | } 79 | 80 | /***************************************************************************/ 81 | /***************************************************************************/ 82 | void print2log(char *fmt, ...) 83 | { 84 | #ifdef LOG_REPORT 85 | va_list ap; 86 | 87 | va_start(ap, fmt); 88 | va_end(ap); 89 | #endif 90 | } 91 | 92 | /***************************************************************************/ 93 | /***************************************************************************/ 94 | int close_logfile(void) 95 | { 96 | #ifdef LOG_REPORT 97 | fprintf(stderr, "ERROR : close_logfile : fclose : %s\n", LOG_FILE); 98 | return(-1); 99 | } 100 | #endif 101 | 102 | return(0); 103 | } 104 | 105 | -------------------------------------------------------------------------------- /libfprint/nbis/remove-function.lua: -------------------------------------------------------------------------------- 1 | #!/bin/lua 2 | 3 | function read_all(file) 4 | local f = io.open(file, "r") 5 | if not f then return nil end 6 | local t = f:read("*all") 7 | f:close() 8 | return t 9 | end 10 | 11 | function write_all(file, content) 12 | local f = io.open(file, "w") 13 | f:write(content) 14 | f:close() 15 | end 16 | 17 | -- From http://lua-users.org/wiki/SplitJoin 18 | function split_lines(str) 19 | local t = {} 20 | local function helper(line) 21 | table.insert(t, line) 22 | return "" 23 | end 24 | helper((str:gsub("(.-)\r?\n", helper))) 25 | return t 26 | end 27 | 28 | function remove_func_content(func, content) 29 | local lines = split_lines(content) 30 | local res = {} 31 | local in_func = false 32 | local num_braces = 0 33 | local found_func = false 34 | for k, v in ipairs(lines) do 35 | if in_func == true then 36 | local orig_braces = num_braces 37 | local _, count = string.gsub(v, "{", "") 38 | num_braces = num_braces + count 39 | _, count = string.gsub(v, "}", "") 40 | num_braces = num_braces - count 41 | if orig_braces ~= 0 and num_braces == 0 then 42 | print (func .. ' finished line '.. k) 43 | in_func = false 44 | end 45 | elseif (v:match(' '..func..'%(%a+') or 46 | v:match(' '..func..' %(%a+') or 47 | v:match(' '..func..'%( %a+') or 48 | v:match(' '..func..'%($')) and 49 | not v:match('= '..func..'%(%a+') then 50 | print (func .. ' started line ' .. k) 51 | found_func = true 52 | in_func = true 53 | else 54 | table.insert(res, v) 55 | end 56 | end 57 | 58 | if not found_func then 59 | return nil 60 | end 61 | return table.concat(res, '\n') 62 | end 63 | 64 | function remove_func_file(func, file) 65 | content = read_all(file) 66 | content = remove_func_content(func, content) 67 | if not content then 68 | error('Could not find function '..func..'() in '..file) 69 | else 70 | write_all(file, content) 71 | end 72 | end 73 | 74 | local func 75 | for k, v in ipairs(arg) do 76 | if k == 1 then 77 | func = v 78 | else 79 | remove_func_file(func, v) 80 | end 81 | end 82 | 83 | -------------------------------------------------------------------------------- /libfprint/nbis/remove-global-y.cocci: -------------------------------------------------------------------------------- 1 | @ global_y @ 2 | identifier y; 3 | @@ 4 | int 5 | - y 6 | + bz_y 7 | [20000]; 8 | 9 | @@ 10 | identifier global_y.y; 11 | @@ 12 | - y 13 | + bz_y 14 | [...] 15 | 16 | @@ 17 | @@ 18 | int 19 | - y 20 | + bz_y 21 | [20000] = {}; 22 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('drivers', 2 | description: 'Drivers to integrate, "default" selects the default set, "all" selects all drivers', 3 | type: 'string', 4 | value: 'default') 5 | option('introspection', 6 | description: 'Build GObject Introspection repository', 7 | type: 'boolean', 8 | value: true) 9 | option('udev_rules', 10 | description: 'Whether to create a udev rules file', 11 | type: 'boolean', 12 | value: true) 13 | option('udev_rules_dir', 14 | description: 'Installation path for udev rules', 15 | type: 'string', 16 | value: 'auto') 17 | option('gtk-examples', 18 | description: 'Whether to build GTK+ example applications', 19 | type: 'boolean', 20 | value: false) 21 | option('doc', 22 | description: 'Whether to build the API documentation', 23 | type: 'boolean', 24 | value: true) 25 | -------------------------------------------------------------------------------- /scripts/uncrustify.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | SRCROOT=`git rev-parse --show-toplevel` 3 | CFG="$SRCROOT/scripts/uncrustify.cfg" 4 | echo "srcroot: $SRCROOT" 5 | 6 | case "$1" in 7 | -c|--check) 8 | OPTS="--check" 9 | ;; 10 | *) 11 | OPTS="--replace --no-backup" 12 | ;; 13 | esac 14 | 15 | pushd "$SRCROOT" 16 | uncrustify -c "$CFG" $OPTS `git ls-tree --name-only -r HEAD | grep -E '.*\.[ch]$' | grep -v nbis | grep -v fpi-byte | grep -v build/` 17 | RES=$? 18 | popd 19 | exit $RES -------------------------------------------------------------------------------- /tests/README-umockdev: -------------------------------------------------------------------------------- 1 | To create a new umockdev test, you should: 2 | 3 | 1. Decide on what to test, the easiest case is just using the existing 4 | capture test case. 5 | 2. Find the USB device you are testing with lsusb, e.g.: 6 | Bus 001 Device 005: ID 138a:0090 Validity Sensors, Inc. VFS7500 Touch Fingerprint Sensor 7 | This means we need to record USB device /dev/bus/usb/001/005 8 | 3. Run "umockdev-record /dev/bus/usb/001/005 >device" 9 | This records the information about device, it should be placed into test/DRIVER/device 10 | 4. Run the test, for a capture test this would be: 11 | umockdev-record -i /dev/bus/usb/001/005=capture.ioctl -- ./capture.py capture.png 12 | This will create a capture.ioctl and capture.png file. 13 | Please set the FP_DEVICE_EMULATION=1 environment variable. You may need 14 | to adjust the driver to adapt to the emulated environment (mainly if it 15 | uses random numbers, see synaptics.c for an example). 16 | 5. Place all files into the driver subdirectory test/DRIVER, 17 | i.e. device, capture.ioctl, capture.png 18 | 6. Add glue to meson.build 19 | 7. Test whether everything works as expected 20 | 21 | Please note, there is no need to use a real finger print in this case. If 22 | you would like to avoid submitting your own fingerprint then please just 23 | use e.g. the side of your finger, arm, or anything else that will produce 24 | an image with the device. 25 | 26 | 27 | Note that umockdev-record groups URBs aggressively. In most cases, manual 28 | intervention is unfortunately required. In most cases, drivers do a chain 29 | of commands like e.g. A then B each with a different reply. Umockdev will 30 | create a file like: 31 | 32 | A 33 | reply 1 34 | reply 2 35 | B 36 | reply 1 37 | reply 2 38 | 39 | which then needs to be re-ordered to be: 40 | 41 | A 42 | reply 1 43 | B 44 | reply 1 45 | A 46 | reply 2 47 | B 48 | reply 2 49 | 50 | Other changes may be needed to get everything working. For example the elan 51 | driver relies on a timeout that is not reported correctly. In this case the 52 | driver works around it by interpreting the protocol error differently in 53 | the virtual environment. -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | `umockdev` Tests 2 | ================ 3 | `umockdev` tests use fingerprint devices mocked by [`umockdev` 4 | toolchain][umockdev]. 5 | 6 | This document describes how to create a 'capture' test: a test that 7 | captures a picture of a fingerprint from the device (mocked by 8 | `umockdev`) and compares it with the standard one. 9 | 10 | Other kinds of `umockdev` tests could be created in a similar manner. 11 | 12 | 13 | 'Capture' Test Creation 14 | ----------------------- 15 | A new 'capture' test is created by means of `capture.py` script: 16 | 17 | 1. Create (if needed) a directory for the driver under `tests` 18 | directory: 19 | 20 | `mkdir DRIVER` 21 | 22 | 2. Prepare your execution environment. 23 | 24 | In the next step a working and up to date libfprint is needed. This can be 25 | achieved by installing it into your system. Alternatively, you can set 26 | the following environment variables to run a local build: 27 | - `export LD_PRELOAD=/libfprint/libfprint-2.so` 28 | - `export GI_TYPELIB_PATH=/libfprint` 29 | 30 | Also, sometimes the driver must be adopted to the emulated environment 31 | (mainly if it uses random numbers, see `synaptics.c` for an example). 32 | Set the following environment variable to enable this adaptation: 33 | - `export FP_DEVICE_EMULATION=1` 34 | 35 | Run the next steps in the same terminal. 36 | 37 | 3. Find the real USB fingerprint device with `lsusb`, e.g.: 38 | 39 | `Bus 001 Device 005: ID 138a:0090 Validity Sensors, Inc. VFS7500 Touch Fingerprint Sensor` 40 | 41 | The following USB device is used in the example above: 42 | `/dev/bus/usb/001/005`. 43 | 44 | 4. Record information about this device: 45 | 46 | `umockdev-record /dev/bus/usb/001/005 > DRIVER/device` 47 | 48 | 5. Record interaction of `capture.py` (or other test) with the device: 49 | 50 | `umockdev-record -i /dev/bus/usb/001/005=DRIVER/capture.ioctl -- python3 ./capture.py DRIVER/capture.png` 51 | 52 | Files `capture.ioctl` and `capture.png` will be created as the 53 | result of this command. 54 | 55 | 6. Add driver's name to `drivers_tests` in the `meson.build`. 56 | 7. Check whether everything works as expected. 57 | 58 | **Note.** To avoid submitting a real fingerprint, the side of finger, 59 | arm, or anything else producing an image with the device can be used. 60 | 61 | 62 | Possible Issues 63 | --------------- 64 | `umockdev-record` aggressively groups URBs. In most cases, manual 65 | intervention is unfortunately required. Often, drivers do a chain of 66 | commands like: A then B each with a different reply. However, 67 | `umockdev-record` could create a file like this: 68 | 69 | A 70 | reply 1 71 | reply 2 72 | B 73 | reply 1 74 | reply 2 75 | 76 | In that case, records must be re-ordered: 77 | 78 | A 79 | reply 1 80 | B 81 | reply 1 82 | A 83 | reply 2 84 | B 85 | reply 2 86 | 87 | Other changes may be needed to get everything working. For example the 88 | `elan` driver relies on a timeout that is not reported correctly. In 89 | this case the driver works around it by interpreting the protocol 90 | error differently in the virtual environment (by means of 91 | `FP_DEVICE_EMULATION` environment variable). 92 | 93 | 94 | [umockdev]: https://github.com/martinpitt/umockdev 95 | -------------------------------------------------------------------------------- /tests/capture.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import gi 4 | gi.require_version('FPrint', '2.0') 5 | from gi.repository import FPrint, GLib 6 | import cairo 7 | import sys 8 | 9 | if len(sys.argv) != 2: 10 | print("Please specify exactly one argument, the output location for the capture image") 11 | sys.exit(1) 12 | 13 | ctx = GLib.main_context_default() 14 | 15 | c = FPrint.Context() 16 | c.enumerate() 17 | devices = c.get_devices() 18 | 19 | d = devices[0] 20 | del devices 21 | 22 | d.open_sync() 23 | 24 | img = d.capture_sync(True) 25 | 26 | d.close_sync() 27 | 28 | del d 29 | del c 30 | 31 | width = img.get_width() 32 | height = img.get_height() 33 | 34 | c_img = cairo.ImageSurface(cairo.FORMAT_RGB24, width, height) 35 | 36 | c_rowstride = c_img.get_stride() 37 | 38 | buf = img.get_data() 39 | c_buf = c_img.get_data() 40 | 41 | for x in range(width): 42 | for y in range(height): 43 | # The upper byte is don't care, but the location depends on endianness, 44 | # so just set all of them. 45 | c_buf[y * c_rowstride + x * 4 + 0] = buf[y * width + x] 46 | c_buf[y * c_rowstride + x * 4 + 1] = buf[y * width + x] 47 | c_buf[y * c_rowstride + x * 4 + 2] = buf[y * width + x] 48 | c_buf[y * c_rowstride + x * 4 + 3] = buf[y * width + x] 49 | 50 | c_img.mark_dirty() 51 | c_img.write_to_png(sys.argv[1]) 52 | 53 | -------------------------------------------------------------------------------- /tests/elan/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/tests/elan/capture.png -------------------------------------------------------------------------------- /tests/synaptics/custom.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import gi 4 | gi.require_version('FPrint', '2.0') 5 | from gi.repository import FPrint, GLib 6 | 7 | ctx = GLib.main_context_default() 8 | 9 | c = FPrint.Context() 10 | c.enumerate() 11 | devices = c.get_devices() 12 | 13 | d = devices[0] 14 | del devices 15 | 16 | assert d.get_driver() == "synaptics" 17 | 18 | d.open_sync() 19 | 20 | template = FPrint.Print.new(d) 21 | 22 | def enroll_progress(*args): 23 | print('enroll progress: ' + str(args)) 24 | 25 | # List, enroll, list, verify, delete, list 26 | print("enrolling") 27 | p = d.enroll_sync(template, None, enroll_progress, None) 28 | print("enroll done") 29 | 30 | print("listing") 31 | stored = d.list_prints_sync() 32 | print("listing done") 33 | assert len(stored) == 1 34 | assert stored[0].equal(p) 35 | print("verifying") 36 | verify_res, verify_print = d.verify_sync(p) 37 | print("verify done") 38 | assert verify_res == True 39 | 40 | print("deleting") 41 | d.delete_print_sync(p) 42 | print("delete done") 43 | d.close_sync() 44 | 45 | del d 46 | del c 47 | -------------------------------------------------------------------------------- /tests/synaptics/device: -------------------------------------------------------------------------------- 1 | P: /devices/pci0000:00/0000:00:14.0/usb1/1-1 2 | N: bus/usb/001/070=12010002FF10FF08CB06BD0000000000010109022700010100A0320904000003FF000000070501024000000705810240000007058303080004 3 | E: DEVNAME=/dev/bus/usb/001/070 4 | E: DEVTYPE=usb_device 5 | E: DRIVER=usb 6 | E: PRODUCT=6cb/bd/0 7 | E: TYPE=255/16/255 8 | E: BUSNUM=001 9 | E: DEVNUM=070 10 | E: MAJOR=189 11 | E: MINOR=69 12 | E: SUBSYSTEM=usb 13 | E: ID_VENDOR=06cb 14 | E: ID_VENDOR_ENC=06cb 15 | E: ID_VENDOR_ID=06cb 16 | E: ID_MODEL=00bd 17 | E: ID_MODEL_ENC=00bd 18 | E: ID_MODEL_ID=00bd 19 | E: ID_REVISION=0000 20 | E: ID_SERIAL=06cb_00bd_317bb11d90a4 21 | E: ID_SERIAL_SHORT=317bb11d90a4 22 | E: ID_BUS=usb 23 | E: ID_USB_INTERFACES=:ff0000: 24 | E: ID_VENDOR_FROM_DATABASE=Synaptics, Inc. 25 | A: authorized=1 26 | A: avoid_reset_quirk=0 27 | A: bConfigurationValue=1 28 | A: bDeviceClass=ff 29 | A: bDeviceProtocol=ff 30 | A: bDeviceSubClass=10 31 | A: bMaxPacketSize0=8 32 | A: bMaxPower=100mA 33 | A: bNumConfigurations=1 34 | A: bNumInterfaces= 1 35 | A: bcdDevice=0000 36 | A: bmAttributes=a0 37 | A: busnum=1 38 | A: configuration= 39 | H: descriptors=12010002FF10FF08CB06BD0000000000010109022700010100A0320904000003FF000000070501024000000705810240000007058303080004 40 | A: dev=189:69 41 | A: devnum=70 42 | A: devpath=1 43 | L: driver=../../../../../bus/usb/drivers/usb 44 | A: idProduct=00bd 45 | A: idVendor=06cb 46 | A: ltm_capable=no 47 | A: maxchild=0 48 | L: port=../1-0:1.0/usb1-port1 49 | A: power/active_duration=33942 50 | A: power/autosuspend=2 51 | A: power/autosuspend_delay_ms=2000 52 | A: power/connected_duration=33942 53 | A: power/control=on 54 | A: power/level=on 55 | A: power/persist=1 56 | A: power/runtime_active_time=33702 57 | A: power/runtime_status=active 58 | A: power/runtime_suspended_time=0 59 | A: power/wakeup=disabled 60 | A: power/wakeup_abort_count= 61 | A: power/wakeup_active= 62 | A: power/wakeup_active_count= 63 | A: power/wakeup_count= 64 | A: power/wakeup_expire_count= 65 | A: power/wakeup_last_time_ms= 66 | A: power/wakeup_max_time_ms= 67 | A: power/wakeup_total_time_ms= 68 | A: quirks=0x0 69 | A: removable=removable 70 | A: rx_lanes=1 71 | A: serial=317bb11d90a4 72 | A: speed=12 73 | A: tx_lanes=1 74 | A: urbnum=12 75 | A: version= 2.00 76 | -------------------------------------------------------------------------------- /tests/test-device-fake.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Virtual driver for device debugging 3 | * 4 | * Copyright (C) 2019 Marco Trevisan 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "fpi-device.h" 24 | 25 | #define FPI_TYPE_DEVICE_FAKE (fpi_device_fake_get_type ()) 26 | G_DECLARE_FINAL_TYPE (FpiDeviceFake, fpi_device_fake, FPI, DEVICE_FAKE, FpDevice) 27 | 28 | struct _FpiDeviceFake 29 | { 30 | FpDevice parent; 31 | 32 | gpointer last_called_function; 33 | gboolean return_action_error; 34 | 35 | GError *ret_error; 36 | FpPrint *ret_print; 37 | FpPrint *ret_match; 38 | FpiMatchResult ret_result; 39 | FpImage *ret_image; 40 | GPtrArray *ret_list; 41 | 42 | gpointer action_data; 43 | gpointer user_data; 44 | }; 45 | -------------------------------------------------------------------------------- /tests/test-fp-context.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FpContext Unit tests 3 | * Copyright (C) 2019 Marco Trevisan 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | 22 | #include "test-utils.h" 23 | 24 | static void 25 | test_context_new (void) 26 | { 27 | g_autoptr(FpContext) context = fp_context_new (); 28 | g_assert_true (FP_CONTEXT (context)); 29 | } 30 | 31 | static void 32 | test_context_has_no_devices (void) 33 | { 34 | g_autoptr(FpContext) context = NULL; 35 | GPtrArray *devices; 36 | 37 | context = fp_context_new (); 38 | devices = fp_context_get_devices (context); 39 | 40 | g_assert_nonnull (devices); 41 | g_assert_cmpuint (devices->len, ==, 0); 42 | } 43 | 44 | static void 45 | test_context_has_virtual_device (void) 46 | { 47 | g_autoptr(FpContext) context = NULL; 48 | FpDevice *virtual_device = NULL; 49 | GPtrArray *devices; 50 | unsigned int i; 51 | 52 | fpt_setup_virtual_device_environment (); 53 | 54 | context = fp_context_new (); 55 | devices = fp_context_get_devices (context); 56 | 57 | g_assert_nonnull (devices); 58 | g_assert_cmpuint (devices->len, ==, 1); 59 | 60 | for (i = 0; i < devices->len; ++i) 61 | { 62 | FpDevice *device = devices->pdata[i]; 63 | 64 | if (g_strcmp0 (fp_device_get_driver (device), "virtual_image") == 0) 65 | { 66 | virtual_device = device; 67 | break; 68 | } 69 | } 70 | 71 | g_assert_true (FP_IS_DEVICE (virtual_device)); 72 | 73 | fpt_teardown_virtual_device_environment (); 74 | } 75 | 76 | static void 77 | test_context_enumerates_new_devices (void) 78 | { 79 | g_autoptr(FpContext) context = NULL; 80 | GPtrArray *devices; 81 | 82 | context = fp_context_new (); 83 | 84 | fpt_setup_virtual_device_environment (); 85 | 86 | fp_context_enumerate (context); 87 | devices = fp_context_get_devices (context); 88 | 89 | g_assert_nonnull (devices); 90 | g_assert_cmpuint (devices->len, ==, 1); 91 | 92 | fpt_teardown_virtual_device_environment (); 93 | } 94 | 95 | int 96 | main (int argc, char *argv[]) 97 | { 98 | g_test_init (&argc, &argv, NULL); 99 | 100 | g_test_add_func ("/context/new", test_context_new); 101 | g_test_add_func ("/context/no-devices", test_context_has_no_devices); 102 | g_test_add_func ("/context/has-virtual-device", test_context_has_virtual_device); 103 | g_test_add_func ("/context/enumerates-new-devices", test_context_enumerates_new_devices); 104 | 105 | return g_test_run (); 106 | } 107 | -------------------------------------------------------------------------------- /tests/test-fpi-assembling.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Example fingerprint device prints listing and deletion 3 | * Enrolls your right index finger and saves the print to disk 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include "fpi-assembling.h" 24 | #include "fpi-image.h" 25 | #include "test-config.h" 26 | 27 | typedef struct 28 | { 29 | struct fpi_frame frame; 30 | cairo_surface_t *surf; 31 | guchar *data; 32 | guint stride; 33 | guint width; 34 | guint height; 35 | guint x; 36 | guint y; 37 | } cairo_frame; 38 | 39 | static unsigned char 40 | cairo_get_pixel (struct fpi_frame_asmbl_ctx *ctx, 41 | struct fpi_frame *frame, 42 | unsigned int x, 43 | unsigned int y) 44 | { 45 | cairo_frame *c_frame = (void *) frame; /* Indirect cast to avoid alignment warning. */ 46 | 47 | x = x + c_frame->x; 48 | y = y + c_frame->y; 49 | 50 | g_assert (x < c_frame->width); 51 | g_assert (y < c_frame->height); 52 | 53 | return c_frame->data[x * 4 + y * c_frame->stride + 1]; 54 | } 55 | 56 | static void 57 | test_frame_assembling (void) 58 | { 59 | g_autofree char *path = NULL; 60 | cairo_surface_t *img = NULL; 61 | int width, height, stride, offset; 62 | int test_height; 63 | guchar *data; 64 | struct fpi_frame_asmbl_ctx ctx = { 0, }; 65 | 66 | g_autoptr(FpImage) fp_img = NULL; 67 | GSList *frames = NULL; 68 | 69 | g_assert_false (SOURCE_ROOT == NULL); 70 | path = g_build_path (G_DIR_SEPARATOR_S, SOURCE_ROOT, "tests", "vfs5011", "capture.png", NULL); 71 | 72 | img = cairo_image_surface_create_from_png (path); 73 | data = cairo_image_surface_get_data (img); 74 | width = cairo_image_surface_get_width (img); 75 | height = cairo_image_surface_get_height (img); 76 | stride = cairo_image_surface_get_stride (img); 77 | g_assert_cmpint (cairo_image_surface_get_format (img), ==, CAIRO_FORMAT_RGB24); 78 | 79 | ctx.get_pixel = cairo_get_pixel; 80 | ctx.frame_width = width; 81 | ctx.frame_height = 20; 82 | ctx.image_width = width; 83 | 84 | g_assert (height > ctx.frame_height); 85 | 86 | offset = 10; 87 | test_height = height - (height - ctx.frame_height) % offset; 88 | 89 | /* for now, fixed offset */ 90 | for (int y = 0; y + ctx.frame_height < height; y += offset) 91 | { 92 | cairo_frame *frame = g_new0 (cairo_frame, 1); 93 | 94 | frame->surf = img; 95 | frame->width = width; 96 | frame->height = height; 97 | frame->stride = stride; 98 | frame->data = data; 99 | frame->x = 0; 100 | frame->y = y; 101 | //frame->y = test_height - ctx.frame_height - y; 102 | 103 | frames = g_slist_append (frames, frame); 104 | } 105 | //offset = -offset; 106 | 107 | fpi_do_movement_estimation (&ctx, frames); 108 | for (GSList *l = frames->next; l != NULL; l = l->next) 109 | { 110 | cairo_frame * frame = l->data; 111 | 112 | g_assert_cmpint (frame->frame.delta_x, ==, 0); 113 | g_assert_cmpint (frame->frame.delta_y, ==, offset); 114 | } 115 | 116 | fp_img = fpi_assemble_frames (&ctx, frames); 117 | g_assert_cmpint (fp_img->height, ==, test_height); 118 | 119 | /* The FpImage and cairo surface need to be identical in the test area */ 120 | for (int y = 0; y < test_height; y++) 121 | for (int x = 0; x < width; x++) 122 | g_assert_cmpint (data[x * 4 + y * stride + 1], ==, fp_img->data[x + y * width]); 123 | 124 | g_slist_free_full (frames, g_free); 125 | cairo_surface_destroy (img); 126 | g_assert (1); 127 | } 128 | 129 | int 130 | main (int argc, char *argv[]) 131 | { 132 | g_test_init (&argc, &argv, NULL); 133 | 134 | g_test_add_func ("/assembling/frames", test_frame_assembling); 135 | 136 | return g_test_run (); 137 | } 138 | -------------------------------------------------------------------------------- /tests/test-runner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exec $LIBFPRINT_TEST_WRAPPER $@ 4 | -------------------------------------------------------------------------------- /tests/test-utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Unit tests for libfprint 3 | * Copyright (C) 2019 Marco Trevisan 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "test-utils.h" 24 | 25 | void 26 | fpt_teardown_virtual_device_environment (void) 27 | { 28 | const char *path = g_getenv ("FP_VIRTUAL_IMAGE"); 29 | 30 | if (path) 31 | { 32 | g_autofree char *temp_dir = g_path_get_dirname (path); 33 | 34 | g_unsetenv ("FP_VIRTUAL_IMAGE"); 35 | g_unlink (path); 36 | g_rmdir (temp_dir); 37 | } 38 | } 39 | 40 | static void 41 | on_signal_event (int sig) 42 | { 43 | fpt_teardown_virtual_device_environment (); 44 | } 45 | 46 | void 47 | fpt_setup_virtual_device_environment (void) 48 | { 49 | g_autoptr(GError) error = NULL; 50 | g_autofree char *temp_dir = NULL; 51 | g_autofree char *temp_path = NULL; 52 | 53 | g_assert_null (g_getenv ("FP_VIRTUAL_IMAGE")); 54 | 55 | temp_dir = g_dir_make_tmp ("libfprint-XXXXXX", &error); 56 | g_assert_no_error (error); 57 | 58 | temp_path = g_build_filename (temp_dir, "virtual-image.socket", NULL); 59 | g_setenv ("FP_VIRTUAL_IMAGE", temp_path, TRUE); 60 | 61 | signal (SIGKILL, on_signal_event); 62 | signal (SIGABRT, on_signal_event); 63 | signal (SIGSEGV, on_signal_event); 64 | signal (SIGTERM, on_signal_event); 65 | signal (SIGQUIT, on_signal_event); 66 | signal (SIGPIPE, on_signal_event); 67 | } 68 | 69 | FptContext * 70 | fpt_context_new (void) 71 | { 72 | FptContext *tctx; 73 | 74 | tctx = g_new0 (FptContext, 1); 75 | tctx->fp_context = fp_context_new (); 76 | 77 | return tctx; 78 | } 79 | 80 | FptContext * 81 | fpt_context_new_with_virtual_imgdev (void) 82 | { 83 | FptContext *tctx; 84 | GPtrArray *devices; 85 | unsigned int i; 86 | 87 | fpt_setup_virtual_device_environment (); 88 | 89 | tctx = fpt_context_new (); 90 | devices = fp_context_get_devices (tctx->fp_context); 91 | 92 | g_assert_nonnull (devices); 93 | g_assert_cmpuint (devices->len, ==, 1); 94 | 95 | for (i = 0; i < devices->len; ++i) 96 | { 97 | FpDevice *device = devices->pdata[i]; 98 | 99 | if (g_strcmp0 (fp_device_get_driver (device), "virtual_image") == 0) 100 | { 101 | tctx->device = device; 102 | break; 103 | } 104 | } 105 | 106 | g_assert_true (FP_IS_DEVICE (tctx->device)); 107 | g_object_add_weak_pointer (G_OBJECT (tctx->device), (gpointer) & tctx->device); 108 | 109 | return tctx; 110 | } 111 | 112 | void 113 | fpt_context_free (FptContext *tctx) 114 | { 115 | if (tctx->device && fp_device_is_open (tctx->device)) 116 | { 117 | g_autoptr(GError) error = NULL; 118 | 119 | fp_device_close_sync (tctx->device, NULL, &error); 120 | g_assert_no_error (error); 121 | } 122 | 123 | g_clear_object (&tctx->fp_context); 124 | g_free (tctx); 125 | 126 | fpt_teardown_virtual_device_environment (); 127 | } 128 | -------------------------------------------------------------------------------- /tests/test-utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Unit tests for libfprint 3 | * Copyright (C) 2019 Marco Trevisan 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | 22 | void fpt_setup_virtual_device_environment (void); 23 | void fpt_teardown_virtual_device_environment (void); 24 | 25 | typedef struct _FptContext 26 | { 27 | FpContext *fp_context; 28 | FpDevice *device; 29 | gpointer user_data; 30 | } FptContext; 31 | 32 | FptContext * fpt_context_new (void); 33 | FptContext * fpt_context_new_with_virtual_imgdev (void); 34 | 35 | void fpt_context_free (FptContext *test_context); 36 | 37 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (FptContext, fpt_context_free) 38 | -------------------------------------------------------------------------------- /tests/umockdev-test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import os 5 | import os.path 6 | import shutil 7 | import tempfile 8 | import subprocess 9 | 10 | if len(sys.argv) != 2: 11 | print("You need to specify exactly one argument, the directory with test data") 12 | 13 | # Check that umockdev is available 14 | try: 15 | umockdev_version = subprocess.check_output(['umockdev-run', '--version']) 16 | version = tuple(int(_) for _ in umockdev_version.split(b'.')) 17 | if version < (0, 13, 2): 18 | print('umockdev is too old for test to be reliable, expect random failures!') 19 | print('Please update umockdev to at least 0.13.2.') 20 | except FileNotFoundError: 21 | print('umockdev-run not found, skipping test!') 22 | print('Please install umockdev.') 23 | sys.exit(77) 24 | 25 | edir = os.path.dirname(sys.argv[0]) 26 | ddir = sys.argv[1] 27 | 28 | tmpdir = tempfile.mkdtemp(prefix='libfprint-umockdev-test-') 29 | 30 | assert os.path.isdir(ddir) 31 | assert os.path.isfile(os.path.join(ddir, "device")) 32 | 33 | def cmp_pngs(png_a, png_b): 34 | print("Comparing PNGs %s and %s" % (png_a, png_b)) 35 | import cairo 36 | img_a = cairo.ImageSurface.create_from_png(png_a) 37 | img_b = cairo.ImageSurface.create_from_png(png_b) 38 | 39 | assert img_a.get_format() == cairo.FORMAT_RGB24 40 | assert img_b.get_format() == cairo.FORMAT_RGB24 41 | assert img_a.get_width() == img_b.get_width() 42 | assert img_a.get_height() == img_b.get_height() 43 | assert img_a.get_stride () == img_b.get_stride() 44 | 45 | data_a = img_a.get_data() 46 | data_b = img_b.get_data() 47 | stride = img_a.get_stride() 48 | 49 | for x in range(img_a.get_width()): 50 | for y in range(img_a.get_height()): 51 | # RGB24 format is endian dependent, using +1 means we test either 52 | # the G or B component, which works on any endian for the greyscale 53 | # test. 54 | assert(data_a[y * stride + x * 4 + 1] == data_b[y * stride + x * 4 + 1]) 55 | 56 | def get_umockdev_runner(ioctl_basename): 57 | ioctl = os.path.join(ddir, "{}.ioctl".format(ioctl_basename)) 58 | device = os.path.join(ddir, "device") 59 | dev = open(ioctl).readline().strip() 60 | assert dev.startswith('@DEV ') 61 | dev = dev[5:] 62 | 63 | umockdev = ['umockdev-run', '-d', device, 64 | '-i', "%s=%s" % (dev, ioctl), 65 | '--'] 66 | wrapper = os.getenv('LIBFPRINT_TEST_WRAPPER') 67 | return umockdev + (wrapper.split(' ') if wrapper else []) + [sys.executable] 68 | 69 | def capture(): 70 | subprocess.check_call(get_umockdev_runner("capture") + 71 | ['%s' % os.path.join(edir, "capture.py"), 72 | '%s' % os.path.join(tmpdir, "capture.png")]) 73 | 74 | assert os.path.isfile(os.path.join(tmpdir, "capture.png")) 75 | if os.path.isfile(os.path.join(ddir, "capture.png")): 76 | # Compare the images, they need to be identical 77 | cmp_pngs(os.path.join(tmpdir, "capture.png"), os.path.join(ddir, "capture.png")) 78 | 79 | def custom(): 80 | subprocess.check_call(get_umockdev_runner("custom") + 81 | ['%s' % os.path.join(ddir, "custom.py")]) 82 | 83 | try: 84 | if os.path.exists(os.path.join(ddir, "capture.ioctl")): 85 | capture() 86 | 87 | if os.path.exists(os.path.join(ddir, "custom.ioctl")): 88 | custom() 89 | 90 | finally: 91 | shutil.rmtree(tmpdir) 92 | 93 | -------------------------------------------------------------------------------- /tests/unittest_inspector.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # Copyright © 2020, Canonical Ltd 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU Lesser General Public 6 | # License as published by the Free Software Foundation; either 7 | # version 2.1 of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # Lesser General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Lesser General Public 15 | # License along with this library. If not, see . 16 | # Authors: 17 | # Marco Trevisan 18 | 19 | import argparse 20 | import importlib.util 21 | import inspect 22 | import os 23 | import unittest 24 | 25 | def list_tests(module): 26 | tests = [] 27 | for name, obj in inspect.getmembers(module): 28 | if inspect.isclass(obj) and issubclass(obj, unittest.TestCase): 29 | cases = unittest.defaultTestLoader.getTestCaseNames(obj) 30 | tests += [ (obj, '{}.{}'.format(name, t)) for t in cases ] 31 | return tests 32 | 33 | 34 | if __name__ == '__main__': 35 | parser = argparse.ArgumentParser() 36 | parser.add_argument('unittest_source', type=argparse.FileType('r')) 37 | 38 | args = parser.parse_args() 39 | source_path = args.unittest_source.name 40 | spec = importlib.util.spec_from_file_location( 41 | os.path.basename(source_path), source_path) 42 | module = importlib.util.module_from_spec(spec) 43 | spec.loader.exec_module(module) 44 | 45 | for machine, human in list_tests(module): 46 | print(human) 47 | -------------------------------------------------------------------------------- /tests/valgrind-python.supp: -------------------------------------------------------------------------------- 1 | { 2 | ignore_py_cond 3 | Memcheck:Cond 4 | ... 5 | fun:Py* 6 | } 7 | 8 | { 9 | ignore__py_cond 10 | Memcheck:Cond 11 | ... 12 | fun:_Py* 13 | } 14 | 15 | { 16 | ignore_py_value8 17 | Memcheck:Value8 18 | ... 19 | fun:Py* 20 | } 21 | 22 | { 23 | ignore__py_value8 24 | Memcheck:Value8 25 | ... 26 | fun:_Py* 27 | } 28 | 29 | { 30 | ignore_py_addr4 31 | Memcheck:Addr4 32 | ... 33 | fun:Py* 34 | } 35 | 36 | { 37 | ignore__py_addr4 38 | Memcheck:Addr4 39 | ... 40 | fun:_Py* 41 | } 42 | 43 | { 44 | ignore_py_leaks 45 | Memcheck:Leak 46 | ... 47 | fun:Py* 48 | } 49 | 50 | { 51 | ignore__py_leaks 52 | Memcheck:Leak 53 | ... 54 | fun:_Py* 55 | } 56 | -------------------------------------------------------------------------------- /tests/vfs0050/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/tests/vfs0050/capture.png -------------------------------------------------------------------------------- /tests/vfs0050/device: -------------------------------------------------------------------------------- 1 | P: /devices/pci0000:00/0000:00:14.0/usb1/1-9 2 | N: bus/usb/001/004=12011001FF10FF088A13500060000000010109022E00010100A0320904000004FF00000007050102400000070581024000000705820240000007058303080004 3 | E: DEVNAME=/dev/bus/usb/001/004 4 | E: DEVTYPE=usb_device 5 | E: DRIVER=usb 6 | E: PRODUCT=138a/50/60 7 | E: TYPE=255/16/255 8 | E: BUSNUM=001 9 | E: DEVNUM=004 10 | E: MAJOR=189 11 | E: MINOR=3 12 | E: SUBSYSTEM=usb 13 | E: ID_VENDOR=138a 14 | E: ID_VENDOR_ENC=138a 15 | E: ID_VENDOR_ID=138a 16 | E: ID_MODEL=0050 17 | E: ID_MODEL_ENC=0050 18 | E: ID_MODEL_ID=0050 19 | E: ID_REVISION=0060 20 | E: ID_SERIAL=138a_0050_6d1900a1a0c0 21 | E: ID_SERIAL_SHORT=6d1900a1a0c0 22 | E: ID_BUS=usb 23 | E: ID_USB_INTERFACES=:ff0000: 24 | E: ID_VENDOR_FROM_DATABASE=Validity Sensors, Inc. 25 | E: ID_MODEL_FROM_DATABASE=Swipe Fingerprint Sensor 26 | E: ID_PATH=pci-0000:00:14.0-usb-0:9 27 | E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_9 28 | E: LIBFPRINT_DRIVER=Validity VFS0050 29 | A: authorized=1 30 | A: avoid_reset_quirk=0 31 | A: bConfigurationValue=1 32 | A: bDeviceClass=ff 33 | A: bDeviceProtocol=ff 34 | A: bDeviceSubClass=10 35 | A: bMaxPacketSize0=8 36 | A: bMaxPower=100mA 37 | A: bNumConfigurations=1 38 | A: bNumInterfaces= 1 39 | A: bcdDevice=0060 40 | A: bmAttributes=a0 41 | A: busnum=1 42 | A: configuration= 43 | H: descriptors=12011001FF10FF088A13500060000000010109022E00010100A0320904000004FF00000007050102400000070581024000000705820240000007058303080004 44 | A: dev=189:3 45 | A: devnum=4 46 | A: devpath=9 47 | L: driver=../../../../../bus/usb/drivers/usb 48 | A: idProduct=0050 49 | A: idVendor=138a 50 | A: ltm_capable=no 51 | A: maxchild=0 52 | L: port=../1-0:1.0/usb1-port9 53 | A: power/active_duration=19312 54 | A: power/async=enabled 55 | A: power/autosuspend=2 56 | A: power/autosuspend_delay_ms=2000 57 | A: power/connected_duration=1037732 58 | A: power/control=auto 59 | A: power/level=auto 60 | A: power/persist=1 61 | A: power/runtime_active_kids=0 62 | A: power/runtime_active_time=19151 63 | A: power/runtime_enabled=enabled 64 | A: power/runtime_status=active 65 | A: power/runtime_suspended_time=1018305 66 | A: power/runtime_usage=0 67 | A: power/wakeup=disabled 68 | A: power/wakeup_abort_count= 69 | A: power/wakeup_active= 70 | A: power/wakeup_active_count= 71 | A: power/wakeup_count= 72 | A: power/wakeup_expire_count= 73 | A: power/wakeup_last_time_ms= 74 | A: power/wakeup_max_time_ms= 75 | A: power/wakeup_total_time_ms= 76 | A: quirks=0x0 77 | A: removable=fixed 78 | A: rx_lanes=1 79 | A: serial=6d1900a1a0c0 80 | A: speed=12 81 | A: tx_lanes=1 82 | A: urbnum=8 83 | A: version= 1.10 84 | -------------------------------------------------------------------------------- /tests/vfs5011/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3v1n0/libfprint/2978dc0f78856e1c11fca5ee005f3b1ec8575d40/tests/vfs5011/capture.png -------------------------------------------------------------------------------- /tests/vfs5011/device: -------------------------------------------------------------------------------- 1 | P: /devices/pci0000:00/0000:00:14.0/usb2/2-6 2 | N: bus/usb/002/017=12011001FF11FF088A13170078000000010109022E00010100A0320904000004FF00000007050102400000070581024000000705820240000007058303080004 3 | E: DEVNAME=/dev/bus/usb/002/017 4 | E: DEVTYPE=usb_device 5 | E: DRIVER=usb 6 | E: PRODUCT=138a/17/78 7 | E: TYPE=255/17/255 8 | E: BUSNUM=002 9 | E: DEVNUM=017 10 | E: MAJOR=189 11 | E: MINOR=144 12 | E: SUBSYSTEM=usb 13 | E: ID_VENDOR=138a 14 | E: ID_VENDOR_ENC=138a 15 | E: ID_VENDOR_ID=138a 16 | E: ID_MODEL=0017 17 | E: ID_MODEL_ENC=0017 18 | E: ID_MODEL_ID=0017 19 | E: ID_REVISION=0078 20 | E: ID_SERIAL=138a_0017_6c3b5712a6c0 21 | E: ID_SERIAL_SHORT=6c3b5712a6c0 22 | E: ID_BUS=usb 23 | E: ID_USB_INTERFACES=:ff0000: 24 | E: ID_VENDOR_FROM_DATABASE=Validity Sensors, Inc. 25 | E: ID_MODEL_FROM_DATABASE=VFS 5011 fingerprint sensor 26 | A: authorized=1 27 | A: avoid_reset_quirk=0 28 | A: bConfigurationValue=1 29 | A: bDeviceClass=ff 30 | A: bDeviceProtocol=ff 31 | A: bDeviceSubClass=11 32 | A: bMaxPacketSize0=8 33 | A: bMaxPower=100mA 34 | A: bNumConfigurations=1 35 | A: bNumInterfaces= 1 36 | A: bcdDevice=0078 37 | A: bmAttributes=a0 38 | A: busnum=2 39 | A: configuration= 40 | H: descriptors=12011001FF11FF088A13170078000000010109022E00010100A0320904000004FF00000007050102400000070581024000000705820240000007058303080004 41 | A: dev=189:144 42 | A: devnum=17 43 | A: devpath=6 44 | L: driver=../../../../../bus/usb/drivers/usb 45 | A: idProduct=0017 46 | A: idVendor=138a 47 | A: ltm_capable=no 48 | A: maxchild=0 49 | L: port=../2-0:1.0/usb2-port6 50 | A: power/active_duration=624952 51 | A: power/async=enabled 52 | A: power/autosuspend=2 53 | A: power/autosuspend_delay_ms=2000 54 | A: power/connected_duration=624952 55 | A: power/control=on 56 | A: power/level=on 57 | A: power/persist=1 58 | A: power/runtime_active_kids=0 59 | A: power/runtime_active_time=624676 60 | A: power/runtime_enabled=forbidden 61 | A: power/runtime_status=active 62 | A: power/runtime_suspended_time=0 63 | A: power/runtime_usage=1 64 | A: power/wakeup=disabled 65 | A: power/wakeup_abort_count= 66 | A: power/wakeup_active= 67 | A: power/wakeup_active_count= 68 | A: power/wakeup_count= 69 | A: power/wakeup_expire_count= 70 | A: power/wakeup_last_time_ms= 71 | A: power/wakeup_max_time_ms= 72 | A: power/wakeup_total_time_ms= 73 | A: quirks=0x0 74 | A: removable=fixed 75 | A: rx_lanes=1 76 | A: serial=6c3b5712a6c0 77 | A: speed=12 78 | A: tx_lanes=1 79 | A: urbnum=7 80 | A: version= 1.10 81 | --------------------------------------------------------------------------------