Merge branch 'optimize/add_alternative_exponentiation' into 'release/v3.4'

feat: Perform an exponentiation by the algorithm of mbedtls V2 which is faster

See merge request sdk/ESP8266_RTOS_SDK!1715
This commit is contained in:
Dong Heng
2025-05-09 17:37:50 +08:00
5 changed files with 411 additions and 610 deletions

View File

@@ -196,6 +196,10 @@ target_sources(mbedcrypto PRIVATE "${current_dir}/port/esp_mem.c"
"${current_dir}/port/esp_timing.c"
"${current_dir}/port/esp_hardware.c")
if(CONFIG_MBEDTLS_MPI_EXP_MOD_ALT)
target_sources(mbedcrypto PRIVATE "${current_dir}/port/esp_bignum.c")
endif()
if(CONFIG_SOC_AES_SUPPORTED)
target_sources(mbedcrypto PRIVATE "${current_dir}/port/aes/esp_aes_xts.c"
"${current_dir}/port/aes/esp_aes_common.c"

View File

@@ -639,6 +639,13 @@ config MBEDTLS_SHA3_C
Enabling this configuration option increases the flash footprint
by almost 4KB.
config MBEDTLS_MPI_EXP_MOD_ALT
bool "Enable the alternative exponentiation"
default y
help
Perform an exponentiation by the algorithm of mbedtls V2,
which is faster when calling "mbedtls_mpi_exp_mod()".
choice MBEDTLS_TLS_MODE
bool "TLS Protocol Role"
default MBEDTLS_TLS_SERVER_AND_CLIENT

View File

@@ -10,7 +10,7 @@ COMPONENT_SRCDIRS := $(CURRENT_DIR)/mbedtls/library $(CURRENT_DIR)/port
COMPONENT_OBJEXCLUDE := $(CURRENT_DIR)/mbedtls/library/net_sockets.o
ifndef CONFIG_MBEDTLS_HARDWARE_MPI
ifndef CONFIG_MBEDTLS_MPI_EXP_MOD_ALT
COMPONENT_OBJEXCLUDE += $(CURRENT_DIR)/port/esp_bignum.o
endif

File diff suppressed because it is too large Load Diff

View File

@@ -206,9 +206,15 @@
#define MBEDTLS_MPI_MUL_MPI_ALT
#else
#undef MBEDTLS_MPI_EXP_MOD_ALT_FALLBACK
#undef MBEDTLS_MPI_EXP_MOD_ALT
#undef MBEDTLS_MPI_MUL_MPI_ALT
#if defined(CONFIG_MBEDTLS_MPI_EXP_MOD_ALT)
#define MBEDTLS_MPI_EXP_MOD_ALT
#else
#undef MBEDTLS_MPI_EXP_MOD_ALT
#endif
#endif
#define MBEDTLS_MPI_WINDOW_SIZE 6
#ifdef CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN
#define MBEDTLS_ECDSA_SIGN_ALT