How to use the ledgerblue.commU2F.U2FTunnelDongle function in ledgerblue

To help you get started, we’ve selected a few ledgerblue examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LedgerHQ / blue-loader-python / ledgerblue / commU2F.py View on Github external
def getDongles(dev_class=None, scrambleKey="", debug=False):
    dev_class = dev_class or HIDDevice
    devices = []
    for d in hid.enumerate(0, 0):
        usage_page = d['usage_page']
        if usage_page == 0xf1d0 and d['usage'] == 1:
            devices.append(U2FTunnelDongle(dev_class(d['path']),scrambleKey, debug=debug))
        # Usage page doesn't work on Linux
        # well known devices
        elif (d['vendor_id'], d['product_id']) in DEVICES:
            device = HIDDevice(d['path'])
            try:
                device.open()
                device.close()
                devices.append(U2FTunnelDongle(dev_class(d['path']),scrambleKey, debug=debug))
            except (exc.DeviceError, IOError, OSError):
                pass
        # unknown devices
        else:
            device = HIDDevice(d['path'])
            try:
                device.open()
                # try a ping command to ensure a FIDO device, else timeout (BEST here, modulate the timeout, 2 seconds is way too big)
github LedgerHQ / blue-loader-python / ledgerblue / commU2F.py View on Github external
def getDongle(path=None, dev_class=None, scrambleKey="", debug=False):
  # if path is none, then use the first device
  dev_class = dev_class or HIDDevice
  devices = []
  for d in hid.enumerate(0, 0):
    if path is None or d['path'] == path:
      usage_page = d['usage_page']
      if usage_page == 0xf1d0 and d['usage'] == 1:
          return U2FTunnelDongle(dev_class(d['path']),scrambleKey, debug=debug)
      # Usage page doesn't work on Linux
      # well known devices
      elif (d['vendor_id'], d['product_id']) in DEVICES and ('interface_number' not in d or d['interface_number'] == 1):
          #print d
          device = HIDDevice(d['path'])
          try:
              device.open()
              device.close()
              return U2FTunnelDongle(dev_class(d['path']),scrambleKey, debug=debug)
          except (exc.DeviceError, IOError, OSError):
              traceback.print_exc()
              pass
      # unknown devices
      # else:
      #     device = HIDDevice(d['path'])
      #     try: