Skip to content

Commit 9269b78

Browse files
L-KAYAAdityaHPatwardhan
authored andcommitted
refactor(ecdsa): rely on efuse to get chip revision
1 parent d8d9ba3 commit 9269b78

File tree

5 files changed

+20
-42
lines changed

5 files changed

+20
-42
lines changed

components/esp_security/src/init.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ ESP_SYSTEM_INIT_FN(esp_security_init, SECONDARY, BIT(0), 103)
4242
esp_crypto_dpa_protection_startup();
4343
#endif
4444

45-
#if SOC_ECDSA_REGISTER_INCOMPATIBILITY_ACROSS_REV
46-
ecdsa_compatible_mem_reg_addr_init();
47-
#endif
48-
4945
#if CONFIG_ESP_CRYPTO_FORCE_ECC_CONSTANT_TIME_POINT_MUL
5046
bool force_constant_time = true;
5147
#if CONFIG_IDF_TARGET_ESP32H2

components/soc/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ if(target STREQUAL "esp32")
2727
list(APPEND srcs "${target_folder}/dport_access.c")
2828
endif()
2929

30-
if(target STREQUAL "esp32h2")
31-
list(APPEND srcs "${target_folder}/ecdsa_reg_addr.c")
32-
endif()
33-
3430
if(CONFIG_SOC_ADC_SUPPORTED)
3531
list(APPEND srcs "${target_folder}/adc_periph.c")
3632
endif()

components/soc/esp32h2/ecdsa_reg_addr.c

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include "soc/efuse_struct.h"
10+
11+
#define ESP_SOC_GET_CHIP_REV (EFUSE.rd_mac_sys_3.wafer_version_major * 100 + EFUSE.rd_mac_sys_3.wafer_version_minor)
12+
13+
#define REG_COMPATIBLE_ADDR(rev, before_addr, after_addr) ((ESP_SOC_GET_CHIP_REV >= (rev)) ? (after_addr) : (before_addr))

components/soc/esp32h2/register/soc/ecdsa_reg.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <stdint.h>
99
#include "soc/soc.h"
10+
#include "soc/chip_rev.h"
11+
1012
#ifdef __cplusplus
1113
extern "C" {
1214
#endif
@@ -448,34 +450,33 @@ extern "C" {
448450
/** ECDSA_R_MEM register
449451
* The memory that stores r.
450452
*/
451-
extern uint32_t ECDSA_R_MEM;
453+
#define ECDSA_R_MEM (DR_REG_ECDSA_BASE + REG_COMPATIBLE_ADDR(102, 0xa00, 0x340))
452454
#define ECDSA_R_MEM_SIZE_BYTES 32
453455

454456
/** ECDSA_S_MEM register
455457
* The memory that stores s.
456458
*/
457-
extern uint32_t ECDSA_S_MEM;
459+
#define ECDSA_S_MEM (DR_REG_ECDSA_BASE + REG_COMPATIBLE_ADDR(102, 0xa20, 0x360))
458460
#define ECDSA_S_MEM_SIZE_BYTES 32
459461

460462
/** ECDSA_Z_MEM register
461463
* The memory that stores software written z.
462464
*/
463-
extern uint32_t ECDSA_Z_MEM;
465+
#define ECDSA_Z_MEM (DR_REG_ECDSA_BASE + REG_COMPATIBLE_ADDR(102, 0xa40, 0x380))
464466
#define ECDSA_Z_MEM_SIZE_BYTES 32
465467

466468
/** ECDSA_QAX_MEM register
467469
* The memory that stores x coordinates of QA or software written k.
468470
*/
469-
extern uint32_t ECDSA_QAX_MEM;
471+
#define ECDSA_QAX_MEM (DR_REG_ECDSA_BASE + REG_COMPATIBLE_ADDR(102, 0xa60, 0x3a0))
470472
#define ECDSA_QAX_MEM_SIZE_BYTES 32
471473

472474
/** ECDSA_QAY_MEM register
473475
* The memory that stores y coordinates of QA.
474476
*/
475-
extern uint32_t ECDSA_QAY_MEM;
477+
#define ECDSA_QAY_MEM (DR_REG_ECDSA_BASE + REG_COMPATIBLE_ADDR(102, 0xa80, 0x3c0))
476478
#define ECDSA_QAY_MEM_SIZE_BYTES 32
477479

478-
479480
#ifdef __cplusplus
480481
}
481482
#endif

0 commit comments

Comments
 (0)