<?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のトピックCSEc command LOAD_KEY returns ERC_KEY_INVALID for some KeyIDs on S32k148</title>
    <link>https://community.nxp.com/t5/S32K/CSEc-command-LOAD-KEY-returns-ERC-KEY-INVALID-for-some-KeyIDs-on/m-p/1881286#M36240</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have encountered an interesting problem. I want to install CSEc keys to S32k148 device. The device is partitioned for 20 keys (uCSEcKeySize = 0x03u). I am using functions &lt;EM&gt;calculate_M1_to_M5&lt;/EM&gt; and &lt;EM&gt;LOAD_KEY&lt;/EM&gt; from AN5401SW in my code.&lt;/P&gt;&lt;P&gt;It works correctly (the &lt;EM&gt;LOAD_KEY&lt;/EM&gt; function returns value 1 = NO_ERROR) for all KeyIDs (0x04 – 0x0D, 0x14 – 0x18) when the master key is used for authorization.&lt;/P&gt;&lt;P&gt;It also works correctly for KeyIDs 0x04 – 0x0D and 0x15 and 0x17, when the old value of the key itself is used for authorization.&lt;/P&gt;&lt;P&gt;However, when I use the old value of the key itself for authorization, the &lt;EM&gt;LOAD_KEY&lt;/EM&gt; function returns value 8 (KEY_INVALID) for KeyIDs 0x14, 0x16, 0x18.&lt;/P&gt;&lt;P&gt;I am sure that the key value used for authorization is correct (the blank key 0xff…ff). I have tested that &lt;EM&gt;LOAD_KEY&lt;/EM&gt; function returns value 0x80 (KEY_UPDATE_ERROR) when wrong value of the authorization key is used.&lt;/P&gt;&lt;P&gt;I have tested it several times. I always unsecure device by the following sequence:&lt;/P&gt;&lt;P&gt;DBG_CHAL,&lt;/P&gt;&lt;P&gt;DBG_AUTH,&lt;/P&gt;&lt;P&gt;FLASH_DRV_EraseAllBlock,&lt;/P&gt;&lt;P&gt;FLASH_DRV_Program configuration fields on address 0x0400 by values {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFE,0x7F,0xFF,0xFF};&lt;/P&gt;&lt;P&gt;FLASH_DRV_DEFlashPartition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have anybody any idea what can be the root of the problem?&lt;/P&gt;&lt;P&gt;I can use it with master key authorization, but I want to be sure that I understand the process well.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Libor Waszniowski&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jun 2024 07:11:06 GMT</pubDate>
    <dc:creator>lwaszniowski</dc:creator>
    <dc:date>2024-06-05T07:11:06Z</dc:date>
    <item>
      <title>CSEc command LOAD_KEY returns ERC_KEY_INVALID for some KeyIDs on S32k148</title>
      <link>https://community.nxp.com/t5/S32K/CSEc-command-LOAD-KEY-returns-ERC-KEY-INVALID-for-some-KeyIDs-on/m-p/1881286#M36240</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have encountered an interesting problem. I want to install CSEc keys to S32k148 device. The device is partitioned for 20 keys (uCSEcKeySize = 0x03u). I am using functions &lt;EM&gt;calculate_M1_to_M5&lt;/EM&gt; and &lt;EM&gt;LOAD_KEY&lt;/EM&gt; from AN5401SW in my code.&lt;/P&gt;&lt;P&gt;It works correctly (the &lt;EM&gt;LOAD_KEY&lt;/EM&gt; function returns value 1 = NO_ERROR) for all KeyIDs (0x04 – 0x0D, 0x14 – 0x18) when the master key is used for authorization.&lt;/P&gt;&lt;P&gt;It also works correctly for KeyIDs 0x04 – 0x0D and 0x15 and 0x17, when the old value of the key itself is used for authorization.&lt;/P&gt;&lt;P&gt;However, when I use the old value of the key itself for authorization, the &lt;EM&gt;LOAD_KEY&lt;/EM&gt; function returns value 8 (KEY_INVALID) for KeyIDs 0x14, 0x16, 0x18.&lt;/P&gt;&lt;P&gt;I am sure that the key value used for authorization is correct (the blank key 0xff…ff). I have tested that &lt;EM&gt;LOAD_KEY&lt;/EM&gt; function returns value 0x80 (KEY_UPDATE_ERROR) when wrong value of the authorization key is used.&lt;/P&gt;&lt;P&gt;I have tested it several times. I always unsecure device by the following sequence:&lt;/P&gt;&lt;P&gt;DBG_CHAL,&lt;/P&gt;&lt;P&gt;DBG_AUTH,&lt;/P&gt;&lt;P&gt;FLASH_DRV_EraseAllBlock,&lt;/P&gt;&lt;P&gt;FLASH_DRV_Program configuration fields on address 0x0400 by values {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFE,0x7F,0xFF,0xFF};&lt;/P&gt;&lt;P&gt;FLASH_DRV_DEFlashPartition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have anybody any idea what can be the root of the problem?&lt;/P&gt;&lt;P&gt;I can use it with master key authorization, but I want to be sure that I understand the process well.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Libor Waszniowski&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 07:11:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/CSEc-command-LOAD-KEY-returns-ERC-KEY-INVALID-for-some-KeyIDs-on/m-p/1881286#M36240</guid>
      <dc:creator>lwaszniowski</dc:creator>
      <dc:date>2024-06-05T07:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: CSEc command LOAD_KEY returns ERC_KEY_INVALID for some KeyIDs on S32k148</title>
      <link>https://community.nxp.com/t5/S32K/CSEc-command-LOAD-KEY-returns-ERC-KEY-INVALID-for-some-KeyIDs-on/m-p/1882363#M36287</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/145729"&gt;@lwaszniowski&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I reported a bug in function calculate_M1_to_M5() short time ago. It looks like the root cause is the same in your case. See please the report and suggestion how to fix it below:&lt;/P&gt;
