Hi Philippe, On Mon, Jun 1, 2026 at 9:43 AM Philippe Reynes <[email protected]> wrote: > > Prepares the support of ecdsa signature check > using MbedTLS. It introduces the option ECDSA_MBEDTLS > to enable (or not) the support of ecdsa in MbedTLS. > > So now, ecdsa is no longer supported by default in the lib TLS. > To get it, the option ECDSA_MBEDTLS must be enabled. > > The option ECDSA_MBEDTLS only enables the ecdsa support > in MbedTLS, it doesn't provide any API to use it for > signature check. It will be done in another commit > by adding the option ECDSA_VERIFY_MBEDTLS. > > Two internal options are also added BIGNUM_MBEDTLS > and ECC_MBEDTLS. Those options are used to share code > between different option and avoid duplication. > > Reviewed-by: Raymond Mao <[email protected]> > Signed-off-by: Philippe Reynes <[email protected]> > --- > v2: > - move ecdsa to MBEDTLS_LIB_X509 > - enhance depencendies > v3: > - do not use _MBEDTLS in mbedtls_def_config.h > v4: > - do not select ECDSA on some configs > - remove duplicated MBEDTLS_ECP_DP_SECP256K1_ENABLED > - change dependencies for ECDSA configs > v5: > - MBEDTLS_LIB_TLS depends en ECDSA_MBEDTLS > - update some configs according to previous change > - build of ecdsa is conditionned by ECDSA_MBEDTLS > v6: > - fix dependencies for ecdsa and ecc on mbedtls > - ecdsa is no longer mandatory for tls > v7: > - no change > v8: > - enhance the commit message > - use /* */ instead of // > > configs/sandbox_defconfig | 1 + > lib/ecdsa/Kconfig | 1 + > lib/mbedtls/Kconfig | 17 +++++++++++++ > lib/mbedtls/Makefile | 17 +++++++------ > lib/mbedtls/mbedtls_def_config.h | 41 +++++++++++++++++++++----------- > 5 files changed, 56 insertions(+), 21 deletions(-) >
Thanks! Reviewed-by: Raymond Mao <[email protected]> > diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig > index ba800f7d19d..03c35429bc6 100644 > --- a/configs/sandbox_defconfig > +++ b/configs/sandbox_defconfig > @@ -381,6 +381,7 @@ CONFIG_PANIC_HANG=y > CONFIG_CMD_DHRYSTONE=y > CONFIG_MBEDTLS_LIB=y > CONFIG_HKDF_MBEDTLS=y > +CONFIG_ECDSA_MBEDTLS=y > CONFIG_ECDSA=y > CONFIG_ECDSA_VERIFY=y > CONFIG_RSASSA_PSS=y > diff --git a/lib/ecdsa/Kconfig b/lib/ecdsa/Kconfig > index ca13b6bfa1f..dac8bcf23dd 100644 > --- a/lib/ecdsa/Kconfig > +++ b/lib/ecdsa/Kconfig > @@ -1,6 +1,7 @@ > config ECDSA > bool "Enable ECDSA support" > depends on DM > + select ASN1_DECODER > help > This enables the ECDSA (elliptic curve signature) algorithm for FIT > image verification in U-Boot. The ECDSA algorithm is implemented > diff --git a/lib/mbedtls/Kconfig b/lib/mbedtls/Kconfig > index 789721ee6cd..e019f17d6bd 100644 > --- a/lib/mbedtls/Kconfig > +++ b/lib/mbedtls/Kconfig > @@ -247,6 +247,12 @@ config MBEDTLS_LIB_X509 > > if MBEDTLS_LIB_X509 > > +config BIGNUM_MBEDTLS > + bool > + > +config ECC_MBEDTLS > + bool > + > config ASN1_DECODER_MBEDTLS > bool "ASN1 decoder with MbedTLS certificate library" > depends on MBEDTLS_LIB_X509 && ASN1_DECODER > @@ -264,6 +270,7 @@ config RSA_PUBLIC_KEY_PARSER_MBEDTLS > bool "RSA public key parser with MbedTLS certificate library" > depends on ASYMMETRIC_PUBLIC_KEY_MBEDTLS > select ASN1_DECODER_MBEDTLS > + select BIGNUM_MBEDTLS > help > This option chooses MbedTLS certificate library for RSA public key > parser. > @@ -292,6 +299,15 @@ config MSCODE_PARSER_MBEDTLS > This option chooses MbedTLS certificate library for MS authenticode > parser. > > +config ECDSA_MBEDTLS > + bool "Enable ECDSA support with MbedTLS certificate library" > + depends on MBEDTLS_LIB_X509 && ASN1_DECODER_MBEDTLS > + select BIGNUM_MBEDTLS > + select ECC_MBEDTLS > + help > + This option enables support of ECDSA with the MbedTLS certificate > + library. > + > endif # MBEDTLS_LIB_X509 > > config MBEDTLS_LIB_TLS > @@ -301,6 +317,7 @@ config MBEDTLS_LIB_TLS > depends on ASYMMETRIC_PUBLIC_KEY_MBEDTLS > depends on ASN1_DECODER_MBEDTLS > depends on MBEDTLS_LIB > + select ECC_MBEDTLS > help > Enable MbedTLS TLS library. Required for HTTPs support > in wget > diff --git a/lib/mbedtls/Makefile b/lib/mbedtls/Makefile > index c5b445bd85c..0c86c90d15a 100644 > --- a/lib/mbedtls/Makefile > +++ b/lib/mbedtls/Makefile > @@ -39,13 +39,21 @@ mbedtls_lib_crypto-$(CONFIG_$(PHASE_)HKDF_MBEDTLS) += \ > # MbedTLS X509 library > obj-$(CONFIG_$(XPL_)MBEDTLS_LIB_X509) += mbedtls_lib_x509.o > mbedtls_lib_x509-y := $(MBEDTLS_LIB_DIR)/x509.o > +mbedtls_lib_x509-$(CONFIG_$(PHASE_)ECC_MBEDTLS) += \ > + $(MBEDTLS_LIB_DIR)/ecp.o \ > + $(MBEDTLS_LIB_DIR)/ecp_curves.o \ > + $(MBEDTLS_LIB_DIR)/ecp_curves_new.o \ > + $(MBEDTLS_LIB_DIR)/pk_ecc.o > +mbedtls_lib_x509-$(CONFIG_$(PHASE_)ECDSA_MBEDTLS) += \ > + $(MBEDTLS_LIB_DIR)/ecdsa.o > +mbedtls_lib_x509-$(CONFIG_$(PHASE_)BIGNUM_MBEDTLS) += \ > + $(MBEDTLS_LIB_DIR)/bignum.o \ > + $(MBEDTLS_LIB_DIR)/bignum_core.o > mbedtls_lib_x509-$(CONFIG_$(PHASE_)ASN1_DECODER_MBEDTLS) += \ > $(MBEDTLS_LIB_DIR)/asn1parse.o \ > $(MBEDTLS_LIB_DIR)/asn1write.o \ > $(MBEDTLS_LIB_DIR)/oid.o > mbedtls_lib_x509-$(CONFIG_$(PHASE_)RSA_PUBLIC_KEY_PARSER_MBEDTLS) += \ > - $(MBEDTLS_LIB_DIR)/bignum.o \ > - $(MBEDTLS_LIB_DIR)/bignum_core.o \ > $(MBEDTLS_LIB_DIR)/rsa.o \ > $(MBEDTLS_LIB_DIR)/rsa_alt_helpers.o > mbedtls_lib_x509-$(CONFIG_$(PHASE_)ASYMMETRIC_PUBLIC_KEY_MBEDTLS) += \ > @@ -64,7 +72,6 @@ mbedtls_lib_tls-y := \ > $(MBEDTLS_LIB_DIR)/mps_reader.o \ > $(MBEDTLS_LIB_DIR)/mps_trace.o \ > $(MBEDTLS_LIB_DIR)/net_sockets.o \ > - $(MBEDTLS_LIB_DIR)/pk_ecc.o \ > $(MBEDTLS_LIB_DIR)/ssl_cache.o \ > $(MBEDTLS_LIB_DIR)/ssl_ciphersuites.o \ > $(MBEDTLS_LIB_DIR)/ssl_client.o \ > @@ -82,8 +89,4 @@ mbedtls_lib_tls-y := \ > $(MBEDTLS_LIB_DIR)/cipher.o \ > $(MBEDTLS_LIB_DIR)/cipher_wrap.o \ > $(MBEDTLS_LIB_DIR)/ecdh.o \ > - $(MBEDTLS_LIB_DIR)/ecdsa.o \ > - $(MBEDTLS_LIB_DIR)/ecp.o \ > - $(MBEDTLS_LIB_DIR)/ecp_curves.o \ > - $(MBEDTLS_LIB_DIR)/ecp_curves_new.o \ > $(MBEDTLS_LIB_DIR)/gcm.o \ > diff --git a/lib/mbedtls/mbedtls_def_config.h > b/lib/mbedtls/mbedtls_def_config.h > index dda3f4dd6e4..d55f31acfda 100644 > --- a/lib/mbedtls/mbedtls_def_config.h > +++ b/lib/mbedtls/mbedtls_def_config.h > @@ -62,6 +62,25 @@ > > #if CONFIG_IS_ENABLED(MBEDTLS_LIB_X509) > > +#if CONFIG_IS_ENABLED(BIGNUM_MBEDTLS) > +#define MBEDTLS_BIGNUM_C > +#endif > + > +#if CONFIG_IS_ENABLED(ECC_MBEDTLS) > +#define MBEDTLS_ECP_C > +#define MBEDTLS_ECP_DP_SECP192R1_ENABLED > +#define MBEDTLS_ECP_DP_SECP224R1_ENABLED > +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED > +#define MBEDTLS_ECP_DP_SECP384R1_ENABLED > +#define MBEDTLS_ECP_DP_SECP521R1_ENABLED > +#define MBEDTLS_ECP_DP_SECP192K1_ENABLED > +#define MBEDTLS_ECP_DP_SECP224K1_ENABLED > +#define MBEDTLS_ECP_DP_SECP256K1_ENABLED > +#define MBEDTLS_ECP_DP_BP256R1_ENABLED > +#define MBEDTLS_ECP_DP_BP384R1_ENABLED > +#define MBEDTLS_ECP_DP_BP512R1_ENABLED > +#endif > + > #if CONFIG_IS_ENABLED(X509_CERTIFICATE_PARSER) > #define MBEDTLS_X509_USE_C > #define MBEDTLS_X509_CRT_PARSE_C > @@ -74,7 +93,6 @@ > #endif > > #if CONFIG_IS_ENABLED(RSA_PUBLIC_KEY_PARSER) > -#define MBEDTLS_BIGNUM_C > #define MBEDTLS_RSA_C > #define MBEDTLS_PKCS1_V15 > #endif > @@ -89,6 +107,10 @@ > #define MBEDTLS_ASN1_WRITE_C > #endif > > +#if CONFIG_IS_ENABLED(ECDSA_MBEDTLS) > +#define MBEDTLS_ECDSA_C > +#endif > + > #endif /* #if CONFIG_IS_ENABLED(MBEDTLS_LIB_X509) */ > > #if CONFIG_IS_ENABLED(MBEDTLS_LIB_TLS) > @@ -122,7 +144,9 @@ > > /* ECDSA */ > #if CONFIG_IS_ENABLED(ASN1_DECODER) > +#if CONFIG_IS_ENABLED(ECDSA_MBEDTLS) > #define MBEDTLS_ECDSA_C > +#endif /* #if CONFIG_IS_ENABLED(ECDSA_MBEDTLS) */ > #define MBEDTLS_ECP_C > #define MBEDTLS_ECDH_C > #endif > @@ -130,24 +154,13 @@ > #define MBEDTLS_HMAC_DRBG_C > > #define MBEDTLS_CAN_ECDH > +#if CONFIG_IS_ENABLED(ECDSA_MBEDTLS) > #define MBEDTLS_PK_CAN_ECDSA_SIGN > #if CONFIG_IS_ENABLED(X509_CERTIFICATE_PARSER) > #define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED > #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED > #endif > - > -#define MBEDTLS_ECP_DP_SECP256K1_ENABLED > -#define MBEDTLS_ECP_DP_SECP192R1_ENABLED > -#define MBEDTLS_ECP_DP_SECP224R1_ENABLED > -#define MBEDTLS_ECP_DP_SECP256R1_ENABLED > -#define MBEDTLS_ECP_DP_SECP384R1_ENABLED > -#define MBEDTLS_ECP_DP_SECP521R1_ENABLED > -#define MBEDTLS_ECP_DP_SECP192K1_ENABLED > -#define MBEDTLS_ECP_DP_SECP224K1_ENABLED > -#define MBEDTLS_ECP_DP_SECP256K1_ENABLED > -#define MBEDTLS_ECP_DP_BP256R1_ENABLED > -#define MBEDTLS_ECP_DP_BP384R1_ENABLED > -#define MBEDTLS_ECP_DP_BP512R1_ENABLED > +#endif /* #if CONFIG_IS_ENABLED(ECDSA_MBEDTLS) */ > > #endif /* #if CONFIG_IS_ENABLED(MBEDTLS_LIB_TLS) */ > > -- > 2.43.0 >

