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

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

<author><name><![CDATA[Yubico Forum]]></name></author>
<id>https://forum.yubico.com/feed.php?f=16&amp;t=1309</id>
<entry>
<author><name><![CDATA[Klas]]></name></author>
<updated>2014-02-04T08:19:40+01:00</updated>
<published>2014-02-04T08:19:40+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4915#p4915</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4915#p4915"/>
<title type="html"><![CDATA[Re: HMAC-SHA1 verification with C#]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4915#p4915"><![CDATA[
Hello,<br /><br />Yes, you need a buffer of 40 bytes, and for the reasons:<br />Each feature report packet is 8 bytes, of which 7 bytes is payload, which means that it should be enough with 32 bytes buffer for hmac-sha1, but: there is a two byte crc as well, which takes us into the next packet as well, so 40 bytes is needed for the response buffer.<br /><br />Maybe this should be hidden from you by the library, but it isn't..<br /><br />/klas<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2019">Klas</a> — Tue Feb 04, 2014 8:19 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[ChainReaktion]]></name></author>
<updated>2014-02-03T17:01:23+01:00</updated>
<published>2014-02-03T17:01:23+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4911#p4911</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4911#p4911"/>
<title type="html"><![CDATA[Re: HMAC-SHA1 verification with C#]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4911#p4911"><![CDATA[
So I just dug into this a bit deeper and I think I found the issue. In ykchalresp.c, the response buffer is set to 64 bytes in length. Making this change in the C# invocation causes the entire response to get stuffed into the first 20 bytes of the 64 byte buffer. I'm not sure whether or not this is a bug (maybe it's a consequence of the yubikey's 64 byte buffer?), so I'd appreciate any input on why this is necessary.<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2797">ChainReaktion</a> — Mon Feb 03, 2014 5:01 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[ChainReaktion]]></name></author>
<updated>2014-02-03T16:49:03+01:00</updated>
<published>2014-02-03T16:49:03+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4910#p4910</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4910#p4910"/>
<title type="html"><![CDATA[Re: HMAC-SHA1 verification with C#]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4910#p4910"><![CDATA[
Good thought, I just checked and using the prebuilt binary the last 6 bytes are filled in properly. This strongly implies that I'm invoking the method improperly. I've declared the ykpers method as:<br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent"> &#91;DllImport(&quot;libykpers-1-1.dll&quot;, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)&#93;<br />        public static extern int yk_challenge_response(IntPtr yk, byte yk_cmd, int may_block, uint challenge_len, byte&#91;&#93; challenge, uint response_len, byte&#91;&#93; response);</div><br /><br />then calling it with <br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">YubiWrapper.yk_challenge_response(yk, YubiWrapper.SLOT_CHAL_HMAC2, 1, 64, m_challenge, 20, m_response);</div><br /><br />does that look reasonable to you? I'll keep digging to see what I'm doing wrong. Thanks!<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2797">ChainReaktion</a> — Mon Feb 03, 2014 4:49 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Klas]]></name></author>
<updated>2014-02-03T10:02:47+01:00</updated>
<published>2014-02-03T10:02:47+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4908#p4908</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4908#p4908"/>
<title type="html"><![CDATA[Re: HMAC-SHA1 verification with C#]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4908#p4908"><![CDATA[
Hello,<br /><br />Do you get the same behaviour using the ykchalresp binary shipped with ykpers?<br />I'm not directly familiar with the PInvoke methods, but how are you invoking the yk_challenge_response() method?<br /><br />/klas<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2019">Klas</a> — Mon Feb 03, 2014 10:02 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[ChainReaktion]]></name></author>
<updated>2014-02-02T23:37:25+01:00</updated>
<published>2014-02-02T23:37:25+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4903#p4903</id>
<link href="https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4903#p4903"/>
<title type="html"><![CDATA[HMAC-SHA1 verification with C#]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=1309&amp;p=4903#p4903"><![CDATA[
I'm trying to do something similar to this comment: <!-- l --><a class="postlink-local" href="http://forum.yubico.com/viewtopic.php?f=16&amp;t=1078">viewtopic.php?f=16&amp;t=1078</a><!-- l -->. I'm writing c# code to send a challenge to the yubikey and verify the response. I'm running the challenge through the System.Cryptography.HMACSHA1 class and comparing the response to the yubikey's output. I've configured the yubikey for a fixed 64 byte challenge to simplify things and it's almost working. The responses are identical except for the last 6 bytes from the yubikey, which are always 0x00. I'm calling the yubikey via the yk_challenge_response method of the ykpers library through PInvoke. Is there any reason this could be the desired behavior? I've looked over the yubikey-personalization code and I can't find any likely culprits. Thanks!<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2797">ChainReaktion</a> — Sun Feb 02, 2014 11:37 pm</p><hr />
]]></content>
</entry>
</feed>