<?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>Disabling bootloader security without customization</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/50296/disabling-bootloader-security-without-customization</link><description>I&amp;#39;m trying out DFU functionality using nRF52840-PreviewDK and UART transport 
 It looks like I can disable the requirement for a signature when downloading an APP or SD (SoftDevice) using NRF_DFU_REQUIRE_SIGNED_APP_UPDATE. 
 It looks like I can disable</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Apr 2022 23:41:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/50296/disabling-bootloader-security-without-customization" /><item><title>RE: Disabling bootloader security without customization</title><link>https://devzone.nordicsemi.com/thread/362464?ContentTypeID=1</link><pubDate>Thu, 07 Apr 2022 23:41:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5165817f-1f23-47a5-a6f2-a2f61047f5bc</guid><dc:creator>ruotoy</dc:creator><description>[quote userid="7571" url="~/f/nordic-q-a/50296/disabling-bootloader-security-without-customization/200992#200992"]Bjørn[/quote]
&lt;p&gt;Hi Bjorn,&lt;/p&gt;
&lt;p&gt;I am confused about how nrf_dfu_validation_prevalidate() verify signature. According to my understanding, the signature from init packet is generated based on the firmware to be updated. The nrf_dfu_validation_signature_check() function will compare if the hash calculated from firmware is the same with the hash from signature. However, the firmware is not available during the prevalidation. To this end, I do not know how the signature is verified.&lt;/p&gt;
&lt;p&gt;From source code, nrf_dfu_validation_prevalidate() call nrf_dfu_validation_signature_check() function with m_init_packet_data_ptr as one of the input. m_init_packet_data_ptr will then be used to calculate the hash, which is obviously the hash from init packet instead of firmware to be updated.&lt;/p&gt;
&lt;p&gt;I might misunderstand some part of the code. Really appreciate if you can explain this to me. Thanks for your time.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disabling bootloader security without customization</title><link>https://devzone.nordicsemi.com/thread/200992?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2019 13:43:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:caa7dc97-5298-40b7-8315-c060d9d0ad4f</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;HI Douglas,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;when creating a DFU firmware image using the --debug-mode option of nrfutil, you&amp;#39;re only skipping the version check for &lt;span&gt;hardware and firmware&lt;/span&gt;, see&amp;nbsp;&lt;a href="https://github.com/NordicSemiconductor/pc-nrfutil#generate"&gt;https://github.com/NordicSemiconductor/pc-nrfutil#generate&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This can be seen in&amp;nbsp;nrf_dfu_ver_validation_check() from nrf_dfu_validation.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrf_dfu_result_t nrf_dfu_ver_validation_check(dfu_init_command_t const * p_init)
{
    nrf_dfu_result_t ret_val = NRF_DFU_RES_CODE_SUCCESS;
    if (!fw_type_ok(p_init))
    {
        NRF_LOG_ERROR(&amp;quot;Invalid firmware type.&amp;quot;);
        ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_INIT_COMMAND_INVALID);
    }
    else if (!fw_hash_type_ok(p_init))
    {
        NRF_LOG_ERROR(&amp;quot;Invalid hash type.&amp;quot;);
        ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_WRONG_HASH_TYPE);
    }
    else if (!NRF_DFU_DEBUG ||
            (NRF_DFU_DEBUG &amp;amp;&amp;amp; ((p_init-&amp;gt;has_is_debug == false) || (p_init-&amp;gt;is_debug == false))))
    {
        if (p_init-&amp;gt;has_hw_version == false)
        {
            NRF_LOG_ERROR(&amp;quot;No HW version.&amp;quot;);
            ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_INIT_COMMAND_INVALID);
        }
        else if (p_init-&amp;gt;hw_version != NRF_DFU_HW_VERSION)
        {
            NRF_LOG_WARNING(&amp;quot;Faulty HW version.&amp;quot;);
            ret_val = EXT_ERR( NRF_DFU_EXT_ERROR_HW_VERSION_FAILURE);
        }

        else if (!sd_req_ok(p_init))
        {
            NRF_LOG_WARNING(&amp;quot;SD req not met.&amp;quot;);
            ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_SD_VERSION_FAILURE);
        }
        else if (p_init-&amp;gt;has_fw_version)
        {
            if (!fw_version_ok(p_init))
            {
                NRF_LOG_WARNING(&amp;quot;FW version too low.&amp;quot;);
                ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_FW_VERSION_FAILURE);
            }
        }
        else
        {
            if (fw_version_required(p_init-&amp;gt;type))
            {
                NRF_LOG_ERROR(&amp;quot;FW version missing.&amp;quot;);
                ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_INIT_COMMAND_INVALID);
            }
        }
    }
    return ret_val;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;which in turn is called by&amp;nbsp;nrf_dfu_validation_prevalidate(), which checks the signature &lt;em&gt;_before_&lt;/em&gt; calling&amp;nbsp;nrf_dfu_ver_validation_check().&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrf_dfu_result_t nrf_dfu_validation_prevalidate(void)
{
    nrf_dfu_result_t                 ret_val        = NRF_DFU_RES_CODE_SUCCESS;
    dfu_command_t            const * p_command      = &amp;amp;m_packet.command;
    dfu_signature_type_t             signature_type = DFU_SIGNATURE_TYPE_MIN;
    uint8_t                  const * p_signature    = NULL;
    uint32_t                         signature_len  = 0;

    if (m_packet.has_signed_command)
    {
        p_command      = &amp;amp;m_packet.signed_command.command;
        signature_type =  m_packet.signed_command.signature_type;
        p_signature    =  m_packet.signed_command.signature.bytes;
        signature_len  =  m_packet.signed_command.signature.size;
    }

    // Validate signature.
    if (signature_required(p_command-&amp;gt;init.type))
    {
        ret_val = nrf_dfu_validation_signature_check(signature_type,
                                                     p_signature,
                                                     signature_len,
                                                     m_init_packet_data_ptr,
                                                     m_init_packet_data_len);
    }

    // Validate versions.
    if (ret_val == NRF_DFU_RES_CODE_SUCCESS)
    {
        ret_val = nrf_dfu_ver_validation_check(&amp;amp;p_command-&amp;gt;init);
    }

    if (ret_val != NRF_DFU_RES_CODE_SUCCESS)
    {
        NRF_LOG_WARNING(&amp;quot;Prevalidation failed.&amp;quot;);
        NRF_LOG_DEBUG(&amp;quot;Init command:&amp;quot;);
        NRF_LOG_HEXDUMP_DEBUG(m_init_packet_data_ptr, m_init_packet_data_len);
    }

    return ret_val;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you want to disable the signature check and version requirement for the bootloader you will have to modify the source.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>