Yubico Forum

...visit our web-store at store.yubico.com
It is currently Tue Jan 30, 2018 5:33 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Nov 19, 2009 5:12 pm 
Offline

Joined: Tue May 19, 2009 3:26 pm
Posts: 5
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.


Top
 Profile  
Reply with quote  

Share On:

Share on Facebook FacebookShare on Twitter TwitterShare on Tumblr TumblrShare on Google+ Google+

PostPosted: Fri Nov 20, 2009 7:46 am 
Offline
Yubico Team
Yubico Team

Joined: Wed Oct 01, 2008 8:11 am
Posts: 210
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!


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 20, 2009 5:11 pm 
Offline

Joined: Tue May 19, 2009 3:26 pm
Posts: 5
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?


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 20, 2009 7:52 pm 
Offline

Joined: Tue May 19, 2009 3:26 pm
Posts: 5
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,)
--


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group