lpcware

LPC43S50 AES issue

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by rmilne on Wed May 27 06:36:10 MST 2015
Hi,

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.  I use the same key & data provided in section 8.5.5 of UM10503 and have verified the output on an offline tool.  My results are 0x82, 0xa2, ... instead of the expected 0xc5, 0xcc, ...

I've coded the following test according to my interpretation of the document and have run out of ideas for getting the proper output.  Built with IAR EWARM 7.2. 

Is there sample code available for reference?
  

static bool is_init = false;
static uint8_t out_buf[16];

bool aesTest(void) {
  uint32_t retval;
  uint8_t test_key[16] = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
                           0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
  uint8_t test_data[16] = { 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
                            0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };

  if(!is_init) {
    retval = Chip_AES_Init();
    if(retval == 0)
      is_init = true;
    else
      return false;
  }

  Chip_AES_LoadKeySW(test_key);

  retval = Chip_AES_SetMode(CHIP_AES_API_CMD_ENCODE_ECB);
  if(retval != 0)
    return false;

  retval = Chip_AES_Operate(out_buf, test_data, 1);
  if(retval != 0)
    return false;

  return true;
}

Outcomes