Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nrf8240 Signature validation failed during testing

Hi , 

i am using nrf52840 dk board. and using 17.1 sdk for examples code.

i am trying to customize open bootloader code and trying to validate the signature of a input data by using nrf_dfu_validation_signature_check() API.

Note: - i am having my own public and signature data, which i fed to this function.

But i am getting "NRF_DFU_RES_CODE_INVALID_OBJECT" in return from the above API.

Below i attcahed the calling function with input parameters.

static uint8_t m_message[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const size_t m_message_len = 36; // Skipping null termination

Regards

  • Hi,

    R_S said:

    And above this can i c ross check my created signature whether it is ok or not.

    is there any way to do that....?

    The only way I can see to do that is to do the validation operation and ensure that it is successful. Also, there is not really much information you can get about what is wrong wen you you validate the signature. Either it validates OK, or there is a problem.

    R_S said:
    i am following this user guide to generate private key. but what about the signature data, how can i generate that so that i can cross check whether there is an issue with my signature or not.

    I see you use nrfutil, and the nRF5 SDK bootloader, with some modification. If you use  nrfutil to generate the upgrade image and an unmodified bootloader, this will work assuming you did not accidentally use wrong keys (for instance forget to build the bootloader with the public key that corresponds to the private key you used with nrfutil). If you have checked the keys it would be interesting to know which changes you have done in the bootloader? Perhaps you can backtrack and go back to the working SDK example and then see which change you does that cause problems?

  • yes public key i cross checked its the same which i generated, there is no confusion in that.

    And regarding changes i did, so the base code i am using nordic sdk open bootloader code.

    i comment out all nrf_bootloader_init part. below is my main function content.

    In IsSignatureVerified() i am calling API for validation .

    And before all these things i am using following steps to program my bootloader code and application code.

    1. Erase the entire flash

    nrfjprog.exe --family NRF52 --eraseall

    2.Program the MBR

    nrfjprog --reset --program mbr_nrf52_2.4.1_mbr.hex  --family NRF52 --sectoranduicrerase

    3.Program the Bootloader Settings

    nrfjprog --program settings.hex -f NRF52 -r

    4. Program the Bootloader

    nrfjprog --reset --program open_bootloader_usb_mbr_pca10056.hex --family NRF52 --sectoranduicrerase

    5. Program Blinky App

    nrfjprog --reset --program blinky_pca10056.hex --family NRF52 --sectoranduicrerase

    one controller boot up its start my open bootloader in that i am doing signature validation of the application code and then jump to the application part.

    but during validation it fails every time. and i am not sure which steps i am missing here.

    for validation i am reading the flash data of application code and store it in a local buffer (dataBuffer) and that buffer i am passing in the nrf_dfu_validation_signature_check() as input. 

    My intension only to validate the application hex file data which i flash directly to the controller.

    Regards

    Rohit Saini

  • Hi Rohit,

    So what you try to do here is just to verify the application before you start it on every boot, right?

    How do you generate the bootloader settings?

    Do you test with DUMMY defined here? If so, I don't see where this m_message comes from nor do I know how the signature you compare with is generated, so I cannot say much other than that as the verification fails there are issues with the data of some sort (could be anywhere). What I can say though is that this is supported by the unmodified bootloader SDK bootloader example, so you could simply do as is done there. When you generate the bootloader settings page you can specify that you want to use signature verification on every boot instead of just a CRC which is default using the --app-boot-validation VALIDATE_ECDSA_P256_SHA256 when you generate the settings page using nrfutil settings generate. Search for VALIDATE_ECDSA_P256_SHA256 in the bootloader code to see how it is used there.

  • HI Einar,

    yes you are right i am just verify my application before it start.

    bootloader settings i am using following command.

    nrfutil.exe settings generate --family NRF52840 --application blinky_pca10056.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 settings.hex

    and how to specify that i want to validate VALIDATE_ECDSA_P256_SHA256 while creating bootloader settings rather than CRC.

    Regards

    Rohit saini

  • Hi Rohit,

    You would have to expand your nrfutil command to something like this:

    nrfutil.exe settings generate --family NRF52840 --application blinky_pca10056.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 --app-boot-validation VALIDATE_ECDSA_P256_SHA256 --key-file /path/to/key_file.pem settings.hex 

    You should also set NRF_BL_APP_SIGNATURE_CHECK_REQUIRED to 1 in the bootloader's sdk_config.h to enforce it.

Related