&lt;P&gt;***&lt;/P&gt;
&lt;P&gt;In case of keys from second bank (when KBS = 1, keys KEY_11 - KEY_17), it is not possible to use the same key as authorization key when loading a key. Only MASTER_ECU_KEY can be used.&lt;/P&gt;
&lt;P&gt;Reason:&lt;/P&gt;
&lt;P&gt;AN5401 says that KBS field should not be considered when calculating M1 and M4 values:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lukaszadrapa_0-1717650875246.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/282766i13BF8C88AF947261/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lukaszadrapa_0-1717650875246.png" alt="lukaszadrapa_0-1717650875246.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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="lukaszadrapa_1-1717650875053.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/282767i7214BB0782E051DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lukaszadrapa_1-1717650875053.png" alt="lukaszadrapa_1-1717650875053.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, the function calculate_M1_to_M5() masks KBS only in case of key_id:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lukaszadrapa_2-1717650875130.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/282765iD9392FCA9AA6A8E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lukaszadrapa_2-1717650875130.png" alt="lukaszadrapa_2-1717650875130.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If such M1-M5 values are used to load a key to second bank when using the same key as authorization key, ERC_KEY_INVALID is returned.&lt;/P&gt;
&lt;P&gt;The solution is to add also this code here:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;auth_key_id = auth_key_id &amp;amp; 0x0F;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Then everything works as expected.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Lukas&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 05:17:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/CSEc-command-LOAD-KEY-returns-ERC-KEY-INVALID-for-some-KeyIDs-on/m-p/1882363#M36287</guid>
      <dc:creator>lukaszadrapa</dc:creator>
      <dc:date>2024-06-06T05:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: CSEc command LOAD_KEY returns ERC_KEY_INVALID for some KeyIDs on S32k148</title>
      <link>https://community.nxp.com/t5/S32K/CSEc-command-LOAD-KEY-returns-ERC-KEY-INVALID-for-some-KeyIDs-on/m-p/1882431#M36290</link>
      <description>&lt;P&gt;Thank you very much for fast response, it really works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Libor Waszniowski&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 06:24:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/CSEc-command-LOAD-KEY-returns-ERC-KEY-INVALID-for-some-KeyIDs-on/m-p/1882431#M36290</guid>
      <dc:creator>lwaszniowski</dc:creator>
      <dc:date>2024-06-06T06:24:07Z</dc:date>
    </item>
  </channel>
</rss>

