This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AES

Other Parts Discussed in Thread: REMOTI, Z-STACK, CC2530

hai all,

Can anyone tell in which file AES security code is written. Also code for hardware AES core, ie, initialization of core and registers,etc

please help

arun

  • hal_aes.c and hal_ccm.c - but these files are not included in the ZStack installer, you would have to install the RemoTI stack to get them:

    http://www.ti.com/tool/remoti

     

  • if it is not included,how AES is working in Z-stack 2.5 when enabling -DSECURE=1

    thanks

    arun

  • Because that code it built into the NWK library.

  • Thanks for your support

  • Hello Yikai Sir and Harry,

    I have read about the code Hal_aes.c but i am not getting how compile and get it working can you please let me know how to use this code and get it working

    or reference for compile and result for the same

    thanks and regards

  • Hi Manish

    You can copy the hal_aes.c and hal_aes.h into your IAR project. Then, you can include hal_aes.h in your application and use the API in hal_aes.c.

  • Hello Yikai Sir,

    Thanks for reply I have done the same but AES engine work on DMA Channel also there are few things that need to be done Addround,ShiftRows,MixedColoums where i could get those function and how to debug that what will be output means how i come to know that I am doing write thing.

    As these function are not written and i am not finding them,

    one more thing how to generate the key encryption function and decryption function where to get it.

    thanks and regards

    Manish

  • Hello Yikai Sir,

    I have got your point and tried to implement a simple AES code where I just want to know API are working or not so i have written a following Snippet

    Encryption_FUNCTION()

    {

    uint8 KEY[16] = {0x54,0x43,0x21,0x32,0x43,0x54,0x34,0x56,0x67,0x65,0x78,0x87,0x97,0x54,0x12,0x45};
    uint8 IV[16] = {0x21,0x23,0x43,0x21,0x43,0x65,0x54,0x87,0x98,0x43,0x56,0x78,0x89,0x43,0x23,0x76};
    uint8 DATA[16] = {0x41,0xC1,0x34,0x54,0x54,0x21,0x87,0x65,0x45,0x54,0x34,0x67,0x95,0x36,0x78,0x65};
    uint8 DATA_OUT[16]= {0};
    HalAesInit();

    //AES_SET_ENCR_DECR_KEY_IV(0x04);
    ENCCS = 0x04;
    AesLoadBlock( KEY );
    //while(!(ENCCS & 0x08));
    ENCCS = 0x06;
    AesLoadBlock( IV );
    // while(!(ENCCS & 0x08));
    ENCCS = 0x00 | 0x01; // Only valid for encryption mode !
    ENCCS = 0x02 | 0x01;
    AesStartBlock( DATA_OUT, DATA );
    // while(!(ENCCS & 0x08));
    HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );
    HalLcdWriteScreen("MANISH",NULL);
    HalUARTWrite( SERIAL_APP_PORT,DATA_OUT,17);

    }

    this Function will be called on key event but AesStartBlock() function is calling the low level function in hal_aes.c but it is not filling any values in DATA_OUT and Nor it will filling any values in  unit8 *in and uint8 *out parameters of the function can you please tell me where i am wrong? is there any compilation flag required or any thing else i am missing as i am getting any error but the operation is not happening on values neither they are transferring to function.

    thanks and regards

    Manish

  • You can refer to the examples code in hal_ccm.c .

  •  Can you please detail what you are trying to implement AES encryption, it is built into ZStack. Do you require additional AES encryption on top of a manufacturer specific message? Can you use APS Security to AES encrypt the application payload? Or are you not interested in ZigBee and just use CC2530 for its AES capabilities?

    If you are not interested in ZigBee then there may be other SW releases that would suit you better.

    Regards, TC.

  • Hello TopCat,

    Thanks for your reply and concern, I have read about AES encryption CC2530 provides 128 bits AES encryption that is why I was just testing it for that I have gone through DN108 document in which it is written that we can write any value to ENCDI register and it will move into AES engine and we can get the output value from the register ENCDO but when I am trying to do it using some some arbitary key and IV along with data value ENCDI is not taking any input value

    void Encryption_SmartINetHB(void)
    {
    uint8 KEY[16] = {0x54,0x43,0x21,0x32,0x43,0x54,0x34,0x56,0x67,0x65,0x78,0x87,0x97,0x54,0x12,0x45};
    uint8 IV[16] = {0x21,0x23,0x43,0x21,0x43,0x65,0x54,0x87,0x98,0x43,0x56,0x78,0x89,0x43,0x23,0x76};
    uint8 DATA[16] = {0x41,0xC1,0x34,0x54,0x54,0x21,0x87,0x65,0x45,0x54,0x34,0x67,0x95,0x36,0x78,0x65};
    uint8 DATA_OUT[16]= {0};
    HalAesInit();
    AES_SETMODE(CBC);
    AES_SET_ENCR_DECR_KEY_IV(AES_LOAD_KEY);
    AesLoadBlock( KEY );
    while(!(ENCCS & 0x08));

    AES_SET_ENCR_DECR_KEY_IV(AES_LOAD_IV);
    AesLoadBlock( IV );
    while(!(ENCCS & 0x08));

    AES_SET_ENCR_DECR_KEY_IV(AES_ENCRYPT); // Only valid for encryption mode !
    AesStartShortBlock( DATA_OUT, DATA );
    while(!(ENCCS & 0x08));

    HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );
    HalLcdWriteScreen("MANISH",NULL);
    HalUARTWrite( SERIAL_APP_PORT,DATA_OUT,17);

    }

    in this code snippet I have taken a Random Key,IV and DATA value putting these value in AES engine and later want to reading it.

    but DATA_OUT is showing 0x00.

    Do i Need to have Any compile option enable or else what i need to do for writting data into AES engine and getting output from it.

    thanks and regards

    Manish

  • Hello TopCat And Yikai Chen,

    I am unable to see any encryption 

    unsigned char KEY[16] = {0x54,0x43,0x21,0x32,0x43,0x54,0x34,0x56,0x67,0x65,0x78,0x87,0x97,0x54,0x12,0x45};
    unsigned char IV[16] = {0x21,0x23,0x43,0x21,0x43,0x65,0x54,0x87,0x98,0x43,0x56,0x78,0x89,0x43,0x23,0x76};
    unsigned char DATA[16] = {0x41,0xC1,0x34,0x54,0x54,0x21,0x87,0x65,0x45,0x54,0x34,0x67,0x95,0x36,0x78,0x65};
    unsigned char DATA_OUT[16]= {0};

    uint8 i;

    ENCCS = 0x04 | 0x01;
    for (i = 0; i < 16; i++) {
    ENCDI = KEY[i];
    ENCDI;

    I have tried this but when i put break pint on  ENCDI it is showing '\0' 0x00 means nothing is write on encryption register why this is happening i dont know

    can you please can what should i do. I know AES is Default in Stack want to see how it works but unable to read or write any value on ENCDI or ENCDO can you please correct me

    thanks and regards

    Manish 

  • Hello Yikai Sir,

    As you said I have taken the reference of hal_ccm.c but it is not working I am trying for without DMA here I am sending my code snippet please let me know what to do

    void encryption_AES(void)
    {
    uint8 key[16] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
    uint8 IV[16] ={0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01};
    uint8 data[16] = {0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04};
    uint8 data_out[16] = {0};
    HalAesInit();
    AES_SETMODE(ECB);
    AesLoadKey( key );
    AesLoadIV( IV );
    AES_SET_ENCR_DECR_KEY_IV( AES_ENCRYPT );
    AesStartBlock( data_out, data );
    data_out;

    }

    need to get the encrypted  data on data_out , can i get it or i have to do some thing else

    thanks and regards

    Manish 

  • Hi Manish,

    Have you taken a look at this link: 

    http://www.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=swra209a

    It contains an application note and a SW package that can be taken a look at.

    Please also note, this forum is about ZigBee/6LoWPAN and MAC products.  it looks like you picked up on a previous thread and would like to use AES module on 2530, but not necessarily in Z-stack context.

    If that's the case, I suggest you also consider posting your queries onto the proprietary 2.4 Ghz forum: http://e2e.ti.com/support/wireless_connectivity/f/964.aspx

    I also recommend, for future queries, to open a new thread when your question is about substantially different than an earlier post, as it looks to be in this case.

    Thanks,

    TheDarkSide