Skip to content

Commit

Permalink
revive fido2 list (Nitrokey#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
daringer committed Jun 3, 2021
1 parent 8b77234 commit 39ebea5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions pynitrokey/cli/fido2.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,24 @@ def rng():
@click.command()
def list():
"""List all 'Nitrokey FIDO2' devices"""
solos = nkfido2.find_all()
devs = nkfido2.find_all()
local_print(":: 'Nitrokey FIDO2' keys")
for c in solos:
devdata = c.dev.descriptor
if "serial_number" in devdata:
local_print(f"{devdata['serial_number']}: {devdata['product_string']}")
for c in devs:
descr = c.dev.descriptor

if hasattr(descr, "product_name"):
name = descr.product_name
elif c.is_solo_bootloader():
name = "FIDO2 Bootloader device"
else:
local_print(f"{devdata['path']}: {devdata['product_string']}")
name = "FIDO2 device"

if hasattr(descr, "serial_number"):
id_ = descr.serial_number
else:
id_ = descr.path

local_print(f"{id_}: {name}")

@click.command()
@click.option("--count", default=8, help="How many bytes to generate (defaults to 8)")
Expand Down
2 changes: 1 addition & 1 deletion pynitrokey/fido2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def find_all():

hid_devices = list(CtapHidDevice.list_devices())
solo_devices = [d for d in hid_devices
if (d.descriptor["vendor_id"], d.descriptor["product_id"]) in [
if (d.descriptor.vid, d.descriptor.pid) in [
## @FIXME: move magic numbers
(1155, 41674),
(0x20A0, 0x42B3),
Expand Down

0 comments on commit 39ebea5

Please sign in to comment.