From e93ef0c296211ad7ef1315f66414a7b17ad9a42f Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 9 Feb 2018 16:45:36 +0100 Subject: [PATCH] src: disable u2f in debug builds --- src/main.py | 75 ++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/src/main.py b/src/main.py index 44023375b..b83975e36 100644 --- a/src/main.py +++ b/src/main.py @@ -18,43 +18,43 @@ usb_wire = io.WebUSB( ep_out=0x01, ) -usb_u2f = io.HID( - iface_num=1, - ep_in=0x82, - ep_out=0x02, - report_desc=bytes([ - 0x06, 0xd0, 0xf1, # USAGE_PAGE (FIDO Alliance) - 0x09, 0x01, # USAGE (U2F HID Authenticator Device) - 0xa1, 0x01, # COLLECTION (Application) - 0x09, 0x20, # USAGE (Input Report Data) - 0x15, 0x00, # LOGICAL_MINIMUM (0) - 0x26, 0xff, 0x00, # LOGICAL_MAXIMUM (255) - 0x75, 0x08, # REPORT_SIZE (8) - 0x95, 0x40, # REPORT_COUNT (64) - 0x81, 0x02, # INPUT (Data,Var,Abs) - 0x09, 0x21, # USAGE (Output Report Data) - 0x15, 0x00, # LOGICAL_MINIMUM (0) - 0x26, 0xff, 0x00, # LOGICAL_MAXIMUM (255) - 0x75, 0x08, # REPORT_SIZE (8) - 0x95, 0x40, # REPORT_COUNT (64) - 0x91, 0x02, # OUTPUT (Data,Var,Abs) - 0xc0, # END_COLLECTION - ]), -) - if __debug__: usb_debug = io.WebUSB( - iface_num=2, - ep_in=0x85, - ep_out=0x05, + iface_num=1, + ep_in=0x82, + ep_out=0x02, ) usb_vcp = io.VCP( - iface_num=3, - data_iface_num=4, + iface_num=2, + data_iface_num=3, ep_in=0x83, ep_out=0x03, ep_cmd=0x84, ) +else: + usb_u2f = io.HID( + iface_num=1, + ep_in=0x82, + ep_out=0x02, + report_desc=bytes([ + 0x06, 0xd0, 0xf1, # USAGE_PAGE (FIDO Alliance) + 0x09, 0x01, # USAGE (U2F HID Authenticator Device) + 0xa1, 0x01, # COLLECTION (Application) + 0x09, 0x20, # USAGE (Input Report Data) + 0x15, 0x00, # LOGICAL_MINIMUM (0) + 0x26, 0xff, 0x00, # LOGICAL_MAXIMUM (255) + 0x75, 0x08, # REPORT_SIZE (8) + 0x95, 0x40, # REPORT_COUNT (64) + 0x81, 0x02, # INPUT (Data,Var,Abs) + 0x09, 0x21, # USAGE (Output Report Data) + 0x15, 0x00, # LOGICAL_MINIMUM (0) + 0x26, 0xff, 0x00, # LOGICAL_MAXIMUM (255) + 0x75, 0x08, # REPORT_SIZE (8) + 0x95, 0x40, # REPORT_COUNT (64) + 0x91, 0x02, # OUTPUT (Data,Var,Abs) + 0xc0, # END_COLLECTION + ]), + ) usb = io.USB( vendor_id=0x1209, @@ -67,28 +67,31 @@ usb = io.USB( ) usb.add(usb_wire) -usb.add(usb_u2f) if __debug__: usb.add(usb_debug) usb.add(usb_vcp) +else: + usb.add(usb_u2f) # load applications -if __debug__: - from apps import debug from apps import homescreen from apps import management from apps import wallet from apps import ethereum -from apps import fido_u2f +if __debug__: + from apps import debug +else: + from apps import fido_u2f # boot applications -if __debug__: - debug.boot() homescreen.boot() management.boot() wallet.boot() ethereum.boot() -fido_u2f.boot(usb_u2f) +if __debug__: + debug.boot() +else: + fido_u2f.boot(usb_u2f) # initialize the wire codec and start the USB wire.setup(usb_wire)