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.

Do TI-RTOS has an inbuilt encryption mechanism like aes ?

Other Parts Discussed in Thread: CC1310

I found AES include files in contiki. Likewise is there any inbuilt include files in TI-RTOS?

  • For some devices, yes, TI-RTOS provides some encryption support.  For example, for CC26xx devices, we provide a driver for the AES security module within the device.  The driver and header file are located in the TI-RTOS installation, for example: C:\ti\tirtos_cc13xx_cc26xx_2_16_01_14\products\tidrivers_cc13xx_cc26xx_2_16_01_13\packages\ti\drivers\crypto

    Is this what you are looking for?  If not, can you please be more specific which device, and what type of encryption support you are looking for?

    Thanks,
    Scott

  • Hi Scott,

    Thank you for the kind reply.

    I am looking for the support for CC26xx device itself. Does TI-RTOS support aes ENCRYPTION as well as DECRYPTION?

    Thank You,

    Aneeshya Rose

  • Hi Aneeshya Rose,

    Yes, the crypto driver supports both encrypt/decrypt, for: AES-ECB, AES-CBC, and AES-CCM.

    Regards,
    Scott

  • Sorry to piggy back on this thread, but there are only very sketchy examples and minimal discussion for encryption/decryption. I am initiating CryptoCC26XX_AESCCM_Transaction on CC1310 with operation CRYPTOCC26XX_OP_AES_CCM and it is giving a binary message in the transaction.msgout.

    To decrypt should I be using CRYPTOCC26XX_OP_AES_CCMINV operation? - however when I use this, it is NOT decrypting back to the original text.

    Can you please provide some code for AESCCM?
  • Which version of TI-RTOS are you using? The API Reference documentation (doxygen) has been improved in newer versions.
  • I am using 2_16_01_14 the latest available to public.

    The documentation has only AES-CCB example

    I just used the same format and made appropriate changes for AES-CCM - I am trying to encrypt followed by decrypt sequentially in the same function

    Psedo code as below

    CryptoCC26XX_init();   
    
    cryptoparams init();
    
        CryptoCC26XX_Transac_init((CryptoCC26XX_Transaction *) &trans, CRYPTOCC26XX_OP_AES_CCM);
    
    handle  = cryptoopen();
    
    allocatekey();
    
    cryptotransact()
    
    cryptorelease();
    
    
    

    For decrypt

    cryptoparams init();
    
        CryptoCC26XX_Transac_init((CryptoCC26XX_Transaction *) &trans, CRYPTOCC26XX_OP_AES_CCM_NOCRYPT); // IS THIS CORRECT?
    
    handle  = cryptoopen();
    
    allocatekey();
    
    cryptotransact()
    
    cryptorelease();
    
    
    

    To decrypt should we specify INV operation or NOCRYPT operation - it is not very clear - for AESCCB there is only NOCRYPT - hence I used CCM_NOCRYPT but the transact method hangs with it. When I use CCM_INV the function proceeds but doesn't decrypt but gives some other text.

    I using the following transaction values for decryption

    char *nonce = "teletubby1234567";
    char *header = "thomasmyheader12345678";
    uint8_t ccmLVal = 2;
    uint16_t msglength = 16;

    //encryption
           trans.keyIndex         = keyIndex;
    	        trans.authLength  =8;
    	        trans.nonce = nonce;
    	        trans.header = header;
    	        trans.fieldLength = ccmLVal;
    	        trans.msgInLength = 16;
    	        trans.headerLength = sizeof(header);
    	        trans.msgIn            = (char *) texttoencrypt;
    	        trans.msgOut           = (char *)encmsgout;
    	 

    //decrypt
           trans2.keyIndex         = keyIndex;
                trans2.authLength  =8;
                trans2.nonce = nonce;
                trans2.header = header;
                trans2.fieldLength = ccmLVal;
                trans2.msgInLength = 16;
                trans2.headerLength =sizeof(header) ;
                trans2.msgIn            = (char *) encmsgout;
                trans2.msgOut           = (char *)dencmsgout;
         

  • After several rounds of debuging, I have discovered that in case of  AESCCM - the structure defined below in CryptoCC26XX.h


     

    typedef struct CryptoCC26XX_AESCCM_Transaction {
        CryptoCC26XX_Operation  opType;         /*!< The type of the crypto operation */
        CryptoCC26XX_Mode       mode;           /*!< The mode of current transaction. Set by transact function. */
        uint8_t                 keyIndex;       /*!< The key store index to be used */
        uint8_t                 authLength;     /*!< Is the the length of the authentication field - */
                                                /*!< 0, 2, 4, 6, 8, 10, 12, 14 or 16 octets. */
        char                   *nonce;          /*!< A pointer to 13-byte or 12-byte Nonce. */
        char                   *msgIn;          /*!< A pointer to the octet string input message */
        char                   *header;         /*!< The Additional Authentication Data or AAD */
        void                   *msgOut;         /*!< A pointer to the output message location */
        uint8_t                 fieldLength;    /*!< The size of the length field (2 or 3) */
        uint16_t                msgInLength;/*!< The length of the message */
        uint16_t                headerLength;   /*!< The length of the header in octets */
    } CryptoCC26XX_AESCCM_Transaction;
    
    

    the msgin pointer seems to be holding the encrypted result - can you please confirm is this as intended or a bug or I am mistaken?

  • No. The msgOut should contain the encrypted/decrypted (depending on what you are doing) result. Can you attach the file that has your code? Please attach and not copy/paste. You can attach with the "use rich formatting" after you hit reply.

    Todd

  • 5460.PacketTxTask.c

    Code attached as requested.

    I have added comments in the code as to what I am observing.

     This is the output I see on my console

    [Cortex_M3_0] Clear text msg before assigning : K...1 
    Clear text msg after encryption : �=�I���N�햶8+̓(
    Clear text msg after encryption : �,�
    Base64 encoded Encrypted text msg : uj3pSYOD506e7Za2OCvMkw== 
    Encout  Encrypted text msg :               Hi 
    T1: 136 ,T2: 202 ,Freq: 65536,Delta: 1.0070 ms
    Clear text msg before assigning : �...+ 
    Clear text msg after encryption : KRISHNA KUMAR123(
    Clear text msg after encryption : K,3
    Base64 encoded Encrypted text msg : S1JJU0hOQSBLVU1BUjEyMw== 
    Encout  Encrypted text msg :               �� 
    T1: 327690 ,T2: 327766 ,Freq: 65536,Delta: 1.1596 ms
    Clear text msg before assigning : K...1 
    Clear text msg after encryption : �=�I���N�햶8+̓(
    Clear text msg after encryption : �,�
    Base64 encoded Encrypted text msg : uj3pSYOD506e7Za2OCvMkw== 
    Encout  Encrypted text msg :               Hi 
    T1: 655368 ,T2: 655444 ,Freq: 65536,Delta: 1.1596 ms
    

  • Thanks. I've reproduced the problem and I'm checking with the engineer that wrote the crypto code to see what's up...

    Todd
  • Any update on this?
  • The right engineer is looking at this now. I should have some feedback soon.

    Todd

  • I received this back

    "In the driver implementation, the encryption of the payload is performed in place.  The encrypted MAC (message authentication code) is placed in the msgOut buffer. The MAC is of length authLength bytes as specified in the transaction struct. When you want to decrypt the message and authenticate is, you need to concatenate the encrypted payload and MAC and then decrypt this with the same nonce, header, and key. I have modified the example code you sent us to show how this is done."

    1513.CCM_crypto_error.c

    Todd

  • I guess the code example works only with new RTOS version as the encryption type is not available in 2.16

    CryptoCC26XX_Transac_init((CryptoCC26XX_Transaction *) &trans,
    CRYPTOCC26XX_OP_AES_CCM_ENCRYPT);

    I think there is some bug in your website's alert option I subscribed to the alert on 14th June- I expected an alert when new RTOS was released, I never received any - checked SPAM as well. I just realised that the new version has been released 12 days back.

    I will test with this new code and the new version of RTOS.