Content originally posted in LPCWare by bin.er on Thu Oct 08 20:59:12 MST 2015
I tried to encode AES 128 ECB test vendor and check the result, and the result is not as expected.
I am wondering the use of AES API of LPC43S37.
Test vector are
uint8_t key[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
uint8_t plain_text[] = {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a};
uint8_t out[] = {0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60, 0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97};
uint32_t i = 0;
Chip_AES_Init();
Chip_AES_LoadKeySW(key);
//Chip_AES_LoadIV_SW(iv);// no initial IV is required as ECB mode
ret = Chip_AES_SetMode(CHIP_AES_API_CMD_ENCODE_ECB);
Chip_AES_Operate(&compressed_text, &plain_text, 16); //also 1 was tried as 3rd argument
The compressed_text is not consistent with the expected result, thought it can be decrypted well by AES ECB engine of LPC43S37 ECB mode and recover the plain text.
compressed_text0x10000050uint8_t[64]
[0]0xB30x10000050uint8_t
[1]0xAE0x10000051uint8_t
[2]0x6C0x10000052uint8_t
[3]0xBF0x10000053uint8_t
[4]0xDD0x10000054uint8_t
[5]0x60 0x10000055uint8_t
[6]0xD70x10000056uint8_t
[7]0x5C0x10000057uint8_t
[8]0xEA0x10000058uint8_t
[9]0x0D0x10000059uint8_t
[10]0xBC0x1000005Auint8_t
[11]0xA20x1000005Buint8_t
[12]0x54 0x1000005Cuint8_t
[13]0x0E0x1000005Duint8_t
[14]0xB00x1000005Euint8_t
[15]0xED0x1000005Fuint8_t