Search code examples
aescontiki

AES encryption under contiki on CC2650


I am currently trying to add AES encryption to an existing beacon-demo that uses the TI cc2650 sensortag. I am using the AES API provided by contiki under core/lib. My main looks like this:

static const uint8_t AES_key[16] = { 0xC0 , 0xC1 , 0xC2 , 0xC3 ,
                                 0xC4 , 0xC5 , 0xC6 , 0xC7 ,
                                 0xC8 , 0xC9 , 0xCA , 0xCB ,
                                 0xCC , 0xCD , 0xCE , 0xCF };// AES Key

static uint8_t plain_text[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16}; // Plain-text to be encrypted.
const struct aes_128_driver AES_128;
.
.
.
printf("Plain_Text: %d \r\n", plain_text);
AES_128.set_key(AES_key);
AES_128.encrypt(plain_text);
printf("Encrypted_Text: %p\r\n", plain_text);

Unfortunately when I run the code the plain text is unchangeable. Using some extra prints, I realize that the encrypt function is working but the output is still unchangeable. Can someone please tell me what am I doing wrong here?

Please note that I already added the following line to my conf file:

#define AES_128_CONF aes_128_driver

Solution

  • Well as @kfx pointed out in the comments const struct aes_128_driver AES_128 was shadowing the global variable.