<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
<link rel="self" type="application/atom+xml" href="https://forum.yubico.com/feed.php?f=4&amp;t=103" />

<title>Yubico Forum</title>
<subtitle>...visit our web-store at</subtitle>
<link href="https://forum.yubico.com/index.php" />
<updated>2009-01-19T00:21:02+01:00</updated>

<author><name><![CDATA[Yubico Forum]]></name></author>
<id>https://forum.yubico.com/feed.php?f=4&amp;t=103</id>
<entry>
<author><name><![CDATA[chaeron]]></name></author>
<updated>2009-01-19T00:21:02+01:00</updated>
<published>2009-01-19T00:21:02+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=103&amp;p=931#p931</id>
<link href="https://forum.yubico.com/viewtopic.php?t=103&amp;p=931#p931"/>
<title type="html"><![CDATA[Re: OTP validation cookbook]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=103&amp;p=931#p931"><![CDATA[
Perfect...that was what I was hoping would happen.<br /><br />That way you don't have to get users to unplug a key after 256 uses.<br /><br />One small suggestion....the use of session/usage counter terminology is not consistent on the forum, in the open source validation code (Java) and in some of the documentation.<br /><br />Session to me means number of power ups, that is number of times the yubikey has been inserted into a USB port and powered up.  Usage to me means number of times you've generated a OTP during a powered up session.<br /><br />Regardless of which way you want to define the terms &quot;session&quot; and &quot;usage&quot; counters, I would recommend that you go through and make the use of the terms consistent across all incarnations.<br /><br />Thx!<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=351">chaeron</a> — Mon Jan 19, 2009 12:21 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Jakob]]></name></author>
<updated>2009-01-10T18:00:39+01:00</updated>
<published>2009-01-10T18:00:39+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=103&amp;p=871#p871</id>
<link href="https://forum.yubico.com/viewtopic.php?t=103&amp;p=871#p871"/>
<title type="html"><![CDATA[Re: OTP validation cookbook]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=103&amp;p=871#p871"><![CDATA[
The usage counter is incremented when the session counter wraps from 255 to 0. Just like if the key was unplugged and inserted again.<br /><br />With the best regards,<br /><br />JakobE<br />Hardware- and firmware guy @ Yubico<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=83">Jakob</a> — Sat Jan 10, 2009 6:00 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[chaeron]]></name></author>
<updated>2009-01-10T02:39:23+01:00</updated>
<published>2009-01-10T02:39:23+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=103&amp;p=866#p866</id>
<link href="https://forum.yubico.com/viewtopic.php?t=103&amp;p=866#p866"/>
<title type="html"><![CDATA[Re: OTP validation cookbook]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=103&amp;p=866#p866"><![CDATA[
<div class="quotetitle">JakobE wrote:</div><div class="quotecontent"><br /><strong>Step 3: Basic (simple) counter validation</strong><br /><br />1. Set ctr32 = ((useCtr &amp; 0x7fff) &lt;&lt; 8) + sessionCtr <br /><br />2. Verify that ctr32 &gt; lastCtr32. If not, it is a fair guess that the OTP is subject to a replay<br /><br />3. If successful, store ctr32 in the database to be lastCtr32<br /></div><br /><br />OK...what happens when the 1 byte sessionCtr rolls over from 255 to 0, as in if a user kept their key plugged in for 256 invocations?<br /><br />The PDF says that that the sessionCtr rolls to zero, but no mention if the 2 byte useCtr  is incremented....I'm assuming that the useCtr does not increment during the rollover.<br /><br />In which case the validation will fail according to the algorithm set out in Step 3.<br /><br />So....do we just live with this and tell the user to remove and re-insert their key and try again?<br /><br />Or is there a better way?<br /><br />Thx!<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=351">chaeron</a> — Sat Jan 10, 2009 2:39 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[paul]]></name></author>
<updated>2008-09-17T15:26:06+01:00</updated>
<published>2008-09-17T15:26:06+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=103&amp;p=691#p691</id>
<link href="https://forum.yubico.com/viewtopic.php?t=103&amp;p=691#p691"/>
<title type="html"><![CDATA[Re: OTP validation cookbook]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=103&amp;p=691#p691"><![CDATA[
<div class="quotetitle">merlin wrote:</div><div class="quotecontent"><br /><div class="quotetitle">JakobE wrote:</div><div class="quotecontent">4. Decrypt the 16 bytes (128 bits) using AES-128 decryption<br /></div><br /><br />Hi<br /><br />I've been searching for the specific layout of the decrypted 128 bits. Some of the fields are referenced in various posts, but I've not seen it &quot;all in one place&quot;, offsets etc<br /> <br />I'm sure it must be somewhere but I'm not finding it - can someone give the link <br /><br />TIA</div><br /><br />Page 2 in this doc explains it well: <!-- m --><a class="postlink" href="http://yubico.com/files/YubiKey_Security_Review.pdf">http://yubico.com/files/YubiKey_Security_Review.pdf</a><!-- m --><br /><br />If you like to find the code that decrypts the OTP, you can find them here: <br /><!-- m --><a class="postlink" href="http://yubico.com/developers/library/">http://yubico.com/developers/library/</a><!-- m --><br /><br />and <!-- m --><a class="postlink" href="http://yubico.com/developers/srv/">http://yubico.com/developers/srv/</a><!-- m --><p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=55">paul</a> — Wed Sep 17, 2008 3:26 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[merlin]]></name></author>
<updated>2008-09-17T05:03:27+01:00</updated>
<published>2008-09-17T05:03:27+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=103&amp;p=690#p690</id>
<link href="https://forum.yubico.com/viewtopic.php?t=103&amp;p=690#p690"/>
<title type="html"><![CDATA[Re: OTP validation cookbook]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=103&amp;p=690#p690"><![CDATA[
<div class="quotetitle">JakobE wrote:</div><div class="quotecontent"><br />4. Decrypt the 16 bytes (128 bits) using AES-128 decryption<br /></div><br /><br />Hi<br /><br />I've been searching for the specific layout of the decrypted 128 bits. Some of the fields are referenced in various posts, but I've not seen it &quot;all in one place&quot;, offsets etc<br /> <br />I'm sure it must be somewhere but I'm not finding it - can someone give the link <br /><br />TIA<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=256">merlin</a> — Wed Sep 17, 2008 5:03 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[jwoltman]]></name></author>
<updated>2008-06-17T22:56:57+01:00</updated>
<published>2008-06-17T22:56:57+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=103&amp;p=308#p308</id>
<link href="https://forum.yubico.com/viewtopic.php?t=103&amp;p=308#p308"/>
<title type="html"><![CDATA[Re: OTP validation cookbook]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=103&amp;p=308#p308"><![CDATA[
<div class="quotetitle">aha42 wrote:</div><div class="quotecontent"><br />Is it a (good?) idea to make a reference implementation of the validation cookbook i the various language currently being hacked in?<br /><br />ValidationResult YubiKeyValidation.validate(Token t, KeyData kd)<br /><br />So this would be invoked after OTP is decrypted and parsed. KeyData contains information of last OTP received from YubiKey in question.<br /></div><br /><br />I think this is a great idea.  That's what I'm trying to accomplish with the PHP version.  If you or anyone else has any input, please let me know.<br /><br />My method (YubiAuthenticator::authenticate) takes the exact same parameters as your sample ValidationResult.  <img src="https://forum.yubico.com/images/smilies/icon_e_smile.gif" alt=":)" title="Smile" /><p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=125">jwoltman</a> — Tue Jun 17, 2008 10:56 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[aha42]]></name></author>
<updated>2008-06-17T12:44:18+01:00</updated>
<published>2008-06-17T12:44:18+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=103&amp;p=307#p307</id>
<link href="https://forum.yubico.com/viewtopic.php?t=103&amp;p=307#p307"/>
<title type="html"><![CDATA[Re: OTP validation cookbook]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=103&amp;p=307#p307"><![CDATA[
Is it a (good?) idea to make a reference implementation of the validation cookbook i the various language currently being hacked in?<br /><br />Any particular server would of course depend on some specific database schema and API for retrieval of key information, but cookbook implementation could be written independent of such with a interface like:<br /><br />ValidationResult YubiKeyValidation.validate(Token t, KeyData kd)<br /><br />So this would be invoked after OTP is decrypted and parsed. KeyData contains information of last OTP received from YubiKey in question.<br /><br />Speaking as a Java programmer, the Java reference cookbook could perhaps fit in the yubico-j library?<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=108">aha42</a> — Tue Jun 17, 2008 12:44 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[patgadget]]></name></author>
<updated>2008-06-16T15:19:19+01:00</updated>
<published>2008-06-16T15:19:19+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=103&amp;p=298#p298</id>
<link href="https://forum.yubico.com/viewtopic.php?t=103&amp;p=298#p298"/>
<title type="html"><![CDATA[Re: OTP validation cookbook]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=103&amp;p=298#p298"><![CDATA[
Step 1.1 Modhex<br /><a href="http://forum.yubico.com/viewtopic.php?f=6&amp;t=96" class="postlink">http://forum.yubico.com/viewtopic.php?f=6&amp;t=96</a><p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=78">patgadget</a> — Mon Jun 16, 2008 3:19 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[patgadget]]></name></author>
<updated>2008-06-16T15:08:08+01:00</updated>
<published>2008-06-16T15:08:08+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=103&amp;p=296#p296</id>
<link href="https://forum.yubico.com/viewtopic.php?t=103&amp;p=296#p296"/>
<title type="html"><![CDATA[Re: OTP validation cookbook]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=103&amp;p=296#p296"><![CDATA[
Hy,<br />I think it would be a nice idea to make a manual that really describe all the step that are require to check a yubikey.<br />because if we add explanation on each step on this forum it will start to be confusing as post come trying to explain this step or this one in more description (the post could be a start thought)<br /><br />You could wait a bit to have question from a lot a person then have a better idea for the FAQ <img src="https://forum.yubico.com/images/smilies/icon_e_wink.gif" alt=";-)" title="Wink" /><br /><br />or make a wiki, but i would make it read only for now (then why call it a wiki <img src="https://forum.yubico.com/images/smilies/icon_e_smile.gif" alt=":-)" title="Smile" /> ) as only maker wright now are mostly answering question and poster (user) asking them. But a least you could easily modify your cookbook as step needs clarification<br /><br />My two cents<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=78">patgadget</a> — Mon Jun 16, 2008 3:08 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[jwoltman]]></name></author>
<updated>2008-06-16T06:57:20+01:00</updated>
<published>2008-06-16T06:57:20+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=103&amp;p=293#p293</id>
<link href="https://forum.yubico.com/viewtopic.php?t=103&amp;p=293#p293"/>
<title type="html"><![CDATA[Re: OTP validation cookbook]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=103&amp;p=293#p293"><![CDATA[
<div class="quotetitle">JakobE wrote:</div><div class="quotecontent"><br /><strong>Step 5: In-session timer validation</strong><br /><br />Each Yubikey has a slightly varying &quot;fingerprint&quot; in terms of timestamp variation. The nominal frequency is 8Hz, but can vary +/- 30% between devices and over temperature.<br /><br />1. For the sake of simplicitly, calculate tstp32 = tstpl + (tstph &lt;&lt; 16)<br /><br />2. When a new session is detected, i.e. lastUseCtr != (useCtr &amp; 0x7fff), set tstpBase = tstp32 and store current time as timeBase<br /><br />3. After the first OTP verification within a session, check (tstp32 - tstpBase) vs. (currentTime - timeBase). This value shall be fairly constant for each individual device.<br /><br />4. Remember that the tstpl/tstph is 24 bits wide and therefore wraps after approx 24 days. An appropriate &quot;fixup&quot; routine will be needed.<br /><br />5. A sophisticated application can store the calculated (expected) frequency for each individual device. At reasonable room temperature bounds (10-40 degrees C), it will stay within +/- 10%.<br /></div><br /><br />First, thanks a <strong>lot</strong> for posting this Jakob, it was very helpful.  I have question about the timing code:  I'm allowing a deviation of 20% in my code before the server denies a key.  Is this reasonable?  When I'm testing the code on my own computer, the yubikey timer gets about that far away from the computer's timer.  Do you have any recommendations for what is acceptable?<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=125">jwoltman</a> — Mon Jun 16, 2008 6:57 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Jakob]]></name></author>
<updated>2008-06-15T21:37:50+01:00</updated>
<published>2008-06-15T21:37:50+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=103&amp;p=281#p281</id>
<link href="https://forum.yubico.com/viewtopic.php?t=103&amp;p=281#p281"/>
<title type="html"><![CDATA[OTP validation cookbook]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=103&amp;p=281#p281"><![CDATA[
Questions regarding how a minimal OTP validation routine should be implemented comes in every now and then. It therefore seems like a good idea to keep a basic &quot;cookbook&quot; here involving the necessary steps involved. <br /><br />&quot;There are may ways to skin a cat&quot; and the same thing apply here. It is somewhat up to each individual implementation to decide which steps are to be included and how the exact implementation is done. <br /><br />I'll try to keep it reasonably brief for clarity reasons. <br /><br /><br /><strong>Step 1: Basic decoding and sanity validation</strong><br /><br />1. Convert the received modhex string into binary<br /><br />2. Split the data in two parts – the last 16 bytes is the OTP part and the first, i.e. len – 16 bytes is the fixed id<br /><br />3. Use the fixed id to look up the AES key for the id in question.  <br /><br />4. Decrypt the 16 bytes (128 bits) using AES-128 decryption<br /><br />5. Calculate a ISO13239 checksum over the 16 bytes and verify that the residual is 0xf0b8. If not, abort<br /><br />6. Check if the 6-byte private ID matches the value in the database. If the private id is not used, ensure that it is set to all zeroes and at verification, verify that all bytes are zero. If it does not match, abort<br /><br />7. If any of the two last stages fail, it is most likely due to an invalid AES key, i.e. the decryption creates garbage.<br /><br /><br /><strong>Step 2: Check for &quot;static OTP&quot; (if used)</strong><br /><br />1. If (useCtr &amp; 0x7fff) == 0x7fff and sessionCtr == 0xff and rnd = 0xffff the OTP is a &quot;static OTP&quot;. If this matches, accept without further checks<br /><br /><br /><strong>Step 3: Basic (simple) counter validation</strong><br /><br />1. Set ctr32 = ((useCtr &amp; 0x7fff) &lt;&lt; 8) + sessionCtr <br /><br />2. Verify that ctr32 &gt; lastCtr32. If not, it is a fair guess that the OTP is subject to a replay<br /><br />3. If successful, store ctr32 in the database to be lastCtr32<br /><br /><br /><strong>Step 4: Optional/alteranative: Detect lost OTPs</strong><br /><br />1. Verify that lastUseCtr &gt; (useCtr &amp; 0x7fff) || (lastUseCtr == (useCtr &amp; 0x7fff) &amp;&amp; lastSessionCtr &gt; sessionCtr). If not, it is a fair guess that the OTP is subject to a replay<br /><br />2. If lastUseCtr == (useCtr &amp; 0x7fff), check that sessionCtr == (lastSessionCtr + 1). If not (at least) one OTP has been lost<br /><br />3. If lastUseCtr != (useCtr &amp; 0x7fff), check that (useCtr &amp; 0x7fff) == (lastUseCtr + 1) and that sessionCtr == 0. If not (at least) one OTP has been lost<br /><br />4. If not failing at step 1, store (useCtr &amp; 0x7fff) as lastUseCtr and sessionCtr as lastSessionCtr<br /><br />5. Depending on policy, accounts may be locked if more than one OTP is lost. Alternatively, the user may be informed by this and decide himself.<br /><br /><br /><strong>Step 5: In-session timer validation</strong><br /><br />Each Yubikey has a slightly varying &quot;fingerprint&quot; in terms of timestamp variation. The nominal frequency is 8Hz, but can vary +/- 30% between devices and over temperature.<br /><br />1. For the sake of simplicitly, calculate tstp32 = tstpl + (tstph &lt;&lt; 16)<br /><br />2. When a new session is detected, i.e. lastUseCtr != (useCtr &amp; 0x7fff), set tstpBase = tstp32 and store current time as timeBase<br /><br />3. After the first OTP verification within a session, check (tstp32 - tstpBase) vs. (currentTime - timeBase). This value shall be fairly constant for each individual device.<br /><br />4. Remember that the tstpl/tstph is 24 bits wide and therefore wraps after approx 24 days. An appropriate &quot;fixup&quot; routine will be needed.<br /><br />5. A sophisticated application can store the calculated (expected) frequency for each individual device. At reasonable room temperature bounds (10-40 degrees C), it will stay within +/- 10%.<br /><br /><br /><br />All feedback is appreciated,<br /><br />Regards,<br /><br />JakobE<br />Hardware- and firmware guy @ Yubico<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=83">Jakob</a> — Sun Jun 15, 2008 9:37 pm</p><hr />
]]></content>
</entry>
</feed>