<?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>Why does the ECC module require the softdevice to be initialised?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19265/why-does-the-ecc-module-require-the-softdevice-to-be-initialised</link><description>I spent some time trying to work out why generating a private/public keypair in my application with the ECC module was failing due to an &amp;#39;internal error&amp;#39; and had to eventually reference my code against the experimental example source code in the nRF5x</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 02 Feb 2017 09:45:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19265/why-does-the-ecc-module-require-the-softdevice-to-be-initialised" /><item><title>RE: Why does the ECC module require the softdevice to be initialised?</title><link>https://devzone.nordicsemi.com/thread/74640?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2017 09:45:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f856d6a-415f-436b-b899-a6cf3ced6aa5</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;So &lt;code&gt;ecc_p256_keypair_gen()&lt;/code&gt; returns NRF_SUCCESS if you call it after &lt;code&gt;SOFTDEVICE_HANDLER_INIT()&lt;/code&gt;, before calling softdevice_enable(), which in turn calls sd_ble_enable?&lt;/p&gt;
&lt;p&gt;I looked through the code in uECC.c and calling &lt;code&gt;ecc_p256_keypair_gen&lt;/code&gt; will result in the following call stack.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ecc_p256_keypair_gen --&amp;gt; uECC_make_key --&amp;gt;uECC_generate_random_int--&amp;gt;g_rng_function 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The g_rng_function is set to &lt;code&gt;nrf_drv_rng_block_rand&lt;/code&gt; in ecc_init() in ecc.c&lt;/p&gt;
&lt;p&gt;I assume that you have called ecc_init before calling ecc_p256_keypair_gen, but If g_rng_function in uECC_generate_random_int does not return then you will get NRF_ERROR_INTERNAL since the return value 0 is propagated up to ecc_p256_keypair_gen. It could be that you need to request the LFCLK and/or HFCLK  before calling ecc_p256_keypair_gen if you have not called SOFTDEVICE_HANDLER_INIT() which configures the clock source for the SD.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why does the ECC module require the softdevice to be initialised?</title><link>https://devzone.nordicsemi.com/thread/74639?ContentTypeID=1</link><pubDate>Wed, 01 Feb 2017 19:18:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7f79e3b-caa2-4723-aa60-b94d9c5e4601</guid><dc:creator>jm_laird</dc:creator><description>&lt;p&gt;nRF52 softdevice 3.0.0 using SDK v12.0.0, calling ecc_p256_keypair_gen() causes the NRF_ERROR_INTERNAL response. If it&amp;#39;s placed after the softdevice handler initiation functions then NRF_SUCCESS is returned.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why does the ECC module require the softdevice to be initialised?</title><link>https://devzone.nordicsemi.com/thread/74638?ContentTypeID=1</link><pubDate>Mon, 30 Jan 2017 12:01:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cce23632-e792-4a51-9b1f-168138e0770f</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Jm_Laird,
Which SDK and SoftDevice version are you using? Which call returned the internal error code?&lt;/p&gt;
&lt;p&gt;As far as I know there is no dependency between the micro-ecc library and the SoftDevice. The &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.2.0/group__nrf__crypto.html?resultof=%22%6e%72%66%5f%63%72%79%70%74%6f%22%20"&gt;nrf_crypto&lt;/a&gt; library, which wraps the micro-ecc library in the SDK, is an independent module that implements SV-calls to the micro_ecc_lib_nrf52.lib that is compiled from the micro-ecc source.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>