<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66899/nrf52840-nrf-connect-sdk-zephyr-random-number-generation</link><description>Hi, 
 Looking for some guidance on how to use the &amp;#39;cryptographically secure random number generator&amp;#39; in a Zephyr/nRF Connect SDK application on an 52840 
 Is this a supported combination? I found some older devzone posts about this being in development</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Dec 2020 10:54:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66899/nrf52840-nrf-connect-sdk-zephyr-random-number-generation" /><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/285794?ContentTypeID=1</link><pubDate>Fri, 18 Dec 2020 10:54:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fc3b285-ad70-4507-9bfc-2486e9114d46</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry, I misunderstood your question and answered about the RNG in CryptoCell, not the RNG peripheral that all the nRF5 SoCs have.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s correct that the RNG is also a TRNG (true random number generator), but the TRNG and RNG are implemented differently. The RNG peripheral isn&amp;#39;t implemented according to the same NIST standards as the CryptoCell RNG is. The RNG peripheral is used by the BLE stack, and used as the only entropy source in other nRF52 SoCs.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/284735?ContentTypeID=1</link><pubDate>Mon, 14 Dec 2020 10:11:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ad39dd0-5916-47b6-8328-2c875f746303</guid><dc:creator>basvkesteren</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;Thanks! This _almost_ answers my last question &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I get the link between the PRNG and TRNG, but how does the RNG (&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Frng.html&amp;amp;cp=4_0_0_5_20"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Frng.html&amp;amp;cp=4_0_0_5_20&lt;/a&gt;) fit into all this. Both the TRNG and RNG are &amp;#39;true random&amp;#39;, according to the datasheet, and &amp;#39;suitable for cryptographic purposes&amp;#39;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/284730?ContentTypeID=1</link><pubDate>Mon, 14 Dec 2020 10:04:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae61dfb3-91b5-4487-a959-42805d7fa876</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Great to hear that you managed to get it to work, and thank you for explaining it here so others can see it!&lt;/p&gt;
&lt;p&gt;Regarding your question about TRNG and RNG, TRNG is used to seed RNG, as a form of PRBS (p&lt;span&gt;seudorandom binary sequence). If you take a look at&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/cryptocell.html?cp=2_0_0_5_0"&gt;this link&lt;/a&gt;&amp;nbsp;you&amp;#39;ll find the following:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;True random number generator (TRNG) compliant with NIST 800-90B, AIS-31, and FIPS 140-2&lt;/li&gt;
&lt;li&gt;Pseudorandom number generator (PRNG) using underlying AES engine compliant with NIST 800-90A&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So to conclude, PRNG uses TRNG for seeding, as well as AES as a part of the process to make pseudorandom numbers, and then regularly reseeds from TRNG.&lt;/p&gt;
&lt;p&gt;Hope this answers your question!&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/284566?ContentTypeID=1</link><pubDate>Fri, 11 Dec 2020 14:22:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6e4c88e-60a5-4f2a-831a-f58061f6533a</guid><dc:creator>basvkesteren</dc:creator><description>&lt;p&gt;To update (and close) this ticket: I now have correctly behaving random numbers.&lt;/p&gt;
&lt;p&gt;I was using nrf_cc310_platform_entropy_get(), which works, but is rather slow. Getting 32 random bytes took close to 100ms, way too much thus breaking my protocol... The correct way (as far as i know) is to use the zephyr entropy driver (the one I could not get to work earlier).&lt;/p&gt;
&lt;p&gt;Using ncs 1.4.0, in my prj.conf I have the following relevant settings:&lt;/p&gt;
&lt;div style="background-color:#1e1e1e;color:#d4d4d4;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_ENTROPY_GENERATOR&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_ENTROPY_NRF5_THR_POOL_SIZE&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;=64&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;CONFIG_ENTROPY_NRF5_THR_THRESHOLD&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;=32&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This uses the RNG perhiperal. The pool (with size as defined above) will be filled in the background. When using entropy with entropy_get_entropy(), you read bytes from this pool. When the pool drops below the configured threshold (as defined above) it starts to fill back up.&lt;/p&gt;
&lt;p&gt;This avoids the slowness I was experiencing. I need blocks of 32 bytes, therefore I&amp;#39;ve configured the pool-size to be twice that, and the threshold to be exactly that. Thus, I should always have atleast one block of random bytes available.&lt;/p&gt;
&lt;p&gt;What I&amp;#39;m not quite sure about is how the cryptocell&amp;#39;s RNG perhiperals fit into this... Both the cryptocell&amp;#39;s TRNG and the RNG provide true randomness, according to the datasheet. Duplicated functionality?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/274983?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2020 07:12:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:054fa462-54b5-4ba8-829d-6e1a59a953d5</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Hayden,&lt;/p&gt;
&lt;p&gt;As of now, there&amp;#39;s only one example that generates random numbers, namely the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/nrf9160/secure_services/README.html"&gt;Secure Services&lt;/a&gt;&amp;nbsp;example. However, this example is for the nRF9160 DK and uses the Secure Partition Manager to get random numbers.&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re still experiencing problems with generating random numbers, please open a new support ticket with your problem.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/274552?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 09:41:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1449de3-7a1b-4e10-a4b6-9d2408a6d12e</guid><dc:creator>Hayden Ball</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/marte.m"&gt;Marte Myrvold&lt;/a&gt; is there a sample showing how to generate a random number using the CC310 entropy driver, please?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve set `CONFIG_ENTROPY_GENERATOR` and `CONFIG_CC310_BACKEND`, but calls to `sys_rand_get` fail.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/274389?ContentTypeID=1</link><pubDate>Mon, 12 Oct 2020 14:52:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c623775c-f7c1-4ead-9547-8578a989fb42</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Bastiaan,&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t give you an exact date for when it will be released, but you can contact your regional sales manager for roadmap details. You can also follow the development on&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf"&gt;our github&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/274236?ContentTypeID=1</link><pubDate>Mon, 12 Oct 2020 09:13:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eaaaa01e-09dc-4937-8366-35af6a79fd20</guid><dc:creator>basvkesteren</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;Thanks, I have a working setup now: just performed my first SHA-256 hash&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&amp;nbsp;When is NCS 1.4.0 expected?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;-Bastiaan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/274227?ContentTypeID=1</link><pubDate>Mon, 12 Oct 2020 08:43:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee1da826-51ce-44ac-a240-cc5ee720984f</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Bastiaan,&lt;/p&gt;
&lt;p&gt;Great to hear that you have random numbers now!&lt;/p&gt;
&lt;p&gt;The fix for that issue will come in NCS v1.4.0, so&amp;nbsp;unfortunately you will have to use command line for now. There&amp;#39;s a guide on how to do this&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_programming.html#building-on-the-command-line"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/274098?ContentTypeID=1</link><pubDate>Fri, 09 Oct 2020 15:42:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74739b0a-1566-4b9d-b08e-80fe6291efc9</guid><dc:creator>basvkesteren</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;Yay, I&amp;nbsp; have random numbers. Apparently i went into the wrong direction when using the Zephyr entropy stuff, that didn&amp;#39;t work. But calling nrf_cc310_platform_init() and then using nrf_cc310_platform_entropy_get() directly gives me random numbers, so that&amp;#39;s good enough for me &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Next step: encryption.. When I enable CONFIG_NORDIC_SECURITY_BACKEND I run into a compilation trouble, seems to be an existing problem:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/63781/ncs1-3-0----mbedtls_config_file----include-expects-filename-or"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/63781/ncs1-3-0----mbedtls_config_file----include-expects-filename-or&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I already replied there, but; is there a fix for this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/273952?ContentTypeID=1</link><pubDate>Fri, 09 Oct 2020 08:41:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b5f5b3e-7893-4e7e-a535-ed0ef8af186b</guid><dc:creator>basvkesteren</dc:creator><description>&lt;p&gt;Hi Marte,&lt;/p&gt;
&lt;p&gt;Thanks! But, one more question, though...&lt;/p&gt;
&lt;p&gt;Can you quide me through how to enable/use this? I&amp;#39;m a newbie to both zephyr and it&amp;#39;s build-system, so I&amp;#39;m probably missing a lot of stuff that should be obvious here...&lt;/p&gt;
&lt;p&gt;The API documentation says &amp;quot;When used on nRF52840, the entropy_cc310 driver gathers entropy by using the CC310 hardware through the &lt;a class="reference external" title="(in nrfxlib v1.3.1)" href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.1/nrfxlib/crypto/doc/nrf_cc310_platform.html#nrf-cc310-platform-readme"&gt;&lt;span&gt;nrf_cc310_platform library&lt;/span&gt;&lt;/a&gt;.&amp;quot;. That seems to be the NRF_CC310_PLATFORM config setting, which says &amp;#39;to use, link with nrfxlib_crypto in CMAKE&amp;#39;. How to i do that?&lt;/p&gt;
&lt;p&gt;I did try to implement some entropy-code (with zephyr\samples\drivers\entropy as an example), but sofar I can&amp;#39;t get that to work...&lt;/p&gt;
&lt;p&gt;device_get_binding(&amp;quot;HW_CC310_0&amp;quot;);&lt;/p&gt;
&lt;p&gt;cannot find the device: The device exists, but the binding fails because dev-&amp;gt;driver_api is null in z_impl_device_get_binding&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 nRF Connect SDK/Zephyr random number generation</title><link>https://devzone.nordicsemi.com/thread/273922?ContentTypeID=1</link><pubDate>Fri, 09 Oct 2020 06:38:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1dc23163-896a-4bb4-8190-d105364e8bc6</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Bastiaan,&lt;/p&gt;
&lt;p&gt;You can use&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/drivers/entropy_cc310.html"&gt;the CC310 entropy driver&lt;/a&gt;&amp;nbsp;(&lt;span&gt;entropy_cc310&lt;/span&gt;) to generate random numbers.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>