<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>S32KのトピックRe: Secure Boot Missmatched - Calculated CMAC and stored CMAC do not match.</title>
    <link>https://community.nxp.com/t5/S32K/Secure-Boot-Missmatched-Calculated-CMAC-and-stored-CMAC-do-not/m-p/1586713#M20180</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/210673"&gt;@BRK_Y&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;that's a good point, yes, BOOT_SIZE is a number of bits. The SDK documentation is wrong. Thanks for bringing this into our attention, I will report it.&lt;/P&gt;
&lt;P&gt;But there's one more point. Take a look at AN5401:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lukaszadrapa_0-1674490246322.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/208169iB982D460313A2CC4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lukaszadrapa_0-1674490246322.png" alt="lukaszadrapa_0-1674490246322.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;lukaszadrapa_0-1674490246322.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can also take a look at function MAC_SECURE_BOOT() in the AN5401.&lt;/P&gt;
&lt;P&gt;And because CMD_GENERATE_MAC calculates the MAC on 128bit data blocks, the best way is to keep the boot_size aligned to 128bits.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Lukas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2023 16:14:38 GMT</pubDate>
    <dc:creator>lukaszadrapa</dc:creator>
    <dc:date>2023-01-23T16:14:38Z</dc:date>
    <item>
      <title>Secure Boot Missmatched - Calculated CMAC and stored CMAC do not match.</title>
      <link>https://community.nxp.com/t5/S32K/Secure-Boot-Missmatched-Calculated-CMAC-and-stored-CMAC-do-not/m-p/1585461#M20132</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I have an cmac value for a binary code file. Code size is 7308byte.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrK__0-1674132943734.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/207912i5B46C993145E203A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrK__0-1674132943734.png" alt="BrK__0-1674132943734.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;BrK__0-1674132943734.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I defined this cmac value in my csec code and loaded it as boot_mac via debug RAM.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrK__1-1674132943675.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/207913iC1615FFA782EDC24/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrK__1-1674132943675.png" alt="BrK__1-1674132943675.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;BrK__1-1674132943675.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrK__2-1674132943730.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/207914i1F80AF2A9DA5E24B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrK__2-1674132943730.png" alt="BrK__2-1674132943730.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;BrK__2-1674132943730.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then i debug the RAM again to enable secure boot.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrK__3-1674132944114.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/207915iE3C6EBA4FBDFCDB7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrK__3-1674132944114.png" alt="BrK__3-1674132944114.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;BrK__3-1674132944114.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The size variable that the CSEC_DRV_BootDefine function takes is defined as follows,&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrK__4-1674132943766.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/207916i79447EE7C2F068AE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrK__4-1674132943766.png" alt="BrK__4-1674132943766.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;BrK__4-1674132943766.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But, in the reference manual, boot size is explained to as follows :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrK__5-1674133153584.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/207917i821A1F4C66720467/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrK__5-1674133153584.png" alt="BrK__5-1674133153584.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;BrK__5-1674133153584.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As a result, secure boot gives an error as boot_mac_key_missmatched.&lt;/P&gt;&lt;P&gt;I think the problem is in the boot size entry.&lt;/P&gt;&lt;P&gt;How can i solve this boot_mac_key_missmatched problem ?&lt;/P&gt;&lt;P&gt;I look forward to your help on the subject.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also i follows these steps :&lt;/P&gt;&lt;P&gt;* Operate flash partition for csec via Debug Ram.&lt;/P&gt;&lt;P&gt;* Define master_ecu_key, boot_mac_key, boot_mac via Debug Ram.&lt;/P&gt;&lt;P&gt;* Loade code into Flash.&lt;/P&gt;&lt;P&gt;* Define secure boot with&amp;nbsp;CSEC_DRV_BootDefine&amp;nbsp; via Debug Ram.&lt;/P&gt;&lt;P&gt;* Reset device.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 13:03:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Secure-Boot-Missmatched-Calculated-CMAC-and-stored-CMAC-do-not/m-p/1585461#M20132</guid>
      <dc:creator>BRK_Y</dc:creator>
      <dc:date>2023-01-19T13:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Secure Boot Missmatched - Calculated CMAC and stored CMAC do not match.</title>
      <link>https://community.nxp.com/t5/S32K/Secure-Boot-Missmatched-Calculated-CMAC-and-stored-CMAC-do-not/m-p/1586713#M20180</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/210673"&gt;@BRK_Y&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;that's a good point, yes, BOOT_SIZE is a number of bits. The SDK documentation is wrong. Thanks for bringing this into our attention, I will report it.&lt;/P&gt;
&lt;P&gt;But there's one more point. Take a look at AN5401:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lukaszadrapa_0-1674490246322.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/208169iB982D460313A2CC4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lukaszadrapa_0-1674490246322.png" alt="lukaszadrapa_0-1674490246322.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;lukaszadrapa_0-1674490246322.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can also take a look at function MAC_SECURE_BOOT() in the AN5401.&lt;/P&gt;
&lt;P&gt;And because CMD_GENERATE_MAC calculates the MAC on 128bit data blocks, the best way is to keep the boot_size aligned to 128bits.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Lukas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 16:14:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Secure-Boot-Missmatched-Calculated-CMAC-and-stored-CMAC-do-not/m-p/1586713#M20180</guid>
      <dc:creator>lukaszadrapa</dc:creator>
      <dc:date>2023-01-23T16:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Secure Boot Missmatched - Calculated CMAC and stored CMAC do not match.</title>
      <link>https://community.nxp.com/t5/S32K/Secure-Boot-Missmatched-Calculated-CMAC-and-stored-CMAC-do-not/m-p/1587003#M20192</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/37795"&gt;@lukaszadrapa&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for reply, but i dont use CMD_GENERATE_MAC() function for generate cmac. I use external software to signing my binary code that follow AES-128 CMAC method.&lt;/P&gt;&lt;P&gt;This binary is 7308byte and calculated cmac is (CSEC_BOOT_MAC) {0x16, 0x3c, 0xc5, 0xdc, 0x7b, 0x0f, 0xcd, 0x7e, 0x24, 0x5b, 0x98, 0xa5, 0x9b, 0x30, 0xcd, 0x66}.&lt;/P&gt;&lt;P&gt;Actually my problem is CSEC_DRV_BootDefine() function.&lt;/P&gt;&lt;P&gt;Firstly, i load keys (CSEC_MASTER_ECU, CSEC_BOOT_MAC_KEY and CSEC_BOOT_MAC) in my EVB via RAM_Debug.&lt;/P&gt;&lt;P&gt;After that i load my application code to EVB via FLASH_Debug.&lt;/P&gt;&lt;P&gt;/// 7308 * 8 =&amp;nbsp;58464&lt;/P&gt;&lt;P&gt;And finally i use&amp;nbsp;CSEC_DRV_BootDefine(58464, CSEC_BOOT_SERIAL); for enable secure boot.&lt;/P&gt;&lt;P&gt;So, should i follow 4.4.3.1 Manually in RM like&amp;nbsp;CSEC_DRV_BootDefine(58464 + 128, CSEC_BOOT_SERIAL);&lt;/P&gt;&lt;P&gt;or should i keep boot_size aligned to 128 bits&lt;/P&gt;&lt;P&gt;Does secure boot operation do automatic 128-bit alignment?&lt;/P&gt;&lt;P&gt;How secure boot handles boot size?&lt;/P&gt;&lt;P&gt;How can i secure boot with external specified boot_mac on my binary file?&lt;/P&gt;&lt;P&gt;Which key is used in boot_mac calculation of secure boot operation? Is the key used csec_boot_mac_key?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 09:55:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Secure-Boot-Missmatched-Calculated-CMAC-and-stored-CMAC-do-not/m-p/1587003#M20192</guid>
      <dc:creator>BRK_Y</dc:creator>
      <dc:date>2023-01-24T09:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Secure Boot Missmatched - Calculated CMAC and stored CMAC do not match.</title>
      <link>https://community.nxp.com/t5/S32K/Secure-Boot-Missmatched-Calculated-CMAC-and-stored-CMAC-do-not/m-p/1588209#M20226</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/210673"&gt;@BRK_Y&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;yes, it is necessary to follow section "4.4.3.1 Manually". This is given directly by SHE specification. You need to append 128b frame before your binary (zeros + boot size) and the CMAC must be calculated over all these data, so size for your offline CMAC calculation must be increased +128.&lt;/P&gt;
&lt;P&gt;The documentation says nothing about alignment of secure boot, so it should not be necessary to align the size.&lt;/P&gt;
&lt;P&gt;And yes, BOOT_MAC_KEY is used for secure boot.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Lukas&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 08:49:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Secure-Boot-Missmatched-Calculated-CMAC-and-stored-CMAC-do-not/m-p/1588209#M20226</guid>
      <dc:creator>lukaszadrapa</dc:creator>
      <dc:date>2023-01-26T08:49:12Z</dc:date>
    </item>
  </channel>
</rss>

