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.

CC1310: CryptoCC26XX

Part Number: CC1310

Hi,

I have two tasks calling to CryptoCC26XX_transact.
I detected a scenario that both tasks call the same function at the same time, thus generating CRYPTOCC26XX_OP_AES_CCM_ENCRYPT_AAD_ONLY error.
I noticed that trans.mode was not initialized so I initialized it:

trans.mode             = CRYPTOCC26XX_MODE_BLOCKING;

but I still get into an error when both tasks enter this function.

What is missing in order to enable the CRYPTOCC26XX_MODE_BLOCKING successfully without an errors?

  • Hi Kobi,

    I see that in the crypto driver, CryptoCC26XX_transact() calls the cryptoTransactionExecute() function with the "polling mode = false". This automatically makes the transaction mode CRYPTOCC26XX_MODE_BLOCKING. And also forces the task to pend on a Semaphore to access the crypto module. 

    Please take a look at the CryptoCC26XX.c file in the SDK for the definition of the function but please do not modify this file. 

    Also, the CRYPTOCC26XX_OP_AES_CCM_ENCRYPT_AAD_ONLY is a transaction mode and not an error message.

    When you call the CryptoCC26XX_transact() what is the error code you are getting as the status returned by this?

     Regards,

    Sid

  • Hi Sid,




    The value of transactRes is 1



    I was confused with the lower enum, now I see CRYPTOCC26XX_OP_AES_CCM_ENCRYPT_AAD_ONLY is not refer to the upper enum CRYPTOCC26XX_STATUS_

    I didn't protect the following functions by a semaphore. which functions must be protected?
    - CryptoCC26XX_Transac_init

    - CryptoCC26XX_open

    - CryptoCC26XX_allocateKey

    - CryptoCC26XX_transact

    - CryptoCC26XX_releaseKey

    - CryptoCC26XX_close

    Regards,

    Kobi

  • Hi Kobi, 

    The driver itself uses a semaphore for sharing the crypto module resource, in the cryptoTransactionExecute() function. So you do not need to add an additional semaphore. 

    But it seems that the error you are getting is  AES_KEYSTORE_READ_ERROR. This is returned by CRYPTOCcmAuthEncrypt(), CRYPTOCcmInvAuthDecrypt() or CRYPTOAesCbc() operations. 

    What are the transaction parameters you are using? 
    Regards,
    Sid
     
  • Hi Sid,

    This is my function:
    There is no call in my project to any of the functions you mentioned in your reply.
    I don't use cryptoTransactionExecute function.


    void AES_CBC_encrypt( CryptoCC26XX_Handle crypto_Handle,
    CryptoCC26XX_Params cryptoParam,
    const AESCBCinfo_t *sAESCBCinfo,
    uint8_t conversiontMode )
    {
    int keyIndex;
    CryptoCC26XX_AESCBC_Transaction trans;

    // Initialize transaction
    CryptoCC26XX_Transac_init((CryptoCC26XX_Transaction *) &trans, conversiontMode);

    // Attempt to open CryptoCC26XX.
    bool exclusiveAccess = false;
    crypto_Handle = CryptoCC26XX_open(Board_CRYPTO, exclusiveAccess, &cryptoParam);
    PG_Assert(crypto_Handle);

    keyIndex = CryptoCC26XX_allocateKey(crypto_Handle, sAESCBCinfo -> ui8AESKeyLocation,
    (const uint32_t *) sAESCBCinfo -> ui8AESKey);

    if (keyIndex != CRYPTOCC26XX_STATUS_ERROR)
    {
    // Setup transaction
    trans.keyIndex = keyIndex;
    trans.nonce = (uint32_t *) sAESCBCinfo -> ui8AESInitVector;
    trans.msgIn = (uint32_t *) sAESCBCinfo -> ui8AESClearText;
    trans.msgOut = (uint32_t *) sAESCBCinfo -> ui8AESMsgOut;
    trans.msgInLength = sAESCBCinfo -> msgInLength;

    // Do AES-CBC operation
    int res = CryptoCC26XX_transact(crypto_Handle, (CryptoCC26XX_Transaction *) &trans);
    PG_Assert(CRYPTOCC26XX_STATUS_SUCCESS == res);
    if(CRYPTOCC26XX_STATUS_SUCCESS == res)
    {
    board_togglePin(NOT_USED_IOID_10);
    }
    else
    {
    nop();
    }
    CryptoCC26XX_releaseKey(crypto_Handle, &keyIndex);
    int crptoClose = CryptoCC26XX_close(crypto_Handle);
    PG_Assert(CRYPTOCC26XX_STATUS_SUCCESS ==crptoClose);
    }
    else
    {
    nop();
    PG_Assert(CRYPTOCC26XX_STATUS_SUCCESS ==keyIndex);
    }
    }

    This is the reason I get the error.
    Both tasks call CryptoCC26XX_transact at the same time

  • Hi Kobi,

    The CryptoCC26XX_transact() function calls the cryptoTransactionExecute function. Check the CryptoCC26XX.c file, there you can get the implementation of the CryptoCC26XX_transact() function. 

    If the functions are working successfully in other situations, I would assume it is an issue when the key is loaded by both the task at the same time, thus resulting in the  AES_KEYSTORE_READ_ERROR. 

    Please check if the error is generated when only one task is executing at a time. 

    I will look into what other causes of AES_KEYSTORE_READ_ERROR is possible. 

    Regards,

    Sid

  • Hi Sid,


    I don't find the c files in TI lib.
    Would you please supply the full path?
    Thank you

  • Hi Kobi, 

    You can find CryptoCC26XX.c in this path.


    simplelink_cc13x0_sdk_4_20_01_03\source\ti\drivers\crypto

    Regards,

    Sid