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

how to obtain sanitized results from challenge_response #35

Closed vapniks closed 7 years ago

vapniks commented 7 years ago

When I call challenge_reponse on a yubikey object the results look quite different to those obtained from the ykchalresp binary. Example: Results from shell command ykchalresp hello: ca299ea0ea9e5c76b197a322c60909e302a54ae9 Whereas the following code:

yubikey = yubico.find_yubikey(debug = False)
resp = yubikey.challenge_response("hello")

results in: \xca)\x9e\xa0\xea\x9e\\v\xb1\x97\xa3"\xc6\t\t\xe3\x02\xa5J\xe9 If I put the results through the hexdump utility function:

yubico.yubico_util.hexdump(resp)

then I get: 0000 ca 29 9e a0 ea 9e 5c 76\n0008 b1 97 a3 22 c6 09 09 e3\n0010 02 a5 4a e9\n which is still not what I want. Surely there is some way to get results from python the same as those from the shell command?

dainnilsson commented 7 years ago
from binascii import b2a_hex
b2a_hex(resp)
vapniks commented 7 years ago

Great, that works. Thanks!