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

<title>Yubico Forum</title>
<subtitle>...visit our web-store at</subtitle>
<link href="https://forum.yubico.com/index.php" />
<updated>2008-06-02T08:51:08+01:00</updated>

<author><name><![CDATA[Yubico Forum]]></name></author>
<id>https://forum.yubico.com/feed.php?f=3&amp;t=72</id>
<entry>
<author><name><![CDATA[Simon]]></name></author>
<updated>2008-06-02T08:51:08+01:00</updated>
<published>2008-06-02T08:51:08+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=72&amp;p=144#p144</id>
<link href="https://forum.yubico.com/viewtopic.php?t=72&amp;p=144#p144"/>
<title type="html"><![CDATA[Re: How to use HMAC verification]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=72&amp;p=144#p144"><![CDATA[
Wow, thanks for providing this code.  Integrating this into Auth_Yubico would solve one of the open issues.  Do you have the time to prepare a patch for the yubico-php code? See:<br /><br /><!-- m --><a class="postlink" href="http://code.google.com/p/php-yubico/source/browse/trunk/Yubico.php">http://code.google.com/p/php-yubico/sou ... Yubico.php</a><!-- m --><br /><br />The reason for failed signature validation could be because of URL parameter ordering issues, or possibly URI encoding of non-URI alphabetical characters.  The latter would only be triggered in a few cases, so that may explain it.<br /><br />/Simon<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=2">Simon</a> — Mon Jun 02, 2008 8:51 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[vrillusions]]></name></author>
<updated>2008-05-31T10:09:53+01:00</updated>
<published>2008-05-31T10:09:53+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=72&amp;p=128#p128</id>
<link href="https://forum.yubico.com/viewtopic.php?t=72&amp;p=128#p128"/>
<title type="html"><![CDATA[Re: How to use HMAC verification]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=72&amp;p=128#p128"><![CDATA[
looked at it some more and solved the problem.  The api key you get when you request it is base64 encoded.  You need to decode it first before perfoming hmac.  After I did that it worked just fine.<br /><br />The attached file is a proof of concept that creates a signature on sending and verifies the response.  I made it in php since I know that the most.  I heavily commented it so it shouldn't be too difficult to port to other languages.  Keep in mind this is a proof of concept script only.  I'm doing no real sanitizing of input and so there's the chance this script is susceptible to XSS in its current form.<br /><br />You'll need to enter your own values for the api id and key that you get when you request it.<br /><br />I have observed a bug where I'll get the BAD_SIGNATURE response on occasion.  It's sporadic and submitting a new OTP it will usually go away.  This could be a problem with this implementation or on the server end or somewhere else.  Since testing this I've never had a bad signature in the response though.<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=90">vrillusions</a> — Sat May 31, 2008 10:09 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[vrillusions]]></name></author>
<updated>2008-05-31T02:19:58+01:00</updated>
<published>2008-05-31T02:19:58+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=72&amp;p=127#p127</id>
<link href="https://forum.yubico.com/viewtopic.php?t=72&amp;p=127#p127"/>
<title type="html"><![CDATA[How to use HMAC verification]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=72&amp;p=127#p127"><![CDATA[
Hi I just got got the yubikey and verifies fine when I do the api test.  I wanted to get hmac signatures working but I'm not getting it to work, the is always &quot;BAD_SIGNATURE&quot;<br /><br />I am using php5 to do this.  Take the following code as an example (api id, api key, and otp are fictional here)<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">&lt;?php<br />$apiKey = 'dksh3icnsle';<br />$message = 'id=1&amp;otp=ddkwn3kdlsh3kglskeh3kld';<br />$signature = hash_hmac('sha1', $message, $apiKey, TRUE);<br />$signature = base64_encode($signature);<br />$url = 'http://api.yubico.com/wsapi/verify?'.$message.'&amp;h='.$signature'<br />// $url becomes http://api.yubico.com/wsapi/verify?id=1&amp;otp=ddkwn3kdlsh3kglskeh3kld&amp;h=ODK20DHD92LSHGKJLSL3KSL<br />$ch = curl_init($url);<br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);<br />$result = curl_exec($ch);<br />curl_close($ch);<br />echo $result;<br /></div><br /><br />The result would have an h and t value and status would be BAD_SIGNATURE<br /><br />So I registered for an api key and id.  I hash id and otp values with my api key (the TRUE at the end returns the raw byte value, I've tried using the hexadecimal representation as well), base64 encode it, and place it at the end of the call.  Is there a step I'm missing somewhere?<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=90">vrillusions</a> — Sat May 31, 2008 2:19 am</p><hr />
]]></content>
</entry>
</feed>