File tree Expand file tree Collapse file tree 18 files changed +144
-84
lines changed Expand file tree Collapse file tree 18 files changed +144
-84
lines changed Original file line number Diff line number Diff line change 88#include "hal/ecdsa_ll.h"
99#include "hal/ecdsa_hal.h"
1010#include "hal/efuse_hal.h"
11+ #include "hal/efuse_ll.h"
1112#include "soc/soc_caps.h"
1213
1314#if HAL_CONFIG (ECDSA_GEN_SIG_CM )
2627#define ECDSA_HAL_P384_COMPONENT_LEN 48
2728#endif /* SOC_ECDSA_SUPPORT_CURVE_P384 */
2829
30+ void ecdsa_hal_set_efuse_key (ecdsa_curve_t curve , int efuse_blk )
31+ {
32+ ecdsa_ll_set_ecdsa_key_blk (curve , efuse_blk );
33+
34+ efuse_ll_rs_bypass_update ();
35+
36+ efuse_hal_read ();
37+ }
38+
2939static void configure_ecdsa_periph (ecdsa_hal_config_t * conf )
3040{
3141
3242 if (conf -> use_km_key == 0 ) {
33- efuse_hal_set_ecdsa_key (conf -> curve , conf -> efuse_key_blk );
43+ ecdsa_hal_set_efuse_key (conf -> curve , conf -> efuse_key_blk );
3444
3545#if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY
3646 // Force Key Manager to use eFuse key for XTS-AES operation
Original file line number Diff line number Diff line change @@ -58,16 +58,7 @@ IRAM_ATTR bool efuse_hal_flash_encryption_enabled(void)
5858 return enabled ;
5959}
6060
61- #if SOC_EFUSE_ECDSA_KEY
62- void efuse_hal_set_ecdsa_key (ecdsa_curve_t curve , int efuse_blk )
63- {
64- efuse_ll_set_ecdsa_key_blk (curve , efuse_blk );
65-
66- efuse_ll_rs_bypass_update ();
6761
68- efuse_hal_read ();
69- }
70- #endif
7162
7263#if SOC_RECOVERY_BOOTLOADER_SUPPORTED
7364uint32_t efuse_hal_get_recovery_bootloader_address (void )
Original file line number Diff line number Diff line change 1010#include "hal/assert.h"
1111#include "soc/ecdsa_reg.h"
1212#include "soc/pcr_struct.h"
13+ #include "soc/efuse_periph.h"
1314#include "hal/ecdsa_types.h"
1415
1516#ifdef __cplusplus
@@ -413,6 +414,37 @@ static inline bool ecdsa_ll_is_deterministic_mode_supported(void)
413414 return true;
414415}
415416
417+ /**
418+ * @brief Set the ECDSA key block in eFuse
419+ *
420+ * @param curve ECDSA curve type
421+ * @param efuse_blk eFuse block number
422+ */
423+ __attribute__((always_inline )) static inline void ecdsa_ll_set_ecdsa_key_blk (ecdsa_curve_t curve , int efuse_blk )
424+ {
425+ uint8_t efuse_blk_low = 0 ;
426+ uint8_t efuse_blk_high = 0 ;
427+
428+ switch (curve ) {
429+ case ECDSA_CURVE_SECP192R1 :
430+ EFUSE .ecdsa .cfg_ecdsa_p192_blk = efuse_blk ;
431+ break ;
432+ case ECDSA_CURVE_SECP256R1 :
433+ EFUSE .ecdsa .cfg_ecdsa_p256_blk = efuse_blk ;
434+ break ;
435+ case ECDSA_CURVE_SECP384R1 :
436+ // ECDSA-p384 uses two efuse blocks to store the key. These two blocks are stored in a single integer
437+ // where the least significant 4 bits store the low key block number and the next 4 more significant bits store the high key block number.
438+ HAL_ECDSA_EXTRACT_KEY_BLOCKS (efuse_blk , efuse_blk_high , efuse_blk_low );
439+ EFUSE .ecdsa .cfg_ecdsa_p384_h_blk = efuse_blk_high ;
440+ EFUSE .ecdsa .cfg_ecdsa_p384_l_blk = efuse_blk_low ;
441+ break ;
442+ default :
443+ HAL_ASSERT (false && "Unsupported curve" );
444+ break ;
445+ }
446+ }
447+
416448#ifdef __cplusplus
417449}
418450#endif
Original file line number Diff line number Diff line change 1313#include "soc/efuse_periph.h"
1414#include "hal/assert.h"
1515#include "rom/efuse.h"
16- #include "hal/ecdsa_types.h"
1716
1817#ifdef __cplusplus
1918extern "C" {
@@ -94,31 +93,6 @@ __attribute__((always_inline)) static inline uint32_t efuse_ll_get_chip_ver_pkg(
9493 return EFUSE .rd_mac_sys2 .pkg_version ;
9594}
9695
97- __attribute__((always_inline )) static inline void efuse_ll_set_ecdsa_key_blk (ecdsa_curve_t curve , int efuse_blk )
98- {
99- uint8_t efuse_blk_low = 0 ;
100- uint8_t efuse_blk_high = 0 ;
101-
102- switch (curve ) {
103- case ECDSA_CURVE_SECP192R1 :
104- EFUSE .ecdsa .cfg_ecdsa_p192_blk = efuse_blk ;
105- break ;
106- case ECDSA_CURVE_SECP256R1 :
107- EFUSE .ecdsa .cfg_ecdsa_p256_blk = efuse_blk ;
108- break ;
109- case ECDSA_CURVE_SECP384R1 :
110- // ECDSA-p384 uses two efuse blocks to store the key. These two blocks are stored in a single integer
111- // where the least significant 4 bits store the low key block number and the next 4 more significant bits store the high key block number.
112- HAL_ECDSA_EXTRACT_KEY_BLOCKS (efuse_blk , efuse_blk_high , efuse_blk_low );
113- EFUSE .ecdsa .cfg_ecdsa_p384_h_blk = efuse_blk_high ;
114- EFUSE .ecdsa .cfg_ecdsa_p384_l_blk = efuse_blk_low ;
115- break ;
116- default :
117- HAL_ASSERT (false && "Unsupported curve" );
118- break ;
119- }
120- }
121-
12296__attribute__((always_inline )) static inline uint32_t efuse_ll_get_ocode (void )
12397{
12498 return EFUSE .rd_sys_part1_data4 .ocode ;
Original file line number Diff line number Diff line change 1010#include "hal/assert.h"
1111#include "soc/ecdsa_reg.h"
1212#include "soc/pcr_struct.h"
13+ #include "soc/efuse_periph.h"
1314#include "hal/ecdsa_types.h"
1415
1516#ifdef __cplusplus
@@ -432,6 +433,18 @@ static inline bool ecdsa_ll_is_deterministic_mode_supported(void)
432433 return true;
433434}
434435
436+ /**
437+ * @brief Set the ECDSA key block in eFuse
438+ *
439+ * @param curve ECDSA curve type
440+ * @param efuse_blk eFuse block number
441+ */
442+ __attribute__((always_inline )) static inline void ecdsa_ll_set_ecdsa_key_blk (ecdsa_curve_t curve , int efuse_blk )
443+ {
444+ (void ) curve ;
445+ EFUSE0 .conf .cfg_ecdsa_blk = efuse_blk ;
446+ }
447+
435448#ifdef __cplusplus
436449}
437450#endif
Original file line number Diff line number Diff line change 1313#include "soc/efuse_struct.h"
1414#include "hal/assert.h"
1515#include "rom/efuse.h"
16- #include "hal/ecdsa_types.h"
1716
1817#ifdef __cplusplus
1918extern "C" {
@@ -139,11 +138,6 @@ __attribute__((always_inline)) static inline uint32_t efuse_ll_get_ecdsa_key_blk
139138 return EFUSE0 .conf .cfg_ecdsa_blk ;
140139}
141140
142- __attribute__((always_inline )) static inline void efuse_ll_set_ecdsa_key_blk (ecdsa_curve_t curve , int efuse_blk )
143- {
144- (void ) curve ;
145- EFUSE0 .conf .cfg_ecdsa_blk = efuse_blk ;
146- }
147141
148142__attribute__((always_inline )) static inline uint32_t efuse_ll_get_recovery_bootloader_sector (void )
149143{
Original file line number Diff line number Diff line change 1111#include "soc/ecdsa_reg.h"
1212#include "soc/ecdsa_struct.h"
1313#include "soc/pcr_struct.h"
14+ #include "soc/efuse_periph.h"
1415#include "hal/ecdsa_types.h"
1516#include "hal/ecc_ll.h"
1617
@@ -418,6 +419,18 @@ static inline bool ecdsa_ll_is_deterministic_mode_supported(void)
418419 return ESP_CHIP_REV_ABOVE (efuse_hal_chip_revision (), 102 );
419420}
420421
422+ /**
423+ * @brief Set the ECDSA key block in eFuse
424+ *
425+ * @param curve ECDSA curve type
426+ * @param efuse_blk eFuse block number
427+ */
428+ __attribute__((always_inline )) static inline void ecdsa_ll_set_ecdsa_key_blk (ecdsa_curve_t curve , int efuse_blk )
429+ {
430+ (void ) curve ;
431+ EFUSE .conf .cfg_ecdsa_blk = efuse_blk ;
432+ }
433+
421434/**
422435 * @brief Check if the ECDSA peripheral uses MPI module's memory
423436 */
Original file line number Diff line number Diff line change 1111#include "soc/efuse_periph.h"
1212#include "hal/assert.h"
1313#include "rom/efuse.h"
14- #include "hal/ecdsa_types.h"
1514
1615#ifdef __cplusplus
1716extern "C" {
@@ -113,12 +112,6 @@ __attribute__((always_inline)) static inline uint32_t efuse_ll_get_ecdsa_key_blk
113112 return EFUSE .conf .cfg_ecdsa_blk ;
114113}
115114
116- __attribute__((always_inline )) static inline void efuse_ll_set_ecdsa_key_blk (ecdsa_curve_t curve , int efuse_blk )
117- {
118- (void ) curve ;
119- EFUSE .conf .cfg_ecdsa_blk = efuse_blk ;
120- }
121-
122115/******************* eFuse control functions *************************/
123116
124117__attribute__((always_inline )) static inline bool efuse_ll_get_read_cmd (void )
Original file line number Diff line number Diff line change 1010#include "hal/assert.h"
1111#include "soc/ecdsa_reg.h"
1212#include "soc/pcr_struct.h"
13+ #include "soc/efuse_periph.h"
1314#include "hal/ecdsa_types.h"
1415
1516#ifdef __cplusplus
@@ -415,6 +416,18 @@ static inline bool ecdsa_ll_is_deterministic_mode_supported(void)
415416 return true;
416417}
417418
419+ /**
420+ * @brief Set the ECDSA key block in eFuse
421+ *
422+ * @param curve ECDSA curve type
423+ * @param efuse_blk eFuse block number
424+ */
425+ __attribute__((always_inline )) static inline void ecdsa_ll_set_ecdsa_key_blk (ecdsa_curve_t curve , int efuse_blk )
426+ {
427+ (void ) curve ;
428+ (void ) efuse_blk ;
429+ }
430+
418431#ifdef __cplusplus
419432}
420433#endif
Original file line number Diff line number Diff line change 1111#include "soc/efuse_periph.h"
1212#include "hal/assert.h"
1313#include "rom/efuse.h"
14- #include "hal/ecdsa_types.h"
1514
1615//TODO: [ESP32H21] IDF-11556, inherit from h2
1716
@@ -103,13 +102,6 @@ __attribute__((always_inline)) static inline uint32_t efuse_ll_get_ecdsa_key_blk
103102 return 0 ;
104103}
105104
106- __attribute__((always_inline )) static inline void efuse_ll_set_ecdsa_key_blk (ecdsa_curve_t curve , int efuse_blk )
107- {
108- //TODO: [ESP32H21] IDF-11507
109- (void ) curve ;
110- (void ) efuse_blk ;
111- }
112-
113105/******************* eFuse control functions *************************/
114106
115107__attribute__((always_inline )) static inline bool efuse_ll_get_read_cmd (void )
You can’t perform that action at this time.
0 commit comments