Page 1 of 1

What if Flash Encryption and Secure Boot goes wrong ??

Posted: Thu Feb 14, 2019 3:04 pm
by k.ifantidis
Hello there.
I'm studying Flash Encryption and security features about ESP32 in esp-idf sdk. I would like to know if it's possible to use "make erase_flash" after enabling the encryption and all other features like secureboot, signed app images, partitions etc in order to restore the flash and flash new programs in the chip.
I'm going to find this out somewhere in near future :D but I would like a quick answer(Y or N) if it's possible.


Regards, Kostas.

Re: What if Flash Encryption and Secure Boot goes wrong ??

Posted: Thu Feb 14, 2019 11:32 pm
by ESP_Angus
Hi Kostas,

Flash Encryption and Secure Boot are both enabled by burning efuses inside the ESP32 (not the flash). Efuses are write-once only, once an efuse bit is set to "1" it can't be set back to "0".

If you erase the flash of an ESP32 with flash encryption and secure boot turned on, the only way to continue to use that ESP32 is to have saved pre-generated Flash Encryption and Secure Boot keys (which match the efuse contents) and then re-flash pre-encrypted binaries with a pre-generated secure boot digest. See here:

https://docs.espressif.com/projects/esp ... bootloader
https://docs.espressif.com/projects/esp ... yption-key

(One exception: If flash encryption is used and FLASH_CRYPT_CNT value is not yet the max, you can increment by one bit to disable flash encryption again and use the chip with flash encryption off. This can only be done 3 times in total, after this you run out of efuse bits in FLASH_CRYPT_CNT. If Secure Boot is enabled then you will still need the secure boot key to generate a bootloader digest for the plaintext bootloader.)

Re: What if Flash Encryption and Secure Boot goes wrong ??

Posted: Sat Feb 16, 2019 2:43 pm
by k.ifantidis
Thank you a lot Angus for the quick response. I'm going to study more these days about the topic.

Best regards, Kostas.