This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF52840 Cryptocell EC signature verify getting stuck in a loop

Using a NRF52840 running zephyr and mcuboot, the function nrf_cc310_bl_ecdsa_verify_secp256r1() is getting stuck in a loop.

I am using NRFXLIB v1.1.0

Looking at the disassembly window in my IDE

PkaEcdsaVerify is getting tuck in a loop and never returning.  

The loop assembly consists of the following

F8D83000    ldr.w r3, [r8, #0]

    931C        str r3, [sp, #0x70]

    9B1C        ldr r3, [sp, #0x70]

    07DB        lsls r3, r3, #31

    D5F9        bpl 0x000104E4

When i first get to these s lines of assembly,

r3 is 0x5002b080

r8 is 0x5002b0b4 (the value at #0 here is zero, so r3 becomes zero after the first line and never changes again.)

Any thoughts?

  • I was able to get the signature checking to work by using 

    mbedtls_ecdsa_verify()

    instead of 

    nrf_cc310_bl_ecdsa_verify_secp256r1()

    Of course, using mbedtls_ecdsa_verify() took a whole lot of extra work to be able to transform the signature, and public key into the correct formats. It also increased the size of the bootloader significantly by requiring me to include a number of extra MBEDTLS code to do the setup and transformations necessary to get the inputs to this function.  And it forced me to hack some MCUboot code I would have rather left un-hacked up.

    So I would still appreciate some resolution if possible, but I have a work around worst case scenario.

  • Hi,

    I am glad you found a workaround. The R&D team is working on improving the crypto support in nRF Connect SDK, and they are aware of this specific issue, but I cannot say when we will have a better solution.

    That said, I am a bit puzzled that how you import the signature and public key mattered since they are valid. Just a shot in the dark, but could it be that you just had the wrong endianness? Could you try to swap the endianness and see? (If so, remember to swap the two halfs of the public key separately).

Related