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

<title>Yubico Forum</title>
<subtitle>...visit our web-store at</subtitle>
<link href="https://forum.yubico.com/index.php" />
<updated>2017-12-29T11:58:42+01:00</updated>

<author><name><![CDATA[Yubico Forum]]></name></author>
<id>https://forum.yubico.com/feed.php?f=35&amp;t=2519</id>
<entry>
<author><name><![CDATA[fhenneke]]></name></author>
<updated>2017-12-29T11:58:42+01:00</updated>
<published>2017-12-29T11:58:42+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=2519&amp;p=10079#p10079</id>
<link href="https://forum.yubico.com/viewtopic.php?t=2519&amp;p=10079#p10079"/>
<title type="html"><![CDATA[Re: Reading random bytes fails on YK 4, but works on YK NEO?]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=2519&amp;p=10079#p10079"><![CDATA[
Since this discovery really surprised me, I decided to dig deeper. The OpenPGP applet on the YubiKey with which the gpg-connect-agent communicates announces its support for random number generation in the &quot;Extended Capabilities&quot; bytes (see <a href="https://gnupg.org/ftp/specs/OpenPGP-smart-card-application-2.1.pdf" class="postlink">OpenPGP spec, Section 4.3.3.5</a>). The second-highest bit in the first byte is 1 if the YubiKey supports the GET CHALLENGE command, which is what gpg-connect-agent seems to use when you run scd random XX. The third and fourth byte encode the maximum length supported for such a request. <br /><br />I extracted the extended capabilities bytes for my YK 4n and YK Neo:<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">&#91;0xF0, 0x00, 0x00, 0xFF, 0x04, 0xC0, 0x00, 0xFF, 0x00, 0xFF&#93; (YK Neo)<br />&#91;0x3C, 0x00, 0x00, 0x00, 0x04, 0xC0, 0x00, 0xFF, 0x00, 0xFF&#93; (YK 4n)<br /></div><br />As you can see, the second-highest bit of the first byte is set for the YK Neo and it supports GET CHALLENGE requests for up to 255 bytes at a time. The YK 4n (and most likely the 4 as well) announces that it does not support GET CHALLENGE. That means that it is realistically impossible to retrieve random numbers from the OpenPGP applet on the YK 4, barring crazy techniques such as harvesting entropy from generated keys.<br /><br />An alternative could be to use the PIV applet, which can generate random challenges via the GENERAL AUTHENTICATE command (<a href="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-73-4.pdf" class="postlink">PIV spec, Section A.1</a>). The downside is that you can apparently only generate 8 random bytes per request and may have to have PIV certificates present on the YK (not sure about the latter, as I can't test it atm).<br /><br />Example invocation of piv-tool (the last 8 bytes of the response are random):<br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">$ piv-tool --send-apdu 00:87:00:9B:04:7C:02:81:00:00<br />Using reader with a card: Yubico Yubikey 4 OTP+U2F+CCID 00 00<br />Sending: 00 87 00 9B 04 7C 02 81 00 00 <br />Received (SW1=0x90, SW2=0x00):<br />7C 0A 81 08 9A 8B F2 A1 5F 54 58 72 |......._TXr<br /></div><p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=5026">fhenneke</a> — Fri Dec 29, 2017 11:58 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[tbaker]]></name></author>
<updated>2017-12-19T23:05:36+01:00</updated>
<published>2017-12-19T23:05:36+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=2519&amp;p=10075#p10075</id>
<link href="https://forum.yubico.com/viewtopic.php?t=2519&amp;p=10075#p10075"/>
<title type="html"><![CDATA[Re: Reading random bytes fails on YK 4, but works on YK NEO?]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=2519&amp;p=10075#p10075"><![CDATA[
I am seeing the same thing.  scd random fails with the Yubikey 4.<br /><br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">$ echo scd random 2048 | gpg-connect-agent<br />ERR 100663404 Card error &lt;SCD&gt;<br /></div><br /><br />The above works fine with the Yubico Neo.  Is there a way to get random bytes from the Yubikey 4?  I'd prefer to buy just one key for all my usecases.<p>Statistics: Posted by <a href="https://forum.yubico.com/memberlist.php?mode=viewprofile&amp;u=5021">tbaker</a> — Tue Dec 19, 2017 11:05 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[lhdnQDLd6U6CTbQwYcJb]]></name></author>
<updated>2017-01-08T22:59:09+01:00</updated>
<published>2017-01-08T22:59:09+01:00</published>
<id>https://forum.yubico.com/viewtopic.php?t=2519&amp;p=9257#p9257</id>
<link href="https://forum.yubico.com/viewtopic.php?t=2519&amp;p=9257#p9257"/>
<title type="html"><![CDATA[Reading random bytes fails on YK 4, but works on YK NEO?]]></title>

<content type="html" xml:base="https://forum.yubico.com/viewtopic.php?t=2519&amp;p=9257#p9257"><![CDATA[
<div class="codetitle"><b>Code:</b></div><div class="codecontent">$ gpg-connect-agent<br />&gt; scd random 32<br />ERR 100663404 Card error &lt;SCD&gt;</div><br /><br />This scd command works correctly on my three NEOs, but fails on my 4s. Is it not a supported feature?<br /><br />How can I read random bytes from the Yubikey 4?<br /><br />Thank you for your help <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=3215">lhdnQDLd6U6CTbQwYcJb</a> — Sun Jan 08, 2017 10:59 pm</p><hr />
]]></content>
</entry>
</feed>