From 958d7a29dc8ab84da7e4f6eae1a97d45e78e04e6 Mon Sep 17 00:00:00 2001 From: Jean-Michel Picod Date: Thu, 11 Feb 2021 17:44:49 +0100 Subject: [PATCH] Fix `config.py` tool according to the new API of fido2 python package (#284) * Fix fido2 API update. Since fido2 0.8.1 the device descriptor moved to NamedTuple, breaking our configuration tool. Code is now updated accordingly and the setup script ensure we're using the correct version for fido2 package. * Make Yapf happy * Fix missing update for fido2 0.9.1 Also split the comment into 2 lines so that the touch is not hidden at the end of the screen. --- setup.sh | 2 +- tools/configure.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/setup.sh b/setup.sh index 13ad9b0..6d58053 100755 --- a/setup.sh +++ b/setup.sh @@ -46,4 +46,4 @@ mkdir -p elf2tab cargo install elf2tab --version 0.6.0 --root elf2tab/ # Install python dependencies to factory configure OpenSK (crypto, JTAG lockdown) -pip3 install --user --upgrade colorama tqdm cryptography fido2 +pip3 install --user --upgrade colorama tqdm cryptography "fido2>=0.9.1" diff --git a/tools/configure.py b/tools/configure.py index cc00a1a..9343490 100755 --- a/tools/configure.py +++ b/tools/configure.py @@ -64,8 +64,7 @@ def info(msg): def get_opensk_devices(batch_mode): devices = [] for dev in hid.CtapHidDevice.list_devices(): - if (dev.descriptor["vendor_id"], - dev.descriptor["product_id"]) == OPENSK_VID_PID: + if (dev.descriptor.vid, dev.descriptor.pid) == OPENSK_VID_PID: if dev.capabilities & hid.CAPABILITY.CBOR: if batch_mode: devices.append(ctap2.CTAP2(dev)) @@ -138,10 +137,9 @@ def main(args): if authenticator.device.capabilities & hid.CAPABILITY.WINK: authenticator.device.wink() aaguid = uuid.UUID(bytes=authenticator.get_info().aaguid) - info(("Programming device {} AAGUID {} ({}). " - "Please touch the device to confirm...").format( - authenticator.device.descriptor.get("product_string", "Unknown"), - aaguid, authenticator.device)) + info("Programming OpenSK device AAGUID {} ({}).".format( + aaguid, authenticator.device)) + info("Please touch the device to confirm...") try: result = authenticator.send_cbor( OPENSK_VENDOR_CONFIGURE,