Skip to main content
kerp0w
Associate
July 10, 2020
Question

SBSFU SECoreBin failing to build with different AES Key

I'm trying to build the SECoreBIn, and have changed the key (OEM_COMPANY_1) in:

STM32CubeExpansion_SBSFU_V2.3.0/Projects/NUCLEO-G071RB/Applications/2_Images/2_Images_SECoreBin/Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin

If I have understood correctly from the Getting strated guilde, this is the symetric AES key used to encrypt the binary in the postscript.sh later.

0693W000001sgVNQAY.png

However, when I try to buld the SECoreBin, I am getting the following error from the python prepareimage.py script:

21:38:49 **** Incremental Build of configuration Debug for project NUCLEO-G071RB_2_Images_SECoreBin ****
make all 
"../../prebuild2.sh" "../.."
../..
Python 3.7.5
prepareimage with python script
python /Users/Development/AgileProject/G0_SBSFU/STM32CubeExpansion_SBSFU_V2.3.0/Middlewares/ST/STM32_Secure_Engine/Utilities/KeysAndImages/prepareimage.py conf ../../../Inc/se_crypto_config.h
SECBOOT_ECCDSA_WITH_AES128_CBC_SHA256 selected
ECCDSA_WITH_AES128_CBC_SHA256
python /Users/Development/AgileProject/G0_SBSFU/STM32CubeExpansion_SBSFU_V2.3.0/Middlewares/ST/STM32_Secure_Engine/Utilities/KeysAndImages/prepareimage.py trans -a GNU -k ../../../Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin -f SE_ReadKey -s .SE_Key_Data -v V6M
Traceback (most recent call last):
 File "/Users/Development/AgileProject/G0_SBSFU/STM32CubeExpansion_SBSFU_V2.3.0/Middlewares/ST/STM32_Secure_Engine/Utilities/KeysAndImages/prepareimage.py", line 759, in <module>
 args()
 File "/Users/Development/AgileProject/G0_SBSFU/STM32CubeExpansion_SBSFU_V2.3.0/Middlewares/ST/STM32_Secure_Engine/Utilities/KeysAndImages/prepareimage.py", line 756, in args
 subcmds[args.subcmd](args)
 File "/Users/Development/AgileProject/G0_SBSFU/STM32CubeExpansion_SBSFU_V2.3.0/Middlewares/ST/STM32_Secure_Engine/Utilities/KeysAndImages/prepareimage.py", line 53, in do_trans
 key = keys.load(args.key)
 File "/Users/Development/AgileProject/G0_SBSFU/STM32CubeExpansion_SBSFU_V2.3.0/Middlewares/ST/STM32_Secure_Engine/Utilities/KeysAndImages/keys.py", line 274, in load
 key = SigningKey.from_pem(pem)
 File "/Users/Development/AgileProject/G0_SBSFU/py3_env/lib/python3.7/site-packages/ecdsa/keys.py", line 828, in from_pem
 privkey_pem = string[string.index(b("-----BEGIN EC PRIVATE KEY-----")):]
ValueError: subsection not found
python /Users/Development/AgileProject/G0_SBSFU/STM32CubeExpansion_SBSFU_V2.3.0/Middlewares/ST/STM32_Secure_Engine/Utilities/KeysAndImages/prepareimage.py trans -a GNU -k ../../../Binary/OEM_KEY_COMPANY1_key_AES_CBC.bin -f SE_ReadKey -s .SE_Key_Data -v V6M : failed
make[1]: *** [makefile:74: pre-build] Error 1
make: *** [makefile:42: all] Error 2
"make all" terminated with exit code 2. Build might be incomplete.
 
21:38:51 Build Failed. 2 errors, 0 warnings. (took 1s.899ms)
 

This topic has been closed for replies.

1 reply

alister
Senior III
July 11, 2020

>ValueError: subsection not found

The string.index's raising ValueError because it can't find "-----BEGIN EC PRIVATE KEY-----".

https://docs.python.org/3/library/stdtypes.html