Skip to content

Commit

Permalink
Merge branch 'sz-fido2-verify-do-not-scan-for-hidraw-devices'
Browse files Browse the repository at this point in the history
Do not connect to other hidraw devices when device file is specified

Fixes #125
  • Loading branch information
szszszsz committed Dec 11, 2021
2 parents 172048f + cc38a94 commit c3edabc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pynitrokey/fido2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,22 @@ def reboot(
pass

def find_device(self, dev=None, solo_serial: str = None):
devices = []
if dev is None:
devices = list(CtapHidDevice.list_devices())
if solo_serial is not None:
if solo_serial.startswith("device="):
solo_serial = solo_serial.split("=")[1]
dev = open_device(solo_serial)
else:
devices = list(CtapHidDevice.list_devices())
devices = [
d for d in devices if d.descriptor.serial_number == solo_serial
]
if dev is None and len(devices) > 1:
else:
devices = list(CtapHidDevice.list_devices())
if len(devices) > 1:
raise pynitrokey.exceptions.NonUniqueDeviceError
if dev is None and len(devices) > 0:
if len(devices) > 0:
dev = devices[0]
if dev is None:
raise RuntimeError("No FIDO device found")
Expand Down

0 comments on commit c3edabc

Please sign in to comment.