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.

CC1352P: CC1352P bootloader ECDSA ROM function problem

Part Number: CC1352P

Hi,

I am using the BIM example as a basis to test ECDSA functionality (using SDK 2.40.0.47)

I wrote a small test in the BIM project that uses ECSDA, just to check that it works as expected with my signing tool. 

My application gets stuck in ECDSA_verif. If I look at the dissasembly, the application is in a permenant branch to the same address:

E7FE                b          #0x100020c0

This only happens when optimization is turned off. 

My test function is quite simple also: 

static void EcdsaTest()
{
    char msg[] = "hello";
    uint8_t tempWorkzone[ECDSA_SHA_TEMPWORKZONE_LEN];
    memset(tempWorkzone, 0, ECDSA_SHA_TEMPWORKZONE_LEN);
    int8_t verifyStatus = FAIL;
    uint8_t *finalHash;
    uint8_t sigr[32] = { 0xC9,0xEE,0x23,0x44,0xF4,0xAE,0x78,0xFC,0x6A,0x92,0x0C,0xEA,0xB8,0xC6,0x1F,0x85,0xF0,0xB2,0x04,0xE4,0x1A,0x3A,0x5C,0xF2,0x19,0xBA,0x0D,0xF6,0x52,0x5D,0x55,0x21};
    uint8_t sigs[32] = {0x9F,0x83,0x6D,0x1D,0x38,0x56,0xBC,0x49,0x40,0xBF,0x78,0xA8,0x63,0x05,0xE5,0xAB,0x86,0xEA,0x16,0xCC,0xB7,0x60,0xD9,0xF2,0x0A,0x51,0xC5,0x4B,0xC6,0xD4,0xA1,0xDB};
    finalHash = hash((uint8_t*)msg, sizeof(msg));

    verifyStatus = bimVerifyImage_ecc(_secureCertElement.certPayload.eccKey.pubKeyX,
                                      _secureCertElement.certPayload.eccKey.pubKeyY,
                                       finalHash,
                                       sigr,
                                       sigs,
                                       eccWorkzone,
                                       tempWorkzone);
}

uint8_t *hash(uint8_t *data, uint32_t len)
{
    SHA256_memory_t workzone;
    SHA2CC26XX_initialize(&workzone);
    SHA2CC26XX_execute(&workzone, data, len);
    SHA2CC26XX_output(&workzone, finalHash);
    return finalHash;
}



You could paste the above code into the BIM project and it should produce the same effects. 


I also see that the ECDSA_verif functon expects the first 32 bit word to contain the length. This is not in any documentation that I can see, and its only understood by looking at the bimVerifyImage_ecc function. Is there any more documentation for these ROM functions?

  • Hi Garry,

    You can find documentation on these ROM functions here:
    dev.ti.com/.../_e_c_d_s_a_8h.html

    Best Regards,
    R.M
  • Hi,

    The link you sent me are not ROM functions. They are driverlib functions that use the sys bios.
    The BIM does not use TI RTOS because its meant to be a small bootloader that fits into one sector (8kb).

    The function ECDSA_verif is different. It is mapped directly to a ROM function.
    The prototype is:
    extern uint8_t ECDSA_verif(uint32_t *, uint32_t *, uint32_t *, uint32_t *,
    uint32_t *);

    Just to make it clear my questions are:
    1. Why does the code get stuck in ECDSA_verif with optimizations off.
    2. If there are any documentation on these ROM functions.
  • Hi Gary,

    1. The code gets stuck in ECDSA_verif with optimization off because of a linker file error. RAM_START needs to start at 0x2000000 + RESERVED_RAM_SIZE and RAM_END should be at 0x20014000. Please see fixed linker file below:

    * RAM
    */
    /* Reserved RAM is that section of the RAM used by the ROM code.
    * For Secure BIM, the ECC library from ROM uses 0x80 bytes of
    * RAM space at the end of the RAM. Even though the ECC library
    * from ROM is not used by the non-secure BIM, to keep the linker
    * command file simple and uniform across the two variants, the
    * reserved section is defined here commonly for both variants.
    * ROM code actually uses slightly <0x300 bytes; Leaving this
    * section of the RAM untouched by BIM application
    */
    #define RESERVED_RAM_SIZE                (0x300)
    
    /*
    * Defines for BIM variable
    */
    #define RAM_START             (RAM_BASE + RESERVED_RAM_SIZE)
    
    
    
    #define RAM_END             (RAM_START + RAM_SIZE - RESERVED_RAM_SIZE - 1)
    
    /* App is given full RAM range (minus ROM reserved offset) when Stack image is not present. */
    #define RAM_BIM_SIZE          (RAM_END - RAM_START + 1)
    

    With optimization turned on it works because the linker happens not to put anything important there. The bug has been reported and will be fixed in the next SDK release. Thank you for reporting the problem.

    2. The only available information on the ROM functions is what you find in driverlib/rom_crypto.c/h

    Best Regards,

    R.M