<?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=30&amp;t=1425" />

<title>Yubico Forum</title>
<subtitle>...visit our web-store at</subtitle>
<link href="https://forum.yubico.com/index.php" />
<updated>2014-07-28T07:48:59+01:00</updated>

<author><name><![CDATA[Yubico Forum]]></name></author>
<id>https://forum.yubico.com/feed.php?f=30&amp;t=1425</id>
<entry>
<author><name><![CDATA[Klas]]></name></author>
<updated>2014-07-28T07:48:59+01:00</updated>
<published>2014-07-28T07:48:59+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5444#p5444</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5444#p5444"/>
<title type="html"><![CDATA[Re: [SOLVED] ykchalresp: Can not get the same response in py]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5444#p5444"><![CDATA[
Hello,<br /><br />You seem to be using the hmac-lt64 option when programming the YubiKey. When this option is in effect the challenge is limited to 63 bytes, but may be less and any challenge longer than 63 bytes will be truncated to 63.<br />I've verified with a 2.2.3 key and a piece of perl that it behaves correctly with challenges up to 63 bytes. There might be bugs in the yubico-python code, so it'd be good if you could verify with both that and the ykchalresp utility.<br /><br />/klas<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2019">Klas</a> — Mon Jul 28, 2014 7:48 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[corny]]></name></author>
<updated>2014-07-18T10:01:45+01:00</updated>
<published>2014-07-18T10:01:45+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5418#p5418</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5418#p5418"/>
<title type="html"><![CDATA[Re: [SOLVED] ykchalresp: Can not get the same response in py]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5418#p5418"><![CDATA[
Hm, I did some more digging:<br /><br />The Yubikey calculates an HMAC SHA1 with the challenge.<br /><br />So this is roughly my verification code:<br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">&gt;&gt;&gt; hexkey=&quot;7b6b585de517c96560f5bd0db211ea58ba1500ca&quot;<br />&gt;&gt;&gt; import binascii<br />&gt;&gt;&gt; import hashlib<br />&gt;&gt;&gt; import hmac<br />&gt;&gt;&gt; chal_hex=&quot;175ff6a6b675906d748b2a2b74dce6dc2f065685f4a69caa7f65e2167015745f4162f1b508d1eef7f5b319cf4bf3f435daca4e387152005e253e4694e9091781&quot;<br />&gt;&gt;&gt; binascii.hexlify(hmac.new(binascii.unhexlify(hexkey), binascii.unhexlify(chal_hex), hashlib.sha1).digest())<br />'b8a53bf4d40db429029e89bfc5cd6057645b3ea6'</div><br /><br />Indeed the 64 byte response of the python hmac libraray does not match the 64 byte response of the Yubikey.<br />The python HMAC lib and the Yubikey itself get the same responses for 32 byte, but not for 64 byte.<br />Thats bad, but at least I know the reason for this...<br /><br />I tested this on Ubuntu 14.04LTS, with python 2.7.6.<br /><br />Kind regards<br />Cornelius<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2703">corny</a> — Fri Jul 18, 2014 10:01 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[corny]]></name></author>
<updated>2014-07-18T09:40:22+01:00</updated>
<published>2014-07-18T09:40:22+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5417#p5417</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5417#p5417"/>
<title type="html"><![CDATA[Re: [SOLVED] ykchalresp: Can not get the same response in py]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5417#p5417"><![CDATA[
Hi Tom,<br /><br />(Read to the end, before clicking links - I have the error (my error) narrowed down)<br /><br />I am running this python code to initialize the yubikey:<br />    <!-- m --><a class="postlink" href="https://github.com/privacyidea/privacyideaadm/blob/master/privacyideautils/yubikey.py">https://github.com/privacyidea/privacyi ... yubikey.py</a><!-- m --><br /><br />roughlty it does this in MODE_OATH and challenge_response==True:<br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">Cfg = YK.init_config()<br />key = binascii.hexlify(os.urandom(20))<br />Cfg.mode_challenge_response('h:' + key, type=&quot;HMAC&quot;)<br />Cfg.ticket_flag('APPEND_CR', False)<br />Cfg.extended_flag('SERIAL_API_VISIBLE', True)<br />YK.write_config(Cfg, slot=slot)</div><br /><br />which pretty much looks the same to me like this <!-- m --><a class="postlink" href="https://github.com/Yubico/python-yubico/blob/master/examples/configure_nist_test_key">https://github.com/Yubico/python-yubico ... t_test_key</a><!-- m -->:<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">Cfg = YK.init_config()<br />key='h:303132333435363738393a3b3c3d3e3f40414243'<br />fg.mode_challenge_response(key, type='HMAC', variable=True)<br />Cfg.extended_flag('SERIAL_API_VISIBLE', True)<br />YK.write_config(Cfg, slot=slot)</div><br /><br />But still it does not work out for me. The command line tool creates another response, than my python program does...<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">% ykchalresp -2 -H -x 175ff6a6b675906d748b2a2b74dce6dc2f065685f4a69caa7f65e2167015745f4162f1b508d1eef7f5b319cf4bf3f435daca4e387152005e253e4694e9091781<br />2008b987214e073127006e4166ef189242dbf035</div><br /><br />OK, using my initialized key with some very basic python code:<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">cornelius@puckel ~/src/privacyideaadm (git)-&#91;master&#93; % python<br />Python 2.7.6 (default, Mar 22 2014, 22:59:56) <br />&#91;GCC 4.8.2&#93; on linux2<br />Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br />&gt;&gt;&gt; import yubico<br />&gt;&gt;&gt; import sys<br />&gt;&gt;&gt; YK=yubico.find_yubikey()<br />&gt;&gt;&gt; chal_hex=&quot;175ff6a6b675906d748b2a2b74dce6dc2f065685f4a69caa7f65e2167015745f4162f1b508d1eef7f5b319cf4bf3f435daca4e387152005e253e4694e9091781&quot;<br />&gt;&gt;&gt; import binascii<br />&gt;&gt;&gt; chal = binascii.unhexlify(chal_hex)<br />&gt;&gt;&gt; YK.challenge_response(chal, slot=2)<br />&quot; \x08\xb9\x87!N\x071'\x00nAf\xef\x18\x92B\xdb\xf05&quot;<br />&gt;&gt;&gt; binascii.hexlify(YK.challenge_response(chal, slot=2))<br />'2008b987214e073127006e4166ef189242dbf035'<br />&gt;&gt;&gt; <br /></div><br /><br />Well! This looks fine and produces the same response! So now I know the following:<br /><br />1. My initialization is working fine.<br />2. My Yubikey is working fine<br />3. My response verification code has a problem with challenges larger than 32 bytes....<br /><br />Thanks for you patience and help.<br />I will look into this.<br /><br />Kind regards<br />Cornelius<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2703">corny</a> — Fri Jul 18, 2014 9:40 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Tom]]></name></author>
<updated>2014-07-18T07:23:11+01:00</updated>
<published>2014-07-18T07:23:11+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5414#p5414</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5414#p5414"/>
<title type="html"><![CDATA[Re: [SOLVED] ykchalresp: Can not get the same response in py]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5414#p5414"><![CDATA[
use ykchalresp.exe -1 -H -x<br /><br />program the yubikey with the GUI<br /><br />Could you use our Python code <!-- m --><a class="postlink" href="https://github.com/Yubico/python-yubico/blob/master/examples/nist_challenge_response">https://github.com/Yubico/python-yubico ... e_response</a><!-- m --><br /><br />also, what version is your Yubikey firmware?<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2195">Tom</a> — Fri Jul 18, 2014 7:23 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[corny]]></name></author>
<updated>2014-07-14T11:21:45+01:00</updated>
<published>2014-07-14T11:21:45+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5404#p5404</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5404#p5404"/>
<title type="html"><![CDATA[Re: [SOLVED] ykchalresp: Can not get the same response in py]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5404#p5404"><![CDATA[
Hi Tom,<br /><br />this test runs perfectly. But this challenge is &lt;=32bytes.<br /><br />And as soon as I use a challenge &gt;32btes &lt;=64bytes the python code does not produces the same result as the ykchalresp!<br /><br />Kind regards<br />Cornelius<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2703">corny</a> — Mon Jul 14, 2014 11:21 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Tom]]></name></author>
<updated>2014-07-14T10:41:13+01:00</updated>
<published>2014-07-14T10:41:13+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5403#p5403</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5403#p5403"/>
<title type="html"><![CDATA[Re: [SOLVED] ykchalresp: Can not get the same response in py]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5403#p5403"><![CDATA[
can you use KATs (Known Answer Tests) NIST PUB 198 A.2 test vectors?<br /><br /><!-- m --><a class="postlink" href="http://opensource.yubico.com/yubikey-personalization/ykchalresp.1.html">http://opensource.yubico.com/yubikey-pe ... esp.1.html</a><!-- m --><p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2195">Tom</a> — Mon Jul 14, 2014 10:41 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[corny]]></name></author>
<updated>2014-07-14T09:54:31+01:00</updated>
<published>2014-07-14T09:54:31+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5402#p5402</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5402#p5402"/>
<title type="html"><![CDATA[Re: [SOLVED] ykchalresp: Can not get the same response in py]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5402#p5402"><![CDATA[
Hi Tom,<br /><br />yes, I read this, but when I use 64bytes, it does not work - while it works fine with 32bytes.<br />I am willing to provide you any additional information!<br /><br />Kind regards<br />Cornelius<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2703">corny</a> — Mon Jul 14, 2014 9:54 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Tom]]></name></author>
<updated>2014-07-14T09:01:02+01:00</updated>
<published>2014-07-14T09:01:02+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5399#p5399</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5399#p5399"/>
<title type="html"><![CDATA[Re: [SOLVED] ykchalresp: Can not get the same response in py]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5399#p5399"><![CDATA[
ykpersonalize -2 -ochal-resp -ochal-hmac -ohmac-lt64 -a 303132333435363738393a3b3c3d3e3f40414243<br /><br /><strong>HMAC-SHA1 challenge-response </strong><br />This method allows a challenge of up to 64 bytes (512 bits) to be <br />hashed using the HMAC-SHA1 algorithm with a 20-byte (160 bits) <br />secret<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2195">Tom</a> — Mon Jul 14, 2014 9:01 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[corny]]></name></author>
<updated>2014-07-13T07:33:56+01:00</updated>
<published>2014-07-13T07:33:56+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5397#p5397</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5397#p5397"/>
<title type="html"><![CDATA[[SOLVED] Re: ykchalresp: Can not get the same response in py]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5397#p5397"><![CDATA[
So tell me!<br /><br />Why does 32byte challenges work although the yubikey claims to process 64 byte challenges?<br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">cornelius@puckel ~/src/python-yubico/examples (git)-&#91;master&#93; % python<br />Python 2.7.6 (default, Mar 22 2014, 22:59:56) <br />&#91;GCC 4.8.2&#93; on linux2<br />Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br />&gt;&gt;&gt; import hmac<br />&gt;&gt;&gt; import binascii<br />&gt;&gt;&gt; import hashlib<br />&gt;&gt;&gt; import os<br />&gt;&gt;&gt; key = &quot;a60f076ca60e6d966f3bdcdc96f5e94c3c8efc32&quot;<br />&gt;&gt;&gt; chal = os.urandom(32)<br />&gt;&gt;&gt; print binascii.hexlify(chal)<br />d1835d598bc20c4ce8312ba94f046a015f7a70c48631b88f29922f1183e77873<br />&gt;&gt;&gt; hmac.new(binascii.unhexlify(key), chal, hashlib.sha1).hexdigest()<br />'c7f7a081d06a738f913dce36b538091adc6d2e93'<br />&gt;&gt;&gt; quit()<br />cornelius@puckel ~/src/python-yubico/examples (git)-&#91;master&#93; % ykchalresp -2 -x d1835d598bc20c4ce8312ba94f046a015f7a70c48631b88f29922f1183e77873<br />c7f7a081d06a738f913dce36b538091adc6d2e93<br /></div><br /><br />So I need to be content with 32 bytes.<br /><br />Kind regards<br />Cornelius<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2703">corny</a> — Sun Jul 13, 2014 7:33 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[corny]]></name></author>
<updated>2014-07-13T07:34:51+01:00</updated>
<published>2014-07-12T20:44:45+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5396#p5396</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5396#p5396"/>
<title type="html"><![CDATA[[SOLVED] ykchalresp: Can not get the same response in python]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1425&amp;p=5396#p5396"><![CDATA[
Hi,<br />I am playing around with the yubikey in challenge response and try to reproduce it in python.<br /><br />I initialize the yubikey like this:<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent"># ykpersonalize -2 -ochal-resp -ochal-hmac -ohmac-lt64 -oserial-api-visible<br />Firmware version 2.2.3 Touch level 1795 Program sequence 3<br /><br />Passphrase to create AES key: lsjdkflksdjf<br />Configuration data to be written to key configuration 2:<br /><br />fixed: m:<br />uid: n/a/<br />key: h:a60f076ca60e6d966f3bdcdc96f5e94c3c8efc32<br />acc_code: h:000000000000<br />OATH IMF: h:0<br />ticket_flags: CHAL_RESP<br />config_flags: CHAL_HMAC|HMAC_LT64<br />extended_flags: SERIAL_API_VISIBLE<br /></div><br /><br />I take it, that a60f076ca60e6d966f3bdcdc96f5e94c3c8efc32 is the stored hmac key.<br /><br />Now I run:<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">ykchalresp -2 -x 57642f9efa71d159181c0f3bbc93a84ccb8d378782e09eae21695395b441f5a22a3f35d46ee596fbab39e38d3fc0c4841780996fd272845af4d92cc31bf5134a<br />cef9198f3a2d9a378289096da646b7c165090d60<br /></div><br /><br />Simuliation this in python I get another response:<br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">import hmac<br />import binascii<br />import hashlib<br />key = &quot;a60f076ca60e6d966f3bdcdc96f5e94c3c8efc32&quot;<br />chal = &quot;57642f9efa71d159181c0f3bbc93a84ccb8d378782e09eae21695395b441f5a22a3f35d46ee596fbab39e38d3fc0c4841780996fd272845af4d92cc31bf5134a&quot;<br />hmac.new(binascii.unhexlify(key), binascii.unhexlify(chal), hashlib.sha1).hexdigest()<br />'d8352dc4a5ce33639801fb2e2fa87444dbcae55e'<br /></div><br /><br />What am I missing here?<br /><br />Thanks a lot and kind regards<br />Cornelius<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2703">corny</a> — Sat Jul 12, 2014 8:44 pm</p><hr />
]]></content>
</entry>
</feed>