Re: Secure boot and signed bins
Posted: Mon Dec 03, 2018 1:09 pm
Hi Angus,
I also enable flash encryption in menuconfig.
# Security features
#
CONFIG_SECURE_SIGNED_ON_BOOT=y
CONFIG_SECURE_SIGNED_ON_UPDATE=y
CONFIG_SECURE_SIGNED_APPS=y
CONFIG_SECURE_BOOT_ENABLED=y
CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH=y
CONFIG_SECURE_BOOTLOADER_REFLASHABLE=
CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES=
CONFIG_SECURE_BOOT_VERIFICATION_KEY="signature_verification_key.bin"
CONFIG_SECURE_BOOT_INSECURE=
CONFIG_FLASH_ENCRYPTION_ENABLED=y
CONFIG_FLASH_ENCRYPTION_INSECURE=
It is Flash encryption with secure boot and signing.
Now signing is all working. now I enabled flash encryption. It is not working any more.
Do I need to first encrypt my all bins including bootloader then do sign and generate secure bootloader from encrypted boot loader bin.
To enable flash encryption:
espefuse.py --port COM184 burn_key flash_encryption encryption_key.bin
espefuse.py --port COM184 burn_efuse FLASH_CRYPT_CONFIG 0xF
espefuse.py --port COM184 burn_efuse FLASH_CRYPT_CNT
I do following first generate encrypted bins.
espsecure.py encrypt_flash_data --keyfile encryption_key.bin --address 0x1000 -o ./build/bootloader-encrypted.bin ./build/bootloader/bootloader.bin
espsecure.py encrypt_flash_data --keyfile encryption_key.bin --address 0x20000 -o ./build/app-encrypted.bin ./build/W2K1-BootLoader-Release.bin
espsecure.py encrypt_flash_data --keyfile encryption_key.bin --address 0x8000 -o ./build/partitions-encrypted.bin ./build/partitions.bin
then use these encrypted bins to generate signed bins.
espsecure.py sign_data --keyfile signing_key.pem --output ./build/signed_partitions.bin ./build/partitions-encrypted.bin
espsecure.py sign_data --keyfile signing_key.pem --output ./build/signed_W2K1-BootLoader-Release.bin ./build/app-encrypted.bin
espsecure.py digest_secure_bootloader --keyfile secure_boot_key.bin --output ./build/secure_bootloader.bin ./build/bootloader-encrypted.bin
Finally:
esptool.py --port COM184 --baud 921600 write_flash 0x0000 ./build/secure_bootloader.bin 0x8000 ./build/signed_partitions.bin 0x20000 ./build/signed_W2K1-BootLoader-Release.bin
Error:
rst:0x10 (RTCWDT_RTC_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
Is this because I already flash secure boot loader with out encryption. It expect encrypted secure bootloader.
Any steps wrong?
Thanks,
Naeem
I also enable flash encryption in menuconfig.
# Security features
#
CONFIG_SECURE_SIGNED_ON_BOOT=y
CONFIG_SECURE_SIGNED_ON_UPDATE=y
CONFIG_SECURE_SIGNED_APPS=y
CONFIG_SECURE_BOOT_ENABLED=y
CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH=y
CONFIG_SECURE_BOOTLOADER_REFLASHABLE=
CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES=
CONFIG_SECURE_BOOT_VERIFICATION_KEY="signature_verification_key.bin"
CONFIG_SECURE_BOOT_INSECURE=
CONFIG_FLASH_ENCRYPTION_ENABLED=y
CONFIG_FLASH_ENCRYPTION_INSECURE=
It is Flash encryption with secure boot and signing.
Now signing is all working. now I enabled flash encryption. It is not working any more.
Do I need to first encrypt my all bins including bootloader then do sign and generate secure bootloader from encrypted boot loader bin.
To enable flash encryption:
espefuse.py --port COM184 burn_key flash_encryption encryption_key.bin
espefuse.py --port COM184 burn_efuse FLASH_CRYPT_CONFIG 0xF
espefuse.py --port COM184 burn_efuse FLASH_CRYPT_CNT
I do following first generate encrypted bins.
espsecure.py encrypt_flash_data --keyfile encryption_key.bin --address 0x1000 -o ./build/bootloader-encrypted.bin ./build/bootloader/bootloader.bin
espsecure.py encrypt_flash_data --keyfile encryption_key.bin --address 0x20000 -o ./build/app-encrypted.bin ./build/W2K1-BootLoader-Release.bin
espsecure.py encrypt_flash_data --keyfile encryption_key.bin --address 0x8000 -o ./build/partitions-encrypted.bin ./build/partitions.bin
then use these encrypted bins to generate signed bins.
espsecure.py sign_data --keyfile signing_key.pem --output ./build/signed_partitions.bin ./build/partitions-encrypted.bin
espsecure.py sign_data --keyfile signing_key.pem --output ./build/signed_W2K1-BootLoader-Release.bin ./build/app-encrypted.bin
espsecure.py digest_secure_bootloader --keyfile secure_boot_key.bin --output ./build/secure_bootloader.bin ./build/bootloader-encrypted.bin
Finally:
esptool.py --port COM184 --baud 921600 write_flash 0x0000 ./build/secure_bootloader.bin 0x8000 ./build/signed_partitions.bin 0x20000 ./build/signed_W2K1-BootLoader-Release.bin
Error:
rst:0x10 (RTCWDT_RTC_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
Is this because I already flash secure boot loader with out encryption. It expect encrypted secure bootloader.
Any steps wrong?
Thanks,
Naeem