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 ROM function: AES_CCM_DecryptData

Other Parts Discussed in Thread: CC1310

Hi

I find there is a ROM function for AES CCM decryption in SDK: AES_CCM_DecryptData.

But, my application get faults in this function call. Because, this function, AES_CCM_DecryptData, wants to jump to an invalid address.

The screenshot for my debug enviroment is attached.

Is there any inilizations required for this function call? Do I miss something for this function call?

Please let me know about that.


Thanks,

HH

  • Hi,

    the function you mention is part of the internal driverlib implementation. We ship the CC1310 with a bunch of driverlib and TI-RTOS kernel functions already preprogrammed in ROM.

    TI-RTOS provides a high-level crypto driver. But if you want to use the AES hardware accelerator based on driverlib in a Ti-RTOS application, then you can use the following code snippet for inspiration:

    #include <driverlib/crypto.h>
    #include <ti/drivers/power/PowerCC26XX.h>
    
    void testAes()
    {
        /* Enable the AES module */
        Power_setDependency(PowerCC26XX_PERIPH_CRYPTO);
        /* Prohibit standby. */
        // This is only necessary when doing blocking calls in the following code
        // or when leaving this function while using the crypto module
        Power_setConstraint(PowerCC26XX_SB_DISALLOW);
    
        /* Set up the variables */
        uint8_t aesKey[16] = {
                0x5a, 0x69, 0x67, 0x42, 0x65, 0x65, 0x41, 0x6c,
                0x6c, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x30, 0x39
        };
        uint8_t inputData[]= {
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
        };
        uint8_t encryptedData[sizeof(inputData)] = { 0 };
        uint8_t outputData[sizeof(inputData)] = { 0 };
    
        enum {
            Encrypt = 0x01,
            Decrypt = 0x00,
            InterruptsEnabled = 0x01,
            InterruptsDisabled = 0x00,
        };
    
        // The crypto HW can store up to 8 keys.
        //
        // For 128 bit key all 8 Key Area locations from 0 to 8 are valid
        // However for 192 bit and 256 bit keys, only even Key Areas 0, 2, 4, 6
        // are valid.
        //
        uint8_t keyIndex = CRYPTO_KEY_AREA_0;
    
        /* Load the key to the crypto unit */
        CRYPTOAesLoadKey((uint32_t*)aesKey, keyIndex);
    
        /* Start the encryption in blocking mode */
        CRYPTOAesEcb((uint32_t*)inputData, (uint32_t*)encryptedData, keyIndex, Encrypt, InterruptsDisabled);
        while (CRYPTOAesEcbStatus() != AES_SUCCESS);
    
        /* Decrypt the data again in blocking mode */
        CRYPTOAesEcb((uint32_t*)encryptedData, (uint32_t*)outputData, keyIndex, Decrypt, InterruptsDisabled);
        while (CRYPTOAesEcbStatus() != AES_SUCCESS);
    
        volatile int i;
        for (i = 0; i < sizeof(inputData); i++)
        {
            if (inputData[i] != outputData[i])
            {
                while (1);
                /* Fail */
            }
        }
    
        /* Allow standby and release the crypto module. */
        Power_releaseConstraint(PowerCC26XX_SB_DISALLOW);
        Power_releaseDependency(PowerCC26XX_PERIPH_CRYPTO);
    }

    All AES-related functions are stored in ROM if you use driverlib in ROM.

  • Hi Richard

    These functions you mentioned, CRYPTOAesLoadKey/CRYPTOAesEcb, are NOT in ROM. No ROM address define for these function, and these functions are linked in flash.
  • Thanks for the example!!

    There is only a litte mistake: after two times calling CRYPTOAesEcb it will not return successfully.

    To avoid this you have to call:

    CRYPTOAesEcbFinish();

  • Hello Richard,

    The crypto driver didn't work for me, I kept getting a AES_KEYSTORE_READ_ERROR, but your example works and seems more straight forward.

    What would be the advantages from your code compared to using the crypto driver? 

    Thanks and best regards,

    Sven

  • There is no real advantage and if only the high-level Crypto driver would have a better API and better documentation, I would always prefer to use the high-level driver instead of the low-level DriverLib API.
  • Thanks Richard! The high level implementation is very confusing. Your example works with the addition of CRYPTOAesEcbFinish();.

    Br,

    Sven