Просмотр исходного кода

esp32h2: enable DS peripheral support in driver and test application

Mahavir Jain 2 лет назад
Родитель
Сommit
e4e4ffa3f4

+ 4 - 0
components/esp_hw_support/esp_ds.c

@@ -48,6 +48,10 @@
 #include "esp32h4/rom/digital_signature.h"
 #endif
 
+#if CONFIG_IDF_TARGET_ESP32H2
+#include "esp32h2/rom/digital_signature.h"
+#endif
+
 
 struct esp_ds_context {
     const ets_ds_data_t *data;

+ 5 - 0
components/esp_hw_support/test_apps/esp_hw_support_unity_tests/main/test_ds.c

@@ -29,6 +29,11 @@
 #include "esp32c6/rom/digital_signature.h"
 #include "esp32c6/rom/aes.h"
 #include "esp32c6/rom/sha.h"
+#elif CONFIG_IDF_TARGET_ESP32H2
+#include "esp32h2/rom/efuse.h"
+#include "esp32h2/rom/digital_signature.h"
+#include "esp32h2/rom/aes.h"
+#include "esp32h2/rom/sha.h"
 #endif
 
 #include "esp_ds.h"

+ 3 - 2
components/esp_hw_support/test_apps/security_support/esp_hw_support_unity_tests/main/gen_digital_signature_tests.py

@@ -16,11 +16,12 @@ from cryptography.hazmat.primitives.asymmetric.rsa import _modinv as modinv  # t
 from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
 from cryptography.utils import int_to_bytes
 
-supported_targets = {'esp32s2', 'esp32c3', 'esp32s3', 'esp32c6'}
+supported_targets = {'esp32s2', 'esp32c3', 'esp32s3', 'esp32c6', 'esp32h2'}
 supported_key_size = {'esp32s2':[4096, 3072, 2048, 1024],
                       'esp32c3':[3072, 2048, 1024],
                       'esp32s3':[4096, 3072, 2048, 1024],
-                      'esp32c6':[3072, 2048, 1024]}
+                      'esp32c6':[3072, 2048, 1024],
+                      'esp32h2':[3072, 2048, 1024]}
 
 NUM_HMAC_KEYS = 3
 NUM_MESSAGES = 10

+ 5 - 0
components/esp_hw_support/test_apps/security_support/esp_hw_support_unity_tests/main/test_ds.c

@@ -29,6 +29,11 @@
 #include "esp32c6/rom/digital_signature.h"
 #include "esp32c6/rom/aes.h"
 #include "esp32c6/rom/sha.h"
+#elif CONFIG_IDF_TARGET_ESP32H2
+#include "esp32h2/rom/efuse.h"
+#include "esp32h2/rom/digital_signature.h"
+#include "esp32h2/rom/aes.h"
+#include "esp32h2/rom/sha.h"
 #endif
 
 #include "esp_ds.h"

+ 11 - 9
components/hal/CMakeLists.txt

@@ -159,6 +159,16 @@ if(NOT BOOTLOADER_BUILD)
         list(APPEND srcs "apm_hal.c")
     endif()
 
+    if(CONFIG_SOC_HMAC_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32S2)
+        # For ESP32-S2 we do not have HMAC HAL layer implementation yet
+        list(APPEND srcs "hmac_hal.c")
+    endif()
+
+    if(CONFIG_SOC_DIG_SIGN_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32S2)
+        # For ESP32-S2 we do not have DS HAL layer implementation yet
+        list(APPEND srcs "ds_hal.c")
+    endif()
+
     if(${target} STREQUAL "esp32")
         list(APPEND srcs
             "touch_sensor_hal.c"
@@ -180,13 +190,11 @@ if(NOT BOOTLOADER_BUILD)
 
     if(${target} STREQUAL "esp32s3")
         list(APPEND srcs
-            "ds_hal.c"
             "spi_flash_hal_gpspi.c"
             "touch_sensor_hal.c"
             "usb_hal.c"
             "usb_phy_hal.c"
             "xt_wdt_hal.c"
-            "hmac_hal.c"
             "esp32s3/touch_sensor_hal.c"
             "esp32s3/rtc_cntl_hal.c"
             "usb_dwc_hal.c")
@@ -194,19 +202,15 @@ if(NOT BOOTLOADER_BUILD)
 
     if(${target} STREQUAL "esp32c3")
         list(APPEND srcs
-              "ds_hal.c"
               "spi_flash_hal_gpspi.c"
               "xt_wdt_hal.c"
-              "hmac_hal.c"
               "esp32c3/rtc_cntl_hal.c")
     endif()
 
     if(${target} STREQUAL "esp32h4")
         list(APPEND srcs
-            "ds_hal.c"
             "spi_flash_hal_gpspi.c"
             "aes_hal.c"
-            "hmac_hal.c"
             "esp32h4/rtc_cntl_hal.c")
     endif()
 
@@ -218,9 +222,7 @@ if(NOT BOOTLOADER_BUILD)
 
     if(${target} STREQUAL "esp32c6")
         list(APPEND srcs
-              "spi_flash_hal_gpspi.c"
-              "hmac_hal.c"
-              "ds_hal.c")
+              "spi_flash_hal_gpspi.c")
 
     endif()
 

+ 2 - 0
components/mbedtls/port/esp_ds/esp_rsa_sign_alt.c

@@ -18,6 +18,8 @@
 #include "esp32s3/rom/digital_signature.h"
 #elif CONFIG_IDF_TARGET_ESP32C6
 #include "esp32c6/rom/digital_signature.h"
+#elif CONFIG_IDF_TARGET_ESP32H2
+#include "esp32h2/rom/digital_signature.h"
 #else
 #error   "Selected target does not support esp_rsa_sign_alt (for DS)"
 #endif