Unable to decrypt FIP on STM32MP13
I have followed the wiki to create my encryption keys;
https://wiki.st.com/stm32mpu/wiki/How_to_perform_Secure_Boot_from_Distribution_Package#Creating_encryption_key_for_STM32MP13--STM32MP21--STM32MP23_and_STM32MP25
Which suggest creating two keys for TF-A and FIP encryption.
But then in the same page it suggest we only load the encryption key for TF-A to OTP registers (i can not fit the FIP key into OTP anyways)
After i build my image with the following config;
SIGN_KEY = "../keys/privateKey00.pem"
SIGN_KEY_stm32mp13 = "../keys/privateKey00.pem"
EXTERNAL_KEY_CONF = "1"
SIGN_KEY_PASS = "pass pass pass pass pass pass pass pass"
SIGN_ENABLE = "1"
SIGN_TOOL = "/bin/STM32_SigningTool_CLI"
ENCRYPT_ENABLE = "1"
ENCRYPT_FSBL_KEY = "../keys/stm32mp_encryption_key.bin"
ENCRYPT_FSBL_KEY_stm32mp13 = "../keys/stm32mp_encryption_key.bin"
ENCRYPT_FIP_KEY = "../keys/stm32mp_encryption_key_256bits.bin"
ENCRYPT_FIP_KEY_stm32mp13 = "../keys/stm32mp_encryption_key_256bits.bin"
I get this error;
NOTICE: CPU: STM32MP135F Rev.Y
NOTICE: Model: EGate Rev D
NOTICE: Bootrom authentication succeeded
NOTICE: Reset reason (0x34):
NOTICE: BL2: v2.10-stm32mp1-r1.0(release):lts-v2.10.5-dirty(7c229848)
NOTICE: BL2: Built : 16:19:31, Jun 28 2024
NOTICE: TRUSTED_BOARD_BOOT support enabled
ERROR: File decryption failed (4)
ERROR: BL2: Failed to load image id 4 (-2)
Which makes sense because I assume TF-A uses the key in the OTP to decrypt the image, which would fail.
When I try to encrypt FIP using the same key as TF-A I get the following error;
| CMD> encrypt_fw \
| --key <my-key> \
| --nonce 1234567890abcdef12345678 \
| --fw-enc-status 0 \
| --in /yocto/build/tmp-glibc/work/egate_revd-oe-linux-gnueabi/fip-stm32mp/6.0/recipe-sysroot/optee/tee-header_v2-stm32mp135f-dk-custom-mx-optee.bin \
| --out /yocto/build/tmp-glibc/work/egate_revd-oe-linux-gnueabi/fip-stm32mp/6.0/recipe-sysroot/optee/tee-header_v2-stm32mp135f-dk-custom-mx-optee_Encrypted.bin
| ERROR: Unsupported key size: 32
| [TOOLS ERROR]: ENCTOOL optee header error
When I completely skip encryption and only use signed binaries I get yet another error;
NOTICE: CPU: STM32MP135F Rev.Y
NOTICE: Model: EGate Rev D
NOTICE: Bootrom authentication succeeded
NOTICE: Reset reason (0x34):
NOTICE: BL2: v2.10-stm32mp1-r1.0(release):lts-v2.10.5-dirty(7c229848)
NOTICE: BL2: Built : 16:19:31, Jun 28 2024
NOTICE: TRUSTED_BOARD_BOOT support enabled
ERROR: BL2: Failed to load image id 4 (-5)
Any suggestions?
