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.

LAUNCHXL-CC1310: using the cryptography module without using RTOS

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: CC1310

I want to test the AES module in my application, but all the examples uses on rtos and I want to use it without rtos I tried the examples suggested in but after the message is encrypted, the CryptoCC26XX_transact keeps running and never returns so i replaced it with CryptoCC26XX_transactPolling but the same problem occured, so
1. how can I use the example without RTOS?
2. why do both functions never return?

// Initialize Crypto driver structures

        // Open the crypto hardware with non-exclusive access and default parameters.
        handle = CryptoCC26XX_open(Board_CRYPTO0, false, NULL);

        if      (handle == NULL)
                printf("CryptoCC26XX did not open");

        uint8_t i;

        for     (i = 0; i < PAYLOAD_LENGTH; i++)
                ccmSetup.clearAndCipherText[i] = 'a';

        keyIndex = CryptoCC26XX_allocateKey(handle, ccmSetup.keyLocation, (const uint32_t *) ccmSetup.key);

        if      (keyIndex == CRYPTOCC26XX_STATUS_ERROR)
                printf("Key Location was not allocated.");

        /* Load key to the key register */
        CryptoCC26XX_loadKey(handle, keyIndex, (const uint32_t *)ccmSetup.key);

        // Encrypt and authenticate the message
        //change the op type hereeeeeeee
        CryptoCC26XX_Transac_init((CryptoCC26XX_Transaction *) &trans, CRYPTOCC26XX_OP_AES_CCM);

        trans.keyIndex = keyIndex;
        trans.authLength = macLength;
        trans.nonce = (char *) ccmSetup.nonce;
        trans.header = (char *) ccmSetup.header;
        trans.fieldLength = 3;
        trans.msgInLength = clearTextLength;
        trans.headerLength = aadLength;
        trans.msgIn = (char *) &(ccmSetup.clearAndCipherText[0]); // Message is encrypted in place
        trans.msgOut = (char *) &(ccmSetup.clearAndCipherText[clearTextLength]); // MAC will be written to this position
        status = CryptoCC26XX_transactPolling(handle, (CryptoCC26XX_Transaction *) &trans);

        if (status != CRYPTOCC26XX_STATUS_SUCCESS)
        printf("Encryption and signing failed.");

  • Hi Nada,

    Please see the following page for some examples on how to use the Crypto driver:

    As for 1) the answer is that you need to use the NoRTOS DPL layer. I do however in this case recommend staying with TI-RTOS if there id no good reason for doing it "No RTOS"-style as you will not save any flash in the process (the footprint for NoRTOS and TI-RTOS is quite similar as the latter has a lot of components in ROM).

  • Is there a guide to write my own application using directly the functions in crypto.c other than the datasheet?

  • I tried to use the functions in crypto.c but I think I am using them wrong. Also, I can not find how to initialize the crypto module?
    typedef struct
            uint8_t key[16];                                // A 128 Bit AES key
            uint32_t keyLocation;           // One of 8 key locations in the hardware
                        // A header that is not encrypted but is authenticated in the operation (AAD).
    } AesExample;

    AesExample Setup =
                .key = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
                        0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C},
                .keyLocation = CRYPTO_KEY_AREA_0,

    uint32_t data[]={1,2,3,4,5,6};
    uint32_t data_Out[40];

    void main(void)


        uint32_t keystat= NOROM_CRYPTOAesLoadKey((uint32_t *) Setup.key, Setup.keyLocation);
            printf("error key loadng");
        uint32_t stat= NOROM_CRYPTOAesEcb(data, data_Out, Setup.keyLocation, 4, 0);
            printf("error encryption");


    This is the code I wrote and of course it is missing many things. Can you provide me with a guide to write the applcation using only the functions in the file crypto.c

  • HI Nada,

    There is no guide on how to do this, the best suggestion I could give you is to look at the CryptoCC26XX.c driver file to see how the TI Drivers use the crypo library and try mimic this. In this case it is a good idea to look at how the TI Driver is used, which APIs is called and then how these are implemented and how they use the crypto DriverLib.

  • I have an issue in how can I enable the clock of the crypto module?

  • Hi Nada,

    If you would study the driver source code you would find that the "open()" API calls out to the power driver to enable the power and clocks. You could follow this API call and see how the power driver in turn does this. In short, you would need to (at the very least) setup the power domain using the PRCM APIs:

    I highly recommend you at least use the NoRTOS approach here instead of trying to do everything yourself. Not only is the power system rather complex, bringing the device into and out of standby takes a lot of considerations. All of this is handed to you freely, tested and verified to use. If you decide to go on without this, I can't really support you on matters of for example power saving etc.

    Also mind that the Radio is not trivial to interface with and you really want to be able to use the radio driver. To use this you at least need to use the NoRTOS DPL.

    What is your reason to not using TI-RTOS in this case?

  • What is your reason to not using TI-RTOS in this case?
    The reason is we do not use RTOS in our company's codes and projects, so we have to stick to not using RTOS.

    Also mind that the Radio is not trivial to interface with and you really want to be able to use the radio driver. To use this you at least need to use the NoRTOS DPL
    I do not understand this, do you mean that I can not work with the crypto module while working with the radio processor?

  • "Also mind that the Radio is not trivial to interface with and you really want to be able to use the radio driver. To use this you at least need to use the NoRTOS DPL"

    No, what I mean with this is that the recommendation is to interface with the TI-Drivers using the NoRTOS DPL layer provided in the SDK. NoRTOS is NOT an RTOS, it consist of a driver porting layer (DPL) to allow a user like you that do not work in an RTOS environment to leverage the TI drivers.

    The recommendation is to use this DPL as it allows you to use for example the TI Power driver (solves the power related parts of the software such as going in and out of low-power modes) and TI Radio driver. When using the DPL, you also get access to any other TI Driver such as the UART, Crypto, SPI etc. 

    It is worth making the point again that these drivers are not bound to any RTOS. While the "DriverLib" sounds like they would be drivers, these are really only register abstractions. The TI Drivers is actual driver implementations with all the logic needed for them to provide the expected function. 

  • ok, I do not know how to integrate the example with the nortos dpl, how can I do so?

  • Hi Nada,

    I suggest you have a look at the NoRTOS examples from the SDK. The basic steps is something on the line with:

    * Add in NoRTOS DPL source to the project

    * Add in drivers you want to use

    * Use NoRTOS DPL for your power and clock requirements (to avoid having conflicts with custom power management code).

  • I managed to write the code all by my self, I have some issues in the timing as when the encryption finishes and in the CCM mode, when to start to get the authentication results, but I guess all of these timing problems can be handled using interrupts, right?

    I have another question concerning choosing a key for the encryption, do I need to generate the key using the random number generator and then using the ECC algorithm or just choosing some random numbers will work? as I do not understand what is really happenning in generating the keys in the AES Key Agreement example.

  • I would recommend trying to read up a bit on the encryption scheme in general. You could use what ever key you want but this would also mean that you in many cases might suffer in security. The private key is something that should be unique to the device, the public key is the commonly shared part in the transaction. 

  • I read abou the encryption schemes and started to use the aes key agreement  example but have problems in the malloc function although I modified the linker file as suggested as a reply to one of the questions on the forum. Can I use the ECC without using the malloc for generating the work zone?

  • Hi Nada,

    The ECC implementation in CC1310 ROM do require a workzone. I don't know what thread you are referring to but it is not clear what issue you have with the malloc function. In theory, you can simply put a static workzone array into RAM and use that instead of the dynamically allocated one.