<?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>topic Re: LPC43S50 AES issue in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC43S50-AES-issue/m-p/575998#M19346</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rmilne on Wed May 27 12:13:43 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Well i just keep answering my own questions here (feels like a blog).&amp;nbsp; Turns out that Chip_AES_LoadKeySW and Chip_AES_ProgramKey do work but only if the code is loaded by the secure boot feature.&amp;nbsp; My steps using IAR with JLink with code programmed to SPIFI:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1/ Build your project and link for a zero starting address (UM says 0x10000000 - I disagree)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2/ Sign the binary with image_manager.exe (AES capable one provided by NXP after signing export control agreement):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;C:\NXP\LPCScrypt\bin&amp;gt;image_manager -key 00000000000000000000000000000000 -i C:\path\to\out.bin -o C:\path\to\out.bin.hdr --bin&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3/ Delete the .hdr extension from the file written by step 2.&amp;nbsp; Start JLink.exe in the same directory as the encrypted binary and load it to the SPIFI:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NB: Use the latest beta release of the jlink drivers - lpc43xx spifi programming was fixed just a few days ago&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;J-Link&amp;gt;loadbin out.bin 0x14000000&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4/ Run the debugger without loading the code.&amp;nbsp; Note also that SWO won't work in this mode.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;5/ Inaudible sigh of relief from my cubicle&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 19:03:09 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T19:03:09Z</dc:date>
    <item>
      <title>LPC43S50 AES issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC43S50-AES-issue/m-p/575996#M19344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rmilne on Wed May 27 06:36:10 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I cannot get aes ROM encryption to work properly on my LPC43S50 part and hopefully someone can point out my problem by looking at my code sample.&amp;nbsp; I use the same key &amp;amp; data provided in section 8.5.5 of UM10503 and have verified the output on an offline tool.&amp;nbsp; My results are 0x82, 0xa2, ... instead of the expected 0xc5, 0xcc, ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've coded the following test according to my interpretation of the document and have run out of ideas for getting the proper output.&amp;nbsp; Built with IAR EWARM 7.2.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there sample code available for reference?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
static bool is_init = false;
static uint8_t out_buf[16];

bool aesTest(void) {
&amp;nbsp; uint32_t retval;
&amp;nbsp; uint8_t test_key[16] = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
&amp;nbsp; uint8_t test_data[16] = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };

&amp;nbsp; if(!is_init) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; retval = Chip_AES_Init();
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(retval == 0)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; is_init = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;
&amp;nbsp; }

&amp;nbsp; Chip_AES_LoadKeySW(test_key);

&amp;nbsp; retval = Chip_AES_SetMode(CHIP_AES_API_CMD_ENCODE_ECB);
&amp;nbsp; if(retval != 0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;

&amp;nbsp; retval = Chip_AES_Operate(out_buf, test_data, 1);
&amp;nbsp; if(retval != 0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;

&amp;nbsp; return true;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:03:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC43S50-AES-issue/m-p/575996#M19344</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: LPC43S50 AES issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC43S50-AES-issue/m-p/575997#M19345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rmilne on Wed May 27 11:41:22 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;...update. I found aes example code inside lpcopen_2_16_keil_iar_nxp_lpcxpresso_4337.zip and the entire array of data, key and output is completely reversed (little endian in both byte and word order)! Weird (and inefficient for network ordered data) but I can work with it. Unfortunately my test still fails because the key seems to be stuck at all zeros - the Chip_AES_LoadKeySW call has no effect. It looks like the only key I'm permitted is zeros. Do I have to program key zero (and lose my jtag) to get this to work?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW - I tried to program key 1 to test a non-zero key and it returned OK but actually failed because it too is still just zeros. Programming a second time returned 0x30003 (already programmed) but it is incorrectly programmed. Encryption with this key is again giving me the results of a zero key. Arrrgh!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:03:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC43S50-AES-issue/m-p/575997#M19345</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: LPC43S50 AES issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC43S50-AES-issue/m-p/575998#M19346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rmilne on Wed May 27 12:13:43 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Well i just keep answering my own questions here (feels like a blog).&amp;nbsp; Turns out that Chip_AES_LoadKeySW and Chip_AES_ProgramKey do work but only if the code is loaded by the secure boot feature.&amp;nbsp; My steps using IAR with JLink with code programmed to SPIFI:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1/ Build your project and link for a zero starting address (UM says 0x10000000 - I disagree)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2/ Sign the binary with image_manager.exe (AES capable one provided by NXP after signing export control agreement):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;C:\NXP\LPCScrypt\bin&amp;gt;image_manager -key 00000000000000000000000000000000 -i C:\path\to\out.bin -o C:\path\to\out.bin.hdr --bin&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3/ Delete the .hdr extension from the file written by step 2.&amp;nbsp; Start JLink.exe in the same directory as the encrypted binary and load it to the SPIFI:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NB: Use the latest beta release of the jlink drivers - lpc43xx spifi programming was fixed just a few days ago&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;J-Link&amp;gt;loadbin out.bin 0x14000000&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4/ Run the debugger without loading the code.&amp;nbsp; Note also that SWO won't work in this mode.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;5/ Inaudible sigh of relief from my cubicle&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:03:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC43S50-AES-issue/m-p/575998#M19346</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: LPC43S50 AES issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC43S50-AES-issue/m-p/575999#M19347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by jsidebottom on Wed May 27 21:22:21 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for sharing, even if you aren't getting any help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've got one of these ordered, and am grateful to you (in advance) for the avoided frustration.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:03:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC43S50-AES-issue/m-p/575999#M19347</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: LPC43S50 AES issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC43S50-AES-issue/m-p/576000#M19348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rmilne on Thu May 28 06:35:32 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;You're welcome.&amp;nbsp; An open engineering community is a happier place to be than a closed one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another find while I'm at it...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The aes ROM will also work using an unencrypted binary as long as the header is present.&amp;nbsp; My original programs failed because I was using IAR to load the binary which of course has no in-built feature to prepend a header.&amp;nbsp; Using the generic LPCScrypt tool will do fine for development (-key attribute not available).&amp;nbsp; Also the system requires a power cycle before the aes ROM will function - issuing a reset via the debugger after loading is insufficient.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:03:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC43S50-AES-issue/m-p/576000#M19348</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:03:10Z</dc:date>
    </item>
  </channel>
</rss>

