Yubico / python-yubico

Python code to talk to YubiKeys
https://developers.yubico.com/python-yubico/
BSD 2-Clause "Simplified" License
229 stars 33 forks source link

find_yubikey fails on TypeError #36

Closed recmo closed 5 years ago

recmo commented 7 years ago
In [1]: import yubico

In [2]: yubikey = yubico.find_yubikey(debug=True)
YubiKeyHIDDevice: Unable to set configuration, ignoring...
YubiKeyHIDDevice: READ  : 0000   00 04 03 01 01 05 02 00
YubiKeyHIDDevice: READ  : 0000   00 04 03 01 01 05 02 00
YubiKeyHIDDevice: READ  : 0000   00 04 03 01 01 05 02 00
YubiKeyHIDDevice: WRITE : 0000   00 00 00 00 00 00 00 80 
YubiKeyHIDDevice: READ  : 0000   00 04 03 01 01 05 02 00
YubiKeyHIDDevice: WRITE : 0000   00 13 6b 5b 00 00 00 89 
YubiKeyHIDDevice: READ  : 0000   0c 01 01 3f 02 04 00 c0
YubiKeyHIDDevice: READ  : 0000   4b 7e ba 03 01 3f a9 c1
YubiKeyHIDDevice: READ  : 0000   a3 cd 30 00 6e 87 17 c2
YubiKeyHIDDevice: READ  : 0000   0c 01 01 3f 02 04 00 c0
YubiKeyHIDDevice: WRITE : 0000   00 00 00 00 00 00 00 8f 
YubiKeyHIDDevice: READ  : 0000   00 04 03 01 01 05 02 00
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-da16bc72b5cd> in <module>()
----> 1 yubikey = yubico.find_yubikey(debug=True)

/usr/local/lib/python3.5/dist-packages/yubico/yubikey.py in find_key(debug, skip)
     59         if yk_version < (4, 0, 0):
     60             return YubiKeyNEO_USBHID(debug, skip, hid_device)
---> 61         return YubiKey4_USBHID(debug, skip, hid_device)
     62     except YubiKeyUSBHIDError as inst:
     63         if 'No USB YubiKey found' in str(inst):

/usr/local/lib/python3.5/dist-packages/yubico/yubikey_4_usb_hid.py in __init__(self, debug, skip, hid_device)
     96 
     97         if self.capabilities.have_capabilities():
---> 98             data = yubico_util.tlv_parse(self._read_capabilities())
     99             self.capabilities._set_yk4_capa(data.get(YK4_CAPA.TAG.CAPA, b''))
    100 

/usr/local/lib/python3.5/dist-packages/yubico/yubikey_4_usb_hid.py in _read_capabilities(self)
    105         self._device._write(frame)
    106         response = self._device._read_response()
--> 107         r_len = ord(response[0])
    108 
    109         # 1 byte length, 2 byte CRC.

TypeError: ord() expected string of length 1, but int found
stlaz commented 7 years ago

Seems to have been fixed two years ago in https://github.com/Yubico/python-yubico/commit/7e6e424ed579c53a0767ba71eb47345ae1e472ca. You may need to upgrade your library if you haven't done so in the past year since this issue was opened.

mdxs commented 5 years ago

While it has indeed been fixed as @stlaz wrote, I noticed that /usr/local/lib/python3.5 showed in the log that @Remco posted originally; therefore https://github.com/Yubico/python-yubico/issues/38 applies and either one needs to install from head or wait for Yubico to release an update to this python-yubico library so that Python 3 is properly supported again.

dainnilsson commented 5 years ago

1.3.3 is now released.