Enabling ESP32 Secure Boot

What is Secure Boot?

ESP32 has a secure boot feature that allows you to configure the device to only accept signed firmware images from trusted sources. This can be used to prevent unauthorized modifications of your code and data on the ESP32, or to protect against malicious software (malware) attacks.

Why should it be used?

The ESP32 is an open-source hardware platform, which means anyone can modify its design. However, this also makes it vulnerable to malware attacks. If the attacker gains access to the device’s flash memory, they could replace the original firmware with their own version. In addition, if the attacker manages to gain root access, they could install any software on the device without user consent.

Secure boot prevents these types of attacks by requiring all firmware images to be digitally signed before being loaded into the device. Only those images that are signed by a trusted certificate authority will be accepted.

How does it work?

The ESP32 uses a Trusted Platform Module (TPM), which is a special-purpose chip designed for cryptographic operations. It provides a tamper-resistant environment where sensitive information such as passwords, keys, and certificates can be stored securely.

When the ESP32 boots up, it reads the TPM’s public key and checks whether the image file is signed using the private key associated with the public key. If so, the image is loaded into the device. Otherwise, the system displays an error message and refuses to load the image.

How do I enable it?

Secure Boot is enabled by default in the latest version of Espressif’s SDK for ESP32 development. But, on older versions of the SDK, you need to set the “secure_boot” option when initializing the board:

esp_init(0, 0x000002ff); // Initialize ESP32 module at address 0x00000200

esp_set_secure_mode(1); // Set secure boot mode

 

This entry was posted in ICS/SCADA and tagged , by Brent Huston. Bookmark the permalink.

About Brent Huston

I am the CEO of MicroSolved, Inc. and a security evangelist. I have spent the last 20+ years working to make the Internet safer for everyone on a global scale. I believe the Internet has the capability to contribute to the next great leap for mankind, and I want to help make that happen!

Leave a Reply