<?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>How to encrypt data before storing to flash without exposing the encryption key?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/98714/how-to-encrypt-data-before-storing-to-flash-without-exposing-the-encryption-key</link><description>I&amp;#39;m using nrf52840 and NVS module to store some data samples, I need these samples to be encrypted, How can I achieve that? Where to store the key securely?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 15 Apr 2023 17:42:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/98714/how-to-encrypt-data-before-storing-to-flash-without-exposing-the-encryption-key" /><item><title>RE: How to encrypt data before storing to flash without exposing the encryption key?</title><link>https://devzone.nordicsemi.com/thread/420617?ContentTypeID=1</link><pubDate>Sat, 15 Apr 2023 17:42:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8f318a2-7327-45c5-a914-d41a66ed2ecf</guid><dc:creator>ahmedwahdan</dc:creator><description>&lt;p&gt;You are right. The error I got because I tried to use the bootloader example as standalone not as a sub image.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to encrypt data before storing to flash without exposing the encryption key?</title><link>https://devzone.nordicsemi.com/thread/420610?ContentTypeID=1</link><pubDate>Sat, 15 Apr 2023 14:14:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e16d29b8-147f-4d52-aeff-9c2ba9c46019</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The flash layout is generated by the partition manager. This works out of the box unless you neeed to tailor it, though.&lt;/p&gt;
&lt;p&gt;Regarding example, the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/keys/random_hw_unique_key/README.html"&gt;Hardware unique key sample&lt;/a&gt;&amp;nbsp;includes the immutable bootloader as a sub image (as it has&amp;nbsp;CONFIG_SECURE_BOOT=y). So this demonstrates everything out of the box. If you need to learn more about the bootloader architecture in the nRF Connect SDK you can refer to &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/app_dev/bootloaders_and_dfu/index.html"&gt;Bootloaders and Device Firmware Updates&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to encrypt data before storing to flash without exposing the encryption key?</title><link>https://devzone.nordicsemi.com/thread/420595?ContentTypeID=1</link><pubDate>Sat, 15 Apr 2023 04:23:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:909e5697-8b83-4ae8-a256-ec1eb53f3229</guid><dc:creator>ahmedwahdan</dc:creator><description>&lt;p&gt;I tried the example &amp;quot;bootloader&amp;quot; but it seems the slots are not defined (I&amp;#39;m still trying to understand the process here)&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;S0 and S1 are set to 0xFFFFFFFF and the example keep restarting due to accessing invalid memory address.&lt;/p&gt;
&lt;p&gt;Should I add something to the example?&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1681532578412v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to encrypt data before storing to flash without exposing the encryption key?</title><link>https://devzone.nordicsemi.com/thread/420586?ContentTypeID=1</link><pubDate>Fri, 14 Apr 2023 21:24:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb92564a-3f9a-46cb-b0fe-413b190c0046</guid><dc:creator>ahmedwahdan</dc:creator><description>&lt;p&gt;Thanks Einar.&lt;br /&gt;&amp;quot;&lt;span&gt;By letting the immutable bootloader load the key, and then prevent&amp;nbsp;further read access to the flash page, the key is not accessible to the application.&amp;quot; This can be effective for internal flash, but for external flash this wouldn&amp;#39;t be effective, as external flash can be directly accesses(Hacked externally), right?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Any examples for implementing the immutable bootloader with the hardware unique key?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to encrypt data before storing to flash without exposing the encryption key?</title><link>https://devzone.nordicsemi.com/thread/420507?ContentTypeID=1</link><pubDate>Fri, 14 Apr 2023 12:58:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e9ef119-4f94-4d83-890b-fb8ce648afd9</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The nRF52840 does not have a KMU, but it is possible lo push a key to cryptocell that is never exposed, but can be used to derive other keys. This will stay in volatile memory inside CrytpoCell, so it needs to be loaded at every boot, though. By letting the immutable bootloader load the key, and then prevent&amp;nbsp;further read access to the flash page, the key is not accessible to the application. See the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/keys/hw_unique_key/README.html"&gt;Hardware unique key&lt;/a&gt;&amp;nbsp;sample.&lt;/p&gt;
&lt;p&gt;With this, you can use the derived key to encrypt the data before storing to flash, and decrypt it after&amp;nbsp;retreaving&amp;nbsp;it. The derived key that you use to encrypt/decrypt will be accessible when you have&amp;nbsp;derived it before you wipe it from memory, but the attack window is minimized.&lt;/p&gt;
&lt;p&gt;To get a higher level of security you would need a form of security by separation, which is provided by TrustZone and TF-M in the nRF5340, for instance, but that is not possible on the nF52840.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>