From 0577e82c7f05b208c66b25ead0ed662365856d69 Mon Sep 17 00:00:00 2001 From: baschi29 Date: Wed, 20 Apr 2022 22:29:52 +0200 Subject: [PATCH] ANSI381 naming if fprint names are not specified --- dbus_service/dbus-service | 2 +- validitysensor/db.py | 2 +- validitysensor/fingerprint_constants.py | 39 +++++++++++++++++++++++++ validitysensor/fprint_constants.py | 18 ------------ validitysensor/winbio_constants.py | 34 --------------------- 5 files changed, 41 insertions(+), 54 deletions(-) create mode 100644 validitysensor/fingerprint_constants.py delete mode 100644 validitysensor/fprint_constants.py delete mode 100644 validitysensor/winbio_constants.py diff --git a/dbus_service/dbus-service b/dbus_service/dbus-service index 829f5ec..63cb9e5 100755 --- a/dbus_service/dbus-service +++ b/dbus_service/dbus-service @@ -27,7 +27,7 @@ from validitysensor.sensor import sensor, RebootException from validitysensor.sid import sid_from_string from validitysensor.tls import tls from validitysensor.usb import usb -from validitysensor.fprint_constants import finger_ids +from validitysensor.fingerprint_constants import finger_ids dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) diff --git a/validitysensor/db.py b/validitysensor/db.py index 11251aa..accda03 100644 --- a/validitysensor/db.py +++ b/validitysensor/db.py @@ -7,7 +7,7 @@ from .flash import call_cleanups from .sid import SidIdentity, sid_from_bytes from .tls import tls from .util import assert_status -from .fprint_constants import finger_names +from .fingerprint_constants import finger_names class UserStorage: diff --git a/validitysensor/fingerprint_constants.py b/validitysensor/fingerprint_constants.py new file mode 100644 index 0000000..e5065e5 --- /dev/null +++ b/validitysensor/fingerprint_constants.py @@ -0,0 +1,39 @@ +# maps fingerprint names from the fprint api to corresponding indices +# for legacy reasons uses ANSI381 naming if no fprint name is specified - see https://github.com/uunicorn/python-validity/pull/23 + +finger_ids = { + # fprint https://fprint.freedesktop.org/fprintd-dev/Device.html#fingerprint-names + "right-thumb": 1, + "right-index-finger": 2, + "right-middle-finger": 3, + "right-ring-finger": 4, + "right-little-finger": 5, + "left-thumb": 6, + "left-index-finger": 7, + "left-middle-finger": 8, + "left-ring-finger": 9, + "left-little-finger": 10, + + # ANSI381 https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/shared/winbio_types.h#L864-L878 + "WINBIO_ANSI_381_POS_UNKNOWN": 0, + "WINBIO_ANSI_381_POS_RH_FOUR_FINGERS": 13, + "WINBIO_ANSI_381_POS_LH_FOUR_FINGERS": 14, + "WINBIO_ANSI_381_POS_TWO_THUMBS": 15, + + # Microsoft specific extensions https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/shared/winbio_types.h#L920-L929 + "WINBIO_FINGER_UNSPECIFIED_POS_01": 0xf5, + "WINBIO_FINGER_UNSPECIFIED_POS_02": 0xf6, + "WINBIO_FINGER_UNSPECIFIED_POS_03": 0xf7, + "WINBIO_FINGER_UNSPECIFIED_POS_04": 0xf8, + "WINBIO_FINGER_UNSPECIFIED_POS_05": 0xf9, + "WINBIO_FINGER_UNSPECIFIED_POS_06": 0xfa, + "WINBIO_FINGER_UNSPECIFIED_POS_07": 0xfb, + "WINBIO_FINGER_UNSPECIFIED_POS_08": 0xfc, + "WINBIO_FINGER_UNSPECIFIED_POS_09": 0xfd, + "WINBIO_FINGER_UNSPECIFIED_POS_10": 0xfe +} + +# Store the keys in the reverse order for faster lookups +finger_names = {} +for name, index in finger_ids.items(): + finger_names[index] = name \ No newline at end of file diff --git a/validitysensor/fprint_constants.py b/validitysensor/fprint_constants.py deleted file mode 100644 index 41b99a3..0000000 --- a/validitysensor/fprint_constants.py +++ /dev/null @@ -1,18 +0,0 @@ -finger_ids = { - # https://fprint.freedesktop.org/fprintd-dev/Device.html#fingerprint-names - "right-thumb": 1, - "right-index-finger": 2, - "right-middle-finger": 3, - "right-ring-finger": 4, - "right-little-finger": 5, - "left-thumb": 6, - "left-index-finger": 7, - "left-middle-finger": 8, - "left-ring-finger": 9, - "left-little-finger": 10, -} - -# Store the keys in the reverse order for faster lookups -finger_names = {} -for name, index in finger_ids.items(): - finger_names[index] = name \ No newline at end of file diff --git a/validitysensor/winbio_constants.py b/validitysensor/winbio_constants.py deleted file mode 100644 index 576620a..0000000 --- a/validitysensor/winbio_constants.py +++ /dev/null @@ -1,34 +0,0 @@ -finger_ids = { - # https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/shared/winbio_types.h#L864-L878 - "WINBIO_ANSI_381_POS_UNKNOWN": 0, - "WINBIO_ANSI_381_POS_RH_THUMB": 1, - "WINBIO_ANSI_381_POS_RH_INDEX_FINGER": 2, - "WINBIO_ANSI_381_POS_RH_MIDDLE_FINGER": 3, - "WINBIO_ANSI_381_POS_RH_RING_FINGER": 4, - "WINBIO_ANSI_381_POS_RH_LITTLE_FINGER": 5, - "WINBIO_ANSI_381_POS_LH_THUMB": 6, - "WINBIO_ANSI_381_POS_LH_INDEX_FINGER": 7, - "WINBIO_ANSI_381_POS_LH_MIDDLE_FINGER": 8, - "WINBIO_ANSI_381_POS_LH_RING_FINGER": 9, - "WINBIO_ANSI_381_POS_LH_LITTLE_FINGER": 10, - "WINBIO_ANSI_381_POS_RH_FOUR_FINGERS": 13, - "WINBIO_ANSI_381_POS_LH_FOUR_FINGERS": 14, - "WINBIO_ANSI_381_POS_TWO_THUMBS": 15, - - # https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/shared/winbio_types.h#L920-L929 - "WINBIO_FINGER_UNSPECIFIED_POS_01": 0xf5, - "WINBIO_FINGER_UNSPECIFIED_POS_02": 0xf6, - "WINBIO_FINGER_UNSPECIFIED_POS_03": 0xf7, - "WINBIO_FINGER_UNSPECIFIED_POS_04": 0xf8, - "WINBIO_FINGER_UNSPECIFIED_POS_05": 0xf9, - "WINBIO_FINGER_UNSPECIFIED_POS_06": 0xfa, - "WINBIO_FINGER_UNSPECIFIED_POS_07": 0xfb, - "WINBIO_FINGER_UNSPECIFIED_POS_08": 0xfc, - "WINBIO_FINGER_UNSPECIFIED_POS_09": 0xfd, - "WINBIO_FINGER_UNSPECIFIED_POS_10": 0xfe -} - -# Store the keys in the reverse order for faster lookups -finger_names = {} -for name, index in finger_ids.items(): - finger_names[index] = name