<?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>Problem with FW encryption</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110344/problem-with-fw-encryption</link><description>Hi i am trying to get fw encryption to work for my dfu with mcuboot for nRF9160DK. 
 I have created a child_image folder with a mcuboot.conf where i have put: 
 
 
 and then i have generated keys with: 
 
 
 i put the result from edcsa_public_key.c in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 19 Apr 2024 08:33:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110344/problem-with-fw-encryption" /><item><title>RE: Problem with FW encryption</title><link>https://devzone.nordicsemi.com/thread/479627?ContentTypeID=1</link><pubDate>Fri, 19 Apr 2024 08:33:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01848ad3-b89b-4b2f-9660-b182da26719c</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Happy to hear that you found a solution for building the firmware.&lt;/p&gt;
&lt;p&gt;What I believe is missing is that you&amp;#39;ve either not signed the new firmware with the same keys (i.e the bootloader can&amp;#39;t validate the new image), or that you&amp;#39;ve not uploaded the correct update image. Could you state what image you&amp;#39;ve uploaded as image update?&lt;/p&gt;
&lt;p&gt;I also recommend that you have a closer look at&amp;nbsp;&lt;a href="https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/bootloader_samples/keys_and_signatures"&gt;https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/bootloader_samples/keys_and_signatures &lt;/a&gt;and&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/"&gt;https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/&lt;/a&gt;&amp;nbsp;(more specifically the lessons and exercises regarding keys). I believe that these links should provide you a solution for what you need&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with FW encryption</title><link>https://devzone.nordicsemi.com/thread/479461?ContentTypeID=1</link><pubDate>Thu, 18 Apr 2024 13:33:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db4833f2-4e51-4d2d-9c6f-9fc1d271ae78</guid><dc:creator>mackz</dc:creator><description>&lt;p&gt;I think i had some misstakes here with the key generation and the keys.c file, i removed what i added to keys.c, generated new keys with:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;openssl ecparam -name prime256v1 -genkey -noout -out ec_private_key.pem
openssl ec -in ec_private_key.pem -pubout -out ec_public_key.pem
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And changed my mcuboot.conf to&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_BOOT_ENCRYPTION_KEY_FILE=&amp;quot;/custom_key_dir/ec_private_key.pem&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And now i can build and flash the program. But when i try to update the firmware via nrf cloud i get&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v3.2.99-ncs2 ***I: 
Starting bootloaderI: 
Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3I: 
Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3I: 
Boot source: noneI: 
Swap type: testE: 
Image in the secondary slot is not valid!I: 
Bootloader chainload address offset: 0x18000I: 
Jumping to the first image slot
*** Booting Zephyr OS build v3.2.99-ncs2 ***&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I encrypt app_to_sign.bin with:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ncs/v2.3.0/bootloader/mcuboot/scripts/imgtool.py --header-size 0x200 --align 4 --version 5.6.9+8 --pad-header --slot-size 0x74000 --encrypt /custom_key_dir/ec_public_key.pem /hello_world/build/zephyr/app_to_sign.bin /hello_world/build/zephyr/app_update_encrypted.bin&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>