<?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>Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/37260/adding-encryption-to-secure-dfu-sdk-v15</link><description>In the following Q&amp;amp;A I will outline a working implementation of encrypted firmware updates using the Secure DFU in SDK v15. This implementation allows for encrypted firmware updates of both the application and the bootloader. 
 
 Creating a custom DFU</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 08 Jan 2024 18:43:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/37260/adding-encryption-to-secure-dfu-sdk-v15" /><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/463225?ContentTypeID=1</link><pubDate>Mon, 08 Jan 2024 18:43:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9ec3a09-ae97-4935-8a1f-cbee6e249b48</guid><dc:creator>aetherengineer</dc:creator><description>&lt;p&gt;Hi Matthew-&lt;/p&gt;
&lt;p&gt;The porting to SDKv17 went smoothly. Only minor function repackaging and variable name changes were involved.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you have any references for adding CBC-MAC to this counter method so this could be a full CCM implementation?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;-Greg&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/456048?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2023 20:59:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:076ccd79-57c1-456e-aace-c433e04776c4</guid><dc:creator>aetherengineer</dc:creator><description>&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/456047?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2023 20:51:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ea62ef6-792e-4844-b875-271a52de3daf</guid><dc:creator>Mathew</dc:creator><description>&lt;p&gt;Hi Greg,&lt;br /&gt;&lt;br /&gt;The link does appear to be broken, but I believe you&amp;#39;ve found what appears to be the correct instructions in that .pdf you&amp;#39;ve linked.&lt;br /&gt;&lt;br /&gt;Best of luck with the port!&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Mathew&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/456046?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2023 20:45:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:755bc6d1-b3c5-4423-b2ee-41b0da1d0a41</guid><dc:creator>aetherengineer</dc:creator><description>&lt;p&gt;Hi Matthew-&lt;/p&gt;
&lt;p&gt;When you say &amp;quot;&lt;span&gt;&amp;nbsp;perform Step 4. as described&amp;nbsp;&lt;/span&gt;&lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.tools%2Fdita%2Ftools%2Fnrfutil%2Fnrfutil_customizing.html&amp;amp;cp=5_5_8"&gt;here&lt;/a&gt;&amp;quot;, the link is broken. Just wanted to verify that it refers to step 4 in section 9 of&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/pdf/nrfutil_v1.3.pdf"&gt;https://infocenter.nordicsemi.com/pdf/nrfutil_v1.3.pdf&lt;/a&gt;.. Here&amp;#39;s to hoping you still check in after all these years! I&amp;#39;m &amp;quot;porting&amp;quot; this solution to v17.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;-Greg&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/442661?ContentTypeID=1</link><pubDate>Wed, 23 Aug 2023 02:15:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89dc5c5c-3352-4bb0-a071-359448a17351</guid><dc:creator>Lurn_Z</dc:creator><description>&lt;p&gt;Hi Mathew,&lt;/p&gt;
&lt;p&gt;When I modified the DFU code, I found that your DFU seems to use softdevice, but I did not use softdevice, so some functions and structures cannot be used. Do you have a version that does not use softdevice? And I use the SDK 17.1.0&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Lurn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/399315?ContentTypeID=1</link><pubDate>Wed, 07 Dec 2022 05:25:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa0adb57-a981-4187-8713-6fab1a5221df</guid><dc:creator>Zivojin</dc:creator><description>&lt;p&gt;Thanks a lot&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/399314?ContentTypeID=1</link><pubDate>Wed, 07 Dec 2022 05:20:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d01c0c4-9baa-44ab-855d-81bac619a9b2</guid><dc:creator>Mathew</dc:creator><description>&lt;p&gt;ECB Key should be 16 bytes (contrary to what was posted in an earlier copy of a reply).&lt;br /&gt;&lt;br /&gt;Please generate &lt;strong&gt;16&lt;/strong&gt; cryptographically random bytes - doing so will remove the need for the spare &amp;#39;0x00&amp;#39;s.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If this is your ECB Key:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;const uint8_t ecb_key[ECB_KEY_LEN] = {0xab, 0x0a, 0xab, 0x3c, 0xdd, 0x1e, 0x5f, 0x88, 0xe7, 0x31, 0x43, 0x58, 0x20, 0x3f, 0x2b, 0x68};&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Then the&amp;nbsp;-K argument to the&amp;nbsp;C:\OpenSSL-Win64\bin\openssl.exe enc command would be as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;682b3f20584331e7885f1edd3cab0aab&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/399313?ContentTypeID=1</link><pubDate>Wed, 07 Dec 2022 04:39:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae244a08-3099-46ee-8f37-c1dbadfd4fa2</guid><dc:creator>Zivojin</dc:creator><description>&lt;p&gt;Hi Mathew,&lt;/p&gt;
&lt;p&gt;After generate ecb key - e.g.&amp;nbsp;&amp;nbsp; &lt;span style="font-family:monospace;"&gt;&lt;span style="background-color:#ffffff;color:#000000;"&gt;ab0aab3cdd1e5f88e7314358&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Should it be written like this:&lt;/p&gt;
&lt;p&gt;const uint8_t ecb_key[ECB_KEY_LEN] = {0x00, 0x00, 0x00, 0x00, 0xab, 0x0a, 0xab, 0x3c, 0xdd, 0x1e, 0x5f, 0x88, 0xe7, 0x31, 0x43, 0x58}; &lt;br /&gt;&lt;br /&gt;or &lt;br /&gt;&lt;br /&gt;const uint8_t ecb_key[ECB_KEY_LEN] = {0xab, 0x0a, 0xab, 0x3c, 0xdd, 0x1e, 0x5f, 0x88, 0xe7, 0x31, 0x43, 0x58, 0x00, 0x00, 0x00, 0x00};&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/399264?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2022 18:21:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34a9b80c-bc39-434b-84bd-c895f074898d</guid><dc:creator>Zivojin</dc:creator><description>&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/399262?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2022 17:58:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11a96085-d1dc-4990-a2da-bfb8cfdc08ce</guid><dc:creator>Mathew</dc:creator><description>&lt;p&gt;signature_check() was part of the SDK with which this Q&amp;amp;A was developed i.e. the call to signature_check() was not added by myself. It&amp;#39;s likely that you&amp;#39;re using a different version of the SDK which no longer includes this exact function.&lt;br /&gt;&lt;br /&gt;Nevertheless, you may&amp;nbsp;be able to tweak the following function to match the SDK you&amp;#39;re using:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// Function to perform signature check if required.
static nrf_dfu_result_t signature_check(dfu_fw_type_t                          fw_type,
                                        dfu_signature_type_t                   signature_type,
                                        dfu_signed_command_signature_t const * p_signature)
{
    ret_code_t err_code;
    size_t     hash_len = NRF_CRYPTO_HASH_SIZE_SHA256;
    
    if (!signature_required(fw_type))
    {
        return NRF_DFU_RES_CODE_SUCCESS;
    }

    NRF_LOG_INFO(&amp;quot;Signature required. Checking signature.&amp;quot;)
    if (p_signature == NULL)
    {
        NRF_LOG_WARNING(&amp;quot;No signature found.&amp;quot;);
        return EXT_ERR(NRF_DFU_EXT_ERROR_SIGNATURE_MISSING);
    }

    if (signature_type != DFU_SIGNATURE_TYPE_ECDSA_P256_SHA256)
    {
        NRF_LOG_INFO(&amp;quot;Invalid signature type&amp;quot;);
        return EXT_ERR(NRF_DFU_EXT_ERROR_WRONG_SIGNATURE_TYPE);
    }

    NRF_LOG_INFO(&amp;quot;Calculating init packet hash (init packet len: %d)&amp;quot;, m_init_packet_data_len);
    err_code = nrf_crypto_hash_calculate(&amp;amp;m_hash_context,
                                         &amp;amp;g_nrf_crypto_hash_sha256_info,
                                         m_init_packet_data_ptr,
                                         m_init_packet_data_len,
                                         m_init_packet_hash,
                                         &amp;amp;hash_len);
    if (err_code != NRF_SUCCESS)
    {
        return NRF_DFU_RES_CODE_OPERATION_FAILED;
    }

    if (sizeof(m_signature) != p_signature-&amp;gt;size)
    {
        return NRF_DFU_RES_CODE_OPERATION_FAILED;
    }

    // Prepare the signature received over the air.
    memcpy(m_signature, p_signature-&amp;gt;bytes, p_signature-&amp;gt;size);

    // Calculate the signature.
    NRF_LOG_INFO(&amp;quot;Verify signature&amp;quot;);

    // The signature is in little-endian format. Change it to big-endian format for nrf_crypto use.
    nrf_crypto_internal_double_swap_endian_in_place(m_signature, sizeof(m_signature) / 2);

    err_code = nrf_crypto_ecdsa_verify(&amp;amp;m_verify_context,
                                       &amp;amp;m_public_key,
                                       m_init_packet_hash,
                                       hash_len,
                                       m_signature,
                                       sizeof(m_signature));
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_ERROR(&amp;quot;Signature failed (err_code: 0x%x)&amp;quot;, err_code);
        NRF_LOG_DEBUG(&amp;quot;Signature:&amp;quot;);
        NRF_LOG_HEXDUMP_DEBUG(m_signature, sizeof(m_signature));
        NRF_LOG_DEBUG(&amp;quot;Hash:&amp;quot;);
        NRF_LOG_HEXDUMP_DEBUG(m_init_packet_hash, hash_len);
        NRF_LOG_DEBUG(&amp;quot;Public Key:&amp;quot;);
        NRF_LOG_HEXDUMP_DEBUG(pk, sizeof(pk));
        NRF_LOG_FLUSH();

        return NRF_DFU_RES_CODE_INVALID_OBJECT;
    }

    NRF_LOG_INFO(&amp;quot;Image verified&amp;quot;);
    return NRF_DFU_RES_CODE_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/399258?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2022 17:33:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5de8f76-e717-4f37-9245-8bb4b035451e</guid><dc:creator>Zivojin</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is the step which says that in the &lt;strong&gt;nrf_dfu_validation_init_cmd_execute()&lt;/strong&gt;&amp;nbsp; we should add&lt;/p&gt;
&lt;p&gt;&lt;em&gt;...&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;// Validate signature.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;ret_val = signature_check(p_command-&amp;gt;init.type, signature_type, p_signature);&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;But there is no definition of &lt;em&gt;signature_check&lt;/em&gt;() function and I am getting error because of that.&lt;/p&gt;
&lt;p&gt;Can you help me on this, please?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/398917?ContentTypeID=1</link><pubDate>Mon, 05 Dec 2022 07:41:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c74b124-5203-459b-91f5-c321e4b8bd83</guid><dc:creator>Zivojin</dc:creator><description>&lt;p&gt;&lt;span class="HwtZe" lang="en"&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;Thanks a lot for the quick reply!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="ZSCsVd"&gt;&lt;span class="azoIfb"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="HwtZe" lang="en"&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;Kind regards&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/398915?ContentTypeID=1</link><pubDate>Mon, 05 Dec 2022 07:36:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dedd45bb-759d-4c91-a09c-940f7e7bac97</guid><dc:creator>Mathew</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;The same information contained in the broken links&amp;nbsp;is&amp;nbsp;likely to be found in Section 9 of this&amp;nbsp;.pdf: &lt;a href="https://infocenter.nordicsemi.com/pdf/nrfutil_v1.3.pdf"&gt;https://infocenter.nordicsemi.com/pdf/nrfutil_v1.3.pdf&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/398904?ContentTypeID=1</link><pubDate>Mon, 05 Dec 2022 05:41:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d79af78-521f-4a59-9bef-2adc78be45e6</guid><dc:creator>Zivojin</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;All provided links int the post are broken&lt;/p&gt;
&lt;p&gt;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.tools/dita/tools/nrfutil/nrfutil_customizing.html?cp=5_5_8"&gt;infocenter.nordicsemi.com/.../nrfutil_customizing.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.tools%2Fdita%2Ftools%2Fnrfutil%2Fnrfutil_customizing.html&amp;amp;cp=5_5_8"&gt;http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.tools%2Fdita%2Ftools%2Fnrfutil%2Fnrfutil_customizing.html&amp;amp;cp=5_5_8&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="HwtZe" lang="en"&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="HwtZe" lang="en"&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;Could you please update the post to include steps which were explained on those links?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="HwtZe" lang="en"&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;Thanks&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/349847?ContentTypeID=1</link><pubDate>Wed, 26 Jan 2022 20:54:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1608e572-a76c-4862-b513-1ddb2708c5eb</guid><dc:creator>Mathew</dc:creator><description>&lt;p&gt;The ECB key is simply&amp;nbsp;16 cryptographically random bytes.&lt;br /&gt;&lt;br /&gt;You can generate 16&amp;nbsp;&lt;span&gt;cryptographically random bytes using Python. Open up a Python command line and type the following:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;import os&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;code&gt;import&amp;nbsp;import binascii&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="hljs language-python"&gt;binascii.hexlify(os.urandom(1&lt;span class="hljs-number"&gt;6&lt;/span&gt;))&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;The output should look something like this (i.e. 16 hex values):&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;span&gt;&amp;nbsp;b&amp;#39;5cf1159902090a33cbbd5c03134f5fcc&amp;#39;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/349667?ContentTypeID=1</link><pubDate>Wed, 26 Jan 2022 05:30:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa37425c-8a15-4523-b07a-378bec007c64</guid><dc:creator>RJ Fang</dc:creator><description>&lt;p&gt;Hi Mathew,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for the clarification!&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have one query that how to get ECB key is not mentioned any where. Could you please update on how to get the corresponding ECB key?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Rj&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/339895?ContentTypeID=1</link><pubDate>Sat, 20 Nov 2021 01:26:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b2505ab-f689-445a-8bad-8732a3948430</guid><dc:creator>Mathew</dc:creator><description>&lt;p&gt;Existing&amp;nbsp;function code in SDK 15:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrf_dfu_result_t nrf_dfu_validation_post_data_execute(uint32_t src_addr, uint32_t data_len)
{
    nrf_dfu_result_t     ret_val = NRF_DFU_RES_CODE_SUCCESS;
    dfu_init_command_t * p_init  = m_packet.has_signed_command ? &amp;amp;m_packet.signed_command.command.init
                                                               : &amp;amp;m_packet.command.init;

    if (!fw_hash_ok(p_init, src_addr, data_len))
    {
        ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_VERIFICATION_FAILED);
    }
    else
    {
        if (p_init-&amp;gt;type == DFU_FW_TYPE_APPLICATION)
        {
            postvalidate_app(p_init);
        }
        else
        {
            bool with_sd = p_init-&amp;gt;type &amp;amp; DFU_FW_TYPE_SOFTDEVICE;
            bool with_bl = p_init-&amp;gt;type &amp;amp; DFU_FW_TYPE_BOOTLOADER;

            if (!postvalidate_sd_bl(p_init, with_sd, with_bl, src_addr))
            {
                ret_val = NRF_DFU_RES_CODE_INVALID_OBJECT;
                if (with_sd &amp;amp;&amp;amp; !DFU_REQUIRES_SOFTDEVICE &amp;amp;&amp;amp;
                    (src_addr == nrf_dfu_softdevice_start_address()))
                {
                    nrf_dfu_softdevice_invalidate();
                }
            }
        }
    }

    if (ret_val == NRF_DFU_RES_CODE_SUCCESS)
    {
        // Store CRC32 for image
        s_dfu_settings.bank_1.image_crc = s_dfu_settings.progress.firmware_image_crc;
        s_dfu_settings.bank_1.image_size = data_len;
    }
    else
    {
        nrf_dfu_bank_invalidate(&amp;amp;s_dfu_settings.bank_1);
    }

    // Set the progress to zero and remove the last command
    memset(&amp;amp;s_dfu_settings.progress, 0, sizeof(dfu_progress_t));
    memset(s_dfu_settings.init_command, 0xFF, DFU_SIGNED_COMMAND_SIZE);

    s_dfu_settings.write_offset                  = 0;
    s_dfu_settings.progress.update_start_address = src_addr;

    return ret_val;
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Change to:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrf_dfu_result_t nrf_dfu_validation_post_data_execute(uint32_t src_addr, uint32_t data_len)
{
    nrf_dfu_result_t     ret_val = NRF_DFU_RES_CODE_SUCCESS;
    dfu_init_command_t * p_init  = m_packet.has_signed_command ? &amp;amp;m_packet.signed_command.command.init
                                                               : &amp;amp;m_packet.command.init;

    if (!fw_hash_ok(p_init, src_addr, data_len))
    {
        ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_VERIFICATION_FAILED);
    }
    else
    {
        if (p_init-&amp;gt;type == DFU_FW_TYPE_APPLICATION || p_init-&amp;gt;type &amp;amp; DFU_FW_TYPE_BOOTLOADER)
        {
            s_dfu_settings.progress.firmware_image_crc = crc32_compute((uint8_t*)src_addr, data_len, NULL);
        }
        
        if (p_init-&amp;gt;type == DFU_FW_TYPE_APPLICATION)
        {
            postvalidate_app(p_init);
        }
        else
        {
            bool with_sd = p_init-&amp;gt;type &amp;amp; DFU_FW_TYPE_SOFTDEVICE;
            bool with_bl = p_init-&amp;gt;type &amp;amp; DFU_FW_TYPE_BOOTLOADER;

            if (!postvalidate_sd_bl(p_init, with_sd, with_bl, src_addr))
            {
                ret_val = NRF_DFU_RES_CODE_INVALID_OBJECT;
                if (with_sd &amp;amp;&amp;amp; !DFU_REQUIRES_SOFTDEVICE &amp;amp;&amp;amp;
                    (src_addr == nrf_dfu_softdevice_start_address()))
                {
                    nrf_dfu_softdevice_invalidate();
                }
            }
        }
    }

    if (ret_val == NRF_DFU_RES_CODE_SUCCESS)
    {
        // Store CRC32 for image
        s_dfu_settings.bank_1.image_crc = s_dfu_settings.progress.firmware_image_crc;
        s_dfu_settings.bank_1.image_size = data_len;
    }
    else
    {
        nrf_dfu_bank_invalidate(&amp;amp;s_dfu_settings.bank_1);
    }

    // Set the progress to zero and remove the last command
    memset(&amp;amp;s_dfu_settings.progress, 0, sizeof(dfu_progress_t));
    memset(s_dfu_settings.init_command, 0xFF, DFU_SIGNED_COMMAND_SIZE);

    s_dfu_settings.write_offset                  = 0;
    s_dfu_settings.progress.update_start_address = src_addr;

    return ret_val;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/339894?ContentTypeID=1</link><pubDate>Sat, 20 Nov 2021 01:11:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf1800ce-e250-4965-9f90-331ba3bfca18</guid><dc:creator>RJ Fang</dc:creator><description>&lt;p&gt;Hi Mathew,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am confused when adding code to&amp;nbsp;&lt;strong&gt;nrf_dfu_validation_post_data_execute. &lt;/strong&gt;It seems like there&amp;#39;s an incomplete code?&lt;/p&gt;
&lt;p&gt;Any help is appreciated!&lt;/p&gt;
&lt;p&gt;Thank you in advance,&lt;/p&gt;
&lt;p&gt;RJ&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/224199?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 13:38:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d07ccb5-3b5d-48ff-869c-aaae8482e876</guid><dc:creator>Dattatray</dc:creator><description>&lt;p&gt;I am getting below error for&amp;nbsp;&amp;nbsp;nRF5 SDK 16.0.0&lt;/p&gt;
&lt;p&gt;1&amp;gt; C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 4.18/gcc/arm-none-eabi/bin/ld: ../../../../Output/Release/Obj/nrf_dfu_validation.o: in function `nrf_dfu_validation_crypt&amp;#39;:&lt;br /&gt;1&amp;gt; \BootLoaderSource\components\libraries\bootloader\dfu/nrf_dfu_validation.c:188: undefined reference to `sd_ecb_block_encrypt&amp;#39;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/224124?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 10:32:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d15c35e1-5382-4aac-9413-a483c75f416f</guid><dc:creator>Dattatray</dc:creator><description>&lt;p&gt;Thank you for sharing such detailed setps.&lt;/p&gt;
&lt;p&gt;I have one query that how to get ECB key is not mentioned any where. Please update on ECB key&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/206679?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2019 14:20:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3db9ef74-12b6-4b11-985b-54568acd67ff</guid><dc:creator>Sergnrf</dc:creator><description>&lt;p&gt;&lt;span&gt;anyone&amp;nbsp;had such an error?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Compiling file: nrf_dfu_req_handler.c&lt;/span&gt;&lt;br /&gt;&lt;span&gt;../../../../../components/libraries/bootloader/dfu/nrf_dfu_req_handler.c: In function &amp;#39;on_data_obj_write_request&amp;#39;:&lt;/span&gt;&lt;br /&gt;&lt;span&gt;../../../../../components/libraries/bootloader/dfu/nrf_dfu_req_handler.c:496:34: error: passing argument 1 of &amp;#39;nrf_dfu_validation_crypt&amp;#39; discards &amp;#39;const&amp;#39; qualifier from pointer target type [-Werror=discarded-qualifiers]&lt;/span&gt;&lt;br /&gt;&lt;span&gt;nrf_dfu_validation_crypt(&amp;amp;p_req-&amp;gt;write.p_data[i]);&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ^&lt;/span&gt;&lt;br /&gt;&lt;span&gt;In file included from ../../../../../components/libraries/bootloader/dfu/nrf_dfu_req_handler.c:62:0:&lt;/span&gt;&lt;br /&gt;&lt;span&gt;../../../../../components/libraries/bootloader/dfu/nrf_dfu_validation.h:120:10: note: expected &amp;#39;uint8_t * {aka unsigned char *}&amp;#39; but argument is of type &amp;#39;const uint8_t * {aka const unsigned char *}&amp;#39;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;uint32_t nrf_dfu_validation_crypt( uint8_t * buf);&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ^~~~~~~~~~~~~~~~~~~~~~~~&lt;/span&gt;&lt;br /&gt;&lt;span&gt;cc1.exe: all warnings being treated as errors&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;please tell me how to fix it&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/174099?ContentTypeID=1</link><pubDate>Mon, 04 Mar 2019 21:18:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:708b9d35-a919-4edd-8ee1-ca71e1323688</guid><dc:creator>ibeckermayer</dc:creator><description>&lt;p&gt;Matthew,&lt;/p&gt;
&lt;p&gt;Thanks for this tutorial. We are trying to implement encryption in a similar manner, however are running into an error when the bootloader checks the &lt;strong&gt;p_init-&amp;gt;type.&amp;nbsp;&lt;/strong&gt;I am getting an apparent junk value of 62, when I should be getting 0 per the&amp;nbsp;&lt;strong&gt;dfu_fw_type_t&lt;/strong&gt; enum in&amp;nbsp;&lt;strong&gt;dfu-cc.pb.h&lt;/strong&gt;. I have added a detailed post &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/44392/adding-encryption-to-secure-dfu-sdk-v15"&gt;here&lt;/a&gt;,&amp;nbsp;any help with debugging would be greatly appreciated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/168049?ContentTypeID=1</link><pubDate>Sat, 26 Jan 2019 02:05:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e03426f6-0343-4551-b1f9-8726a6dc5d75</guid><dc:creator>Mathew</dc:creator><description>&lt;p&gt;I&amp;#39;ve updated the post to include the changes made to the files found in the pc-nrfutil/nordicsemi/dfu folder. Don&amp;#39;t forget to edit the dfu-cc.proto file and regenerate the dfu_cc_pb2.py file with the protocol buffer compiler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/168048?ContentTypeID=1</link><pubDate>Sat, 26 Jan 2019 02:03:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aed14e60-3986-4ca3-8f6d-e47dc1389fd9</guid><dc:creator>Mathew</dc:creator><description>&lt;p&gt;I&amp;#39;ve updated the post to include the changes made to the files found in the pc-nrfutil/nordicsemi/dfu folder. Don&amp;#39;t forget to edit the dfu-cc.proto file and regenerate the dfu_cc_pb2.py file with the protocol buffer compiler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding Encryption to Secure DFU SDK v15</title><link>https://devzone.nordicsemi.com/thread/168040?ContentTypeID=1</link><pubDate>Fri, 25 Jan 2019 23:13:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87782071-268e-4ca4-9c03-782f288d39ab</guid><dc:creator>wozix</dc:creator><description>&lt;p&gt;Hi Mathew,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can you please share the required change to nrfutil to add the nonce? You attached a .exe but I&amp;#39;m modifying the nrfutil source to be able to use this on Linux.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>