New reformatting of code after rebase and changes.
This commit is contained in:
parent
9f116547d0
commit
4417e49612
13 changed files with 51 additions and 52 deletions
|
|
@ -158,11 +158,9 @@ class Device(dbus.service.Object):
|
|||
logging.exception(e)
|
||||
self.EnrollStatus('enroll-failed', True)
|
||||
|
||||
if index == None:
|
||||
logging.exception(
|
||||
'Unknown finger name passed to enroll? ' +
|
||||
finger_name + ' (' + winbio_name + ')'
|
||||
)
|
||||
if index is None:
|
||||
logging.exception('Unknown finger name passed to enroll? ' + finger_name + ' (' +
|
||||
winbio_name + ')')
|
||||
self.EnrollStatus('enroll-failed', True)
|
||||
else:
|
||||
thread = Thread(target=run)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from validitysensor.usb import usb
|
||||
from validitysensor.sensor import factory_reset, RebootException
|
||||
from validitysensor.usb import usb
|
||||
|
||||
try:
|
||||
usb.open()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import dbus.mainloop.glib
|
||||
|
||||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||
|
||||
bus = dbus.SystemBus()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from binascii import hexlify
|
|||
|
||||
from validitysensor.sensor import sensor
|
||||
|
||||
|
||||
# usb.trace_enabled = True
|
||||
# tls.trace_enabled = True
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import typing
|
||||
from binascii import hexlify
|
||||
from struct import pack, unpack
|
||||
import typing
|
||||
|
||||
from .blobs import db_write_enable
|
||||
from .flash import call_cleanups
|
||||
|
|
|
|||
|
|
@ -80,7 +80,8 @@ class ModuleInfo:
|
|||
|
||||
|
||||
class FirmwareInfo:
|
||||
def __init__(self, major: int, minor: int, buildtime: int, modules: typing.Sequence[ModuleInfo]):
|
||||
def __init__(self, major: int, minor: int, buildtime: int,
|
||||
modules: typing.Sequence[ModuleInfo]):
|
||||
self.major, self.minor, self.buildtime, self.modules = major, minor, buildtime, modules
|
||||
|
||||
def __repr__(self):
|
||||
|
|
|
|||
|
|
@ -408,7 +408,8 @@ class Sensor:
|
|||
|
||||
return key_line
|
||||
|
||||
def line_update_type_1(self, mode: CaptureMode, chunks: typing.List[typing.List[typing.Union[int, bytes]]]):
|
||||
def line_update_type_1(self, mode: CaptureMode,
|
||||
chunks: typing.List[typing.List[typing.Union[int, bytes]]]):
|
||||
for c in chunks:
|
||||
# Timeslot Table 2D
|
||||
if c[0] == 0x34:
|
||||
|
|
@ -511,11 +512,12 @@ class Sensor:
|
|||
|
||||
return chunks
|
||||
|
||||
def line_update_type_2(self, mode: CaptureMode, chunks: typing.List[typing.List[typing.Union[int, bytes]]]):
|
||||
def line_update_type_2(self, mode: CaptureMode,
|
||||
chunks: typing.List[typing.List[typing.Union[int, bytes]]]):
|
||||
for c in chunks:
|
||||
# patch the 2D params.
|
||||
# The following is only needed on some rom versions below 6.5 as reported by cmd_01
|
||||
#if c[0] == 0x2f:
|
||||
# if c[0] == 0x2f:
|
||||
# c[1] = pack('<L', unpack('<L', c[1])[0]*mult)
|
||||
|
||||
# Timeslot Table 2D
|
||||
|
|
@ -589,7 +591,7 @@ class Sensor:
|
|||
if pad > 0:
|
||||
l.data += b'\0' * (4 - pad)
|
||||
|
||||
#---------------- Line Update ---------------
|
||||
# ---------------- Line Update ---------------
|
||||
line_update = pack('<L', len(lines))
|
||||
line_update += b''.join([pack('<LL', l.mask, l.flags) for l in lines])
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ class SensorTypeInfo:
|
|||
if i.sensor_type == sensor_type:
|
||||
return i
|
||||
|
||||
def __init__(self, sensor_type: int, bytes_per_line: int, repeat_multiplier: int, lines_per_calibration_data: int,
|
||||
line_width: int, calibration_blob: str):
|
||||
def __init__(self, sensor_type: int, bytes_per_line: int, repeat_multiplier: int,
|
||||
lines_per_calibration_data: int, line_width: int, calibration_blob: str):
|
||||
self.sensor_type = sensor_type
|
||||
self.repeat_multiplier = repeat_multiplier
|
||||
self.lines_per_calibration_data = lines_per_calibration_data
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import typing
|
||||
from binascii import hexlify
|
||||
from struct import unpack, pack
|
||||
import typing
|
||||
|
||||
codes = {}
|
||||
codes[0x0] = "No Operation"
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ class Tls:
|
|||
return m
|
||||
|
||||
def encrypt(self, b: bytes):
|
||||
#iv = unhexlify('454849acdd075174d6b9e713a957c2e7')
|
||||
# iv = unhexlify('454849acdd075174d6b9e713a957c2e7')
|
||||
iv = os.urandom(0x10)
|
||||
cipher = Cipher(algorithms.AES(self.encryption_key), modes.CBC(iv), backend=crypto_backend)
|
||||
encryptor = cipher.encryptor()
|
||||
|
|
@ -383,7 +383,7 @@ class Tls:
|
|||
|
||||
def make_client_hello(self):
|
||||
h = unhexlify('0303') # TLS 1.2
|
||||
#self.client_random = unhexlify('bc349559ac16c8f8362191395b4d04a435d870315f519eed8777488bc2b9600c')
|
||||
# self.client_random = unhexlify('bc349559ac16c8f8362191395b4d04a435d870315f519eed8777488bc2b9600c')
|
||||
self.client_random = os.urandom(0x20)
|
||||
h += self.client_random # client's random
|
||||
h += with_1byte_size(unhexlify('00000000000000')) # session ID
|
||||
|
|
@ -533,8 +533,8 @@ class Tls:
|
|||
self.trace('d=0x%x' % d)
|
||||
|
||||
# Someone has reported that x and y are 0 after pairing with the latest windows driver.
|
||||
#pub_key = ec.EllipticCurvePublicNumbers(x, y, ec.SECP256R1())
|
||||
#self.priv_key = ec.EllipticCurvePrivateNumbers(d, pub_key).private_key(crypto_backend)
|
||||
# pub_key = ec.EllipticCurvePublicNumbers(x, y, ec.SECP256R1())
|
||||
# self.priv_key = ec.EllipticCurvePrivateNumbers(d, pub_key).private_key(crypto_backend)
|
||||
|
||||
self.priv_key = ec.derive_private_key(d, ec.SECP256R1(), backend=crypto_backend)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
import typing
|
||||
from os.path import basename
|
||||
from time import ctime
|
||||
import typing
|
||||
|
||||
from .flash import write_flash_all, write_fw_signature, get_fw_info
|
||||
from .sensor import reboot, write_hw_reg32, read_hw_reg32, identify_sensor
|
||||
|
|
@ -22,7 +22,7 @@ def default_fwext_name():
|
|||
return '6_07f_lenovo_mis_qm.xpfwext'
|
||||
|
||||
|
||||
def upload_fwext(fw_path: typing.Optional[str]=None):
|
||||
def upload_fwext(fw_path: typing.Optional[str] = None):
|
||||
fwi = get_fw_info(2)
|
||||
if fwi is not None:
|
||||
logging.info('Detected firmware version %d.%d (%s))' %
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import errno
|
||||
import logging
|
||||
import typing
|
||||
from binascii import hexlify, unhexlify
|
||||
from struct import unpack
|
||||
import typing
|
||||
|
||||
import usb.core as ucore
|
||||
from usb.core import USBError
|
||||
|
|
|
|||
|
|
@ -1,36 +1,34 @@
|
|||
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,
|
||||
# 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,
|
||||
|
||||
"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
|
||||
# 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
|
||||
finger_names[index] = name
|
||||
|
|
|
|||
Loading…
Reference in a new issue