2022-01-31 08:41 AM
Hello,
I am using the SBSFU with the KMS on my STM32L486RG. I activated the verbose debug in the config file and this is the output that i am getting when flashing the binary file combining the boot-loader and my user application at the same time :
As you can see the boot-loader fails to verify the the authenticity of the Firmware. How can I debug this problem?
If I debug the SBSFU.elf alone from the STM32CubeIDE, the secure boot tells me that there is no firmware in the active slot (obviously) so does not verify it...
I am using ECCDSA for the firmware authenticity verification and using this same boot-loader configuration in a another project without any problem.
Thanks in advance for the help,
Benjamin
Solved! Go to Solution.
2022-02-01 02:37 AM
Thank you for the help everyone.
The issue was that because I use the KMS, the ECC public key is inserted in the kms_platf_objects_config.h file during prebuild.sh but for some reason even though i changed the private key in 2_Images\2_Images_SECoreBin\Binary. The public key was not updated during build.
So what I did is :
2022-01-31 09:11 AM
Hey all,
I noticed that the problem is linked to me changing the ECC DSA private key. I generated a key using
python3 prepareimage.py keygen -k ECCKEY1.txt -t ecdsa-p256
and placed ECCKEY1.txt in 2_Images_SECoreBin/Binary. If i change this key by the one provided in the example projects. The signature is verified correctly. Am i missing something ?
2022-01-31 03:09 PM
Validation presumably occurs with the PUBLIC KEY, if you change the private one, signing the image with it, expect to change the public one the authentication is using.
2022-01-31 11:48 PM
Hi,
when you use prepareimage with keygen command you generate a new private ECC key.
This private key gets stored in ECCKEY1.txt.
This key will never go into your device, it remains on your HOST PC side to sign the bundle.
On device side, we need to embed the corresponding ECC public key.
This is done by the tooling (prebuild stage) when recompiling the SECoreBin project.
So what you need to do is:
The problem is that the IDE will not detect that there is a dependency with ECCKEY1.txt, so you need to clean your project and rebuild it to make sure the prebuild stage is done again.
During this prebuild stage:
So, to make sure it goes well you can make a diff on this file (if you work with STM32CubeIDE):
Applications\2_Images\2_Images_SECoreBin\STM32CubeIDE\se_key.s
The content of se_key.s must have been updated with the new public key (SE_ReadKey_Pub).
This .s file gets compiled in your SECoreBin and will be used to verify the signature of your bundle.
You also need to regenerate SBSFU to integrate the updated SECoreBin binary.
At this point, your public and private keys should match and the verification should succeed.
Of course, do not forget to regenerate your bundle with your new private key on PC side (UserApp compilation and postbuild stage to sign it).
Thanks & Regards,
Fred
P.S.: what I write is without KMS, but the same principle should apply except that the public key will be injected in KMS embedded keys instead of going into a .s file. So probably you won't be able to make the diff easily.
2022-02-01 02:09 AM
Additional info can be found here: Integration guide for the X-CUBE-SBSFU STM32Cube Expansion Package - Application note
See section 5, especially 5.4
2022-02-01 02:37 AM
Thank you for the help everyone.
The issue was that because I use the KMS, the ECC public key is inserted in the kms_platf_objects_config.h file during prebuild.sh but for some reason even though i changed the private key in 2_Images\2_Images_SECoreBin\Binary. The public key was not updated during build.
So what I did is :