Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit fe4860a

Browse files
author
Catalin Ioana
authored
Features/secure boot enabling (#5)
components/bootloader_support: Enabled Secure Boot with re-flashable bootloader in wifi_scan project, add default a real key for signing partitions, workaround for an IDF bug, debug has to enabled for reflashable bootloader
1 parent 3b54cd7 commit fe4860a

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Y��IA))��->!�Pb4k��J�ʬHe���toȡ��K�/��؆��r��fM��D;��|(E

components/bootloader_support/src/esp_image_format.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <soc/cpu.h>
1919
#include <esp_image_format.h>
2020
#include <esp_secure_boot.h>
21+
#define LOG_LOCAL_LEVEL ESP_LOG_ERROR
2122
#include <esp_log.h>
2223
#include <bootloader_flash.h>
2324
#include <bootloader_random.h>
@@ -166,15 +167,18 @@ goto err;
166167
rewritten the header - rely on esptool.py having verified the bootloader at flashing time, instead.
167168
*/
168169
if (!is_bootloader) {
169-
#ifdef CONFIG_SECURE_BOOT_ENABLED
170-
// secure boot images have a signature appended
171-
err = verify_secure_boot_signature(sha_handle, data);
172-
#else
173-
// No secure boot, but SHA-256 can be appended for basic corruption detection
174-
if (sha_handle != NULL) {
175-
err = verify_simple_hash(sha_handle, data);
170+
//#ifdef CONFIG_SECURE_BOOT_ENABLED
171+
if (esp_secure_boot_enabled()) {
172+
// secure boot images have a signature appended
173+
err = verify_secure_boot_signature(sha_handle, data);
174+
//#else
175+
} else {
176+
// No secure boot, but SHA-256 can be appended for basic corruption detection
177+
if (sha_handle != NULL) {
178+
err = verify_simple_hash(sha_handle, data);
179+
}
176180
}
177-
#endif // CONFIG_SECURE_BOOT_ENABLED
181+
//#endif // CONFIG_SECURE_BOOT_ENABLED
178182
} else { // is_bootloader
179183
// bootloader may still have a sha256 digest handle open
180184
if (sha_handle != NULL) {

examples/wifi/scan/sdkconfig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ CONFIG_BOOTLOADER_VDDSDIO_BOOST=y
2626
#
2727
# Security features
2828
#
29-
CONFIG_SECURE_BOOT_ENABLED=
29+
CONFIG_SECURE_BOOT_ENABLED=y
30+
CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH=
31+
CONFIG_SECURE_BOOTLOADER_REFLASHABLE=y
32+
CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES=y
33+
CONFIG_SECURE_BOOT_SIGNING_KEY="secure_boot_signing_key.pem"
34+
CONFIG_SECURE_BOOT_INSECURE=
3035
CONFIG_FLASH_ENCRYPTION_ENABLED=
3136

3237
#
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-----BEGIN EC PRIVATE KEY-----
2+
MHcCAQEEICMyAIK9+SQEoSM06ju1q2PHfyQf34uN0J6WS0OFwP9OoAoGCCqGSM49
3+
AwEHoUQDQgAEWc/nSUEpKYnULT4h7AVQYjRr6AK5SpzKrEhlgpmjdBBvyKHFBopL
4+
oS+5nNiGlPdym8YYZk3THReXRDv+/3woRQ==
5+
-----END EC PRIVATE KEY-----
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Y��IA))��->!�Pb4k��J�ʬHe���toȡ��K�/��؆��r��fM��D;��|(E

0 commit comments

Comments
 (0)