Yubico Forum
https://forum.yubico.com/

Yubikey public ID (and sticker)
https://forum.yubico.com/viewtopic.php?f=16&t=436
Page 1 of 1

Author:  btimby [ Thu Nov 19, 2009 5:12 pm ]
Post subject:  Yubikey public ID (and sticker)

My understanding is that the number printed on the sticker stuck to the plastic envelope is the public ID assigned to the yubikey.

I need to know how to translate from this integer value to the modhex version the yubikey spits out.

For example, I ask a customer to read the number from the sticker, I want to locate that key in my database, how is this conversion from integer to 48 bit modhex value performed?

I can find no example of this.

Author:  network-marvels [ Fri Nov 20, 2009 7:46 am ]
Post subject:  Re: Yubikey public ID (and sticker)

Yubico provides the ModHex calculator for converting the data into various formats including converting the integer into the ModHex format. The ModHex calculator is available at the following link:

http://www.yubico.com/developers/modhex/

We hope this helps!

Author:  btimby [ Fri Nov 20, 2009 5:11 pm ]
Post subject:  Re: Yubikey public ID (and sticker)

Thank you. However, I need to do this programatically. I have found examples on how to encode/decode modhex, but how do I go from the result to the int?

Author:  btimby [ Fri Nov 20, 2009 7:52 pm ]
Post subject:  Re: Yubikey public ID (and sticker)

OK, so I figured this out, here is the python code. What I was missing was the byte order.

--
>>> otp = 'ccccccccfckduehjhceenjluteviurncvivulgecfjbj'
>>> id = otp[:-32]
>>> id = yubikey.modhex_decode(id)
>>> id
'\x00\x00\x00\x00@\x92'
>>> struct.unpack('<HHH', id)
(0, 0, 37440)
>>> struct.unpack('>HHH', id)
(0, 0, 16530)
# eureka, there is my id as an integer!
# now pad that guy with NULL word to expand it to 64 bits, then convert to long long.
>>> struct.unpack('>Q', struct.pack('H', 0) + id)
(16530,)
--

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/