Skip to content

Commit 39872a5

Browse files
committed
feat(esp_security): Config to forcefully enable ECC constant-time operations during bootup
1 parent 46cbaa7 commit 39872a5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

components/esp_security/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,17 @@ menu "ESP Security Specific"
3737
default 3 if ESP_CRYPTO_DPA_PROTECTION_LEVEL_HIGH
3838
endmenu
3939

40+
config ESP_CRYPTO_FORCE_ECC_CONSTANT_TIME_POINT_MUL
41+
bool "Forcfully enable ECC constant time point multiplication operations"
42+
depends on SOC_ECC_CONSTANT_TIME_POINT_MUL
43+
default N
44+
help
45+
If enabled, the app startup code will burn the ECC_FORCE_CONST_TIME efuse bit to force the
46+
ECC peripheral to always perform constant time point multiplication operations,
47+
irrespective of the ECC_MULT_SECURITY_MODE status bit that is present in the ECC_MULT_CONF_REG
48+
register. By default, ESP-IDF configures the ECC peripheral to perform constant time point
49+
multiplication operations, so enabling this config would provide security enhancement only in
50+
the cases when trusted boot is not enabled and the attacker tries carrying out non-constant
51+
time point multiplication operations by changing the default ESP-IDF configurations.
52+
Performing constant time operations protect the ECC multiplication operations from timing attacks.
4053
endmenu

components/esp_security/src/init.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,30 @@
77
#include "esp_private/startup_internal.h"
88
#include "sdkconfig.h"
99
#include "esp_crypto_clk.h"
10+
#include "esp_efuse.h"
11+
#include "esp_efuse_table.h"
1012
#include "esp_security_priv.h"
13+
#include "esp_err.h"
14+
15+
__attribute__((unused)) static const char *TAG = "esp_security";
1116

1217
ESP_SYSTEM_INIT_FN(esp_security_init, SECONDARY, BIT(0), 103)
1318
{
1419
esp_crypto_clk_init();
1520
#if CONFIG_ESP_CRYPTO_DPA_PROTECTION_AT_STARTUP
1621
esp_crypto_dpa_protection_startup();
1722
#endif
23+
24+
#ifdef CONFIG_ESP_CRYPTO_FORCE_ECC_CONSTANT_TIME_POINT_MUL
25+
if (!esp_efuse_read_field_bit(ESP_EFUSE_ECC_FORCE_CONST_TIME)) {
26+
ESP_EARLY_LOGD(TAG, "Forcefully enabling ECC constant time operations");
27+
esp_err_t err = esp_efuse_write_field_bit(ESP_EFUSE_ECC_FORCE_CONST_TIME);
28+
if (err != ESP_OK) {
29+
ESP_EARLY_LOGE(TAG, "Enabling ECC constant time operations forcefully failed.");
30+
return err;
31+
}
32+
}
33+
#endif
1834
return ESP_OK;
1935
}
2036

0 commit comments

Comments
 (0)