add software ecdsa support
Subsystems (3)
v2 cover add software ecdsa support
This serie adds the support of ecdsa with software using mbedtls. So boards without ecdsa hardware may also use signature with ecdsa.
To add the support of ecdsa with mbedtls, I have:
- enabled ecdsa in mbedtls
- add a function sw_ecdsa_verify that uses mbedtls
- add a driver sw_ecdsa that call sw_ecdsa_verify
I have tested this code with sandbox, and I have followed those steps:
0) build u-boot using sandbox_defconfig and adding those options:CONFIG_ECDSA_SW=yCONFIG_ECDSA_MBEDTLS=yCONFIG_ECDSA=yCONFIG_ECDSA_VERIFY=y
1) add a signature node to an its file
signature-256 {
algo = "sha256,ecdsa256";
key-name-hint = "private-key-256";
};2) generate an ecdsa key
openssl ecparam -name prime256v1 -genkey -noout -out private-key-256.pem
3) create the itb file./tools/mkimage -f <file.its> -k . -K arch/sandbox/dts/test.dtb <file.itb>
4) launch sandbox u-boot
./u-boot -d arch/sandbox/dts/test.dtb
5) on sandbox u-boot prompt, load the itb and launch bootm on it
=> host load hostfs - 1000000 uboot-ecdsa.itb
4628674 bytes read in 1 ms (4.3 GiB/s)
=> bootm 1000000
...
...
Verifying Hash Integrity ... sha256,ecdsa256:private-key-256+ OK
I have tested with success ecdsa256 and ecdsa384, but there is an issue with secp521r1.
Changes in v2:
- move ECDSA_MBEDTLS to MBEDTLS_LIB_X509
- rename lib/mbedtls/sw_ecdsa.c to lib/mbedtls/ecdsa.c
- enhance dependancies for ECDSA_MBEDTLS
- fix support of ecdsa521/secp521r1
- add vboot test using ecdsa
Philippe Reynes (9):
mbedtls: enable support of ecc
ecdsa: initial support of ecdsa using mbedtls
test: lib: sw_ecdsa: add initial test
drivers: crypto: add software ecdsa support
ecdsa: fix support of secp521r1
test: dm: ecdsa.c: clean this test as software ecdsa is now
implemented
configs: sandbox: enable the software ecdsa driver
test: py: vboot: prepare integration test for ecdsa
test: vboot: add test for ecdsa
configs/amd_versal2_virt_defconfig | 1 +
configs/qemu_arm64_lwip_defconfig | 1 +
configs/sandbox_defconfig | 1 +
configs/starfive_visionfive2_defconfig | 1 +
configs/xilinx_versal_net_virt_defconfig | 1 +
configs/xilinx_versal_virt_defconfig | 1 +
configs/xilinx_zynqmp_kria_defconfig | 1 +
configs/xilinx_zynqmp_virt_defconfig | 1 +
drivers/crypto/Kconfig | 2 +
drivers/crypto/Makefile | 1 +
drivers/crypto/ecdsa/Kconfig | 6 +
drivers/crypto/ecdsa/Makefile | 6 +
drivers/crypto/ecdsa/ecdsa-sw.c | 33 ++
include/crypto/internal/sw_ecdsa.h | 14 +
lib/ecdsa/ecdsa-libcrypto.c | 21 +-
lib/ecdsa/ecdsa-verify.c | 24 +-
lib/fdt-libcrypto.c | 2 +-
lib/mbedtls/Kconfig | 16 +
lib/mbedtls/Makefile | 19 +-
lib/mbedtls/ecdsa.c | 94 ++++
lib/mbedtls/mbedtls_def_config.h | 18 +
test/dm/ecdsa.c | 18 +-
test/lib/Makefile | 1 +
test/lib/sw_ecdsa.c | 465 ++++++++++++++++++
test/py/tests/test_fit_ecdsa.py | 2 +-
test/py/tests/test_vboot.py | 128 +++--
....its => sign-configs-sha1-rsa2048-pss.its} | 0
...sha1.its => sign-configs-sha1-rsa2048.its} | 0
.../vboot/sign-configs-sha256-ecdsa256.its | 45 ++
.../vboot/sign-configs-sha256-ecdsa384.its | 45 ++
.../vboot/sign-configs-sha256-ecdsa521.its | 45 ++
... sign-configs-sha256-rsa2048-pss-prod.its} | 0
...ts => sign-configs-sha256-rsa2048-pss.its} | 0
...56.its => sign-configs-sha256-rsa2048.its} | 0
...84.its => sign-configs-sha384-rsa3072.its} | 0
...s.its => sign-images-sha1-rsa2048-pss.its} | 0
...-sha1.its => sign-images-sha1-rsa2048.its} | 0
.../vboot/sign-images-sha256-ecdsa256.its | 42 ++
.../vboot/sign-images-sha256-ecdsa384.its | 42 ++
.../vboot/sign-images-sha256-ecdsa521.its | 42 ++
...its => sign-images-sha256-rsa2048-pss.its} | 0
...256.its => sign-images-sha256-rsa2048.its} | 0
...384.its => sign-images-sha384-rsa3072.its} | 0
tools/image-sig-host.c | 2 +-
44 files changed, 1062 insertions(+), 79 deletions(-)
create mode 100644 drivers/crypto/ecdsa/Kconfig
create mode 100644 drivers/crypto/ecdsa/Makefile
create mode 100644 drivers/crypto/ecdsa/ecdsa-sw.c
create mode 100644 include/crypto/internal/sw_ecdsa.h
create mode 100644 lib/mbedtls/ecdsa.c
create mode 100644 test/lib/sw_ecdsa.c
rename test/py/tests/vboot/{sign-configs-sha1-pss.its => sign-configs-sha1-rsa2048-pss.its} (100%)
rename test/py/tests/vboot/{sign-configs-sha1.its => sign-configs-sha1-rsa2048.its} (100%)
create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa256.its
create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa384.its
create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa521.its
rename test/py/tests/vboot/{sign-configs-sha256-pss-prod.its => sign-configs-sha256-rsa2048-pss-prod.its} (100%)
rename test/py/tests/vboot/{sign-configs-sha256-pss.its => sign-configs-sha256-rsa2048-pss.its} (100%)
rename test/py/tests/vboot/{sign-configs-sha256.its => sign-configs-sha256-rsa2048.its} (100%)
rename test/py/tests/vboot/{sign-configs-sha384.its => sign-configs-sha384-rsa3072.its} (100%)
rename test/py/tests/vboot/{sign-images-sha1-pss.its => sign-images-sha1-rsa2048-pss.its} (100%)
rename test/py/tests/vboot/{sign-images-sha1.its => sign-images-sha1-rsa2048.its} (100%)
create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa256.its
create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa384.its
create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa521.its
rename test/py/tests/vboot/{sign-images-sha256-pss.its => sign-images-sha256-rsa2048-pss.its} (100%)
rename test/py/tests/vboot/{sign-images-sha256.its => sign-images-sha256-rsa2048.its} (100%)
rename test/py/tests/vboot/{sign-images-sha384.its => sign-images-sha384-rsa3072.its} (100%)Signature · 1 line
2.43.0
RFC PATCH v2 1/9 mbedtls: enable support of ecc
Enables the support of ecc in mbedtls.
---
v2:
- move ecdsa to MBEDTLS_LIB_X509
- enhance depencendies
configs/amd_versal2_virt_defconfig | 1 + configs/qemu_arm64_lwip_defconfig | 1 + configs/starfive_visionfive2_defconfig | 1 + configs/xilinx_versal_net_virt_defconfig | 1 + configs/xilinx_versal_virt_defconfig | 1 + configs/xilinx_zynqmp_kria_defconfig | 1 + configs/xilinx_zynqmp_virt_defconfig | 1 + lib/mbedtls/Kconfig | 16 ++++++++++++++++ lib/mbedtls/Makefile | 16 +++++++++------- lib/mbedtls/mbedtls_def_config.h | 18 ++++++++++++++++++ 10 files changed, 50 insertions(+), 7 deletions(-)
configs/amd_versal2_virt_defconfig +1 -0
@@ -164,6 +164,7 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y # CONFIG_OPTEE_LIB is not set CONFIG_TOOLS_MKFWUMDATA=y
configs/qemu_arm64_lwip_defconfig +1 -0
@@ -11,3 +11,4 @@ CONFIG_CMD_WGET=y CONFIG_EFI_HTTP_BOOT=y CONFIG_WGET_HTTPS=y CONFIG_WGET_CACERT=y +CONFIG_ECDSA=y
configs/starfive_visionfive2_defconfig +1 -0
@@ -156,3 +156,4 @@ CONFIG_USB_GADGET=y CONFIG_WDT=y CONFIG_WDT_STARFIVE=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y
configs/xilinx_versal_net_virt_defconfig +1 -0
@@ -154,4 +154,5 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y
configs/xilinx_versal_virt_defconfig +1 -0
@@ -168,5 +168,6 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_TOOLS_MKFWUMDATA=y
configs/xilinx_zynqmp_kria_defconfig +1 -0
@@ -219,6 +219,7 @@ CONFIG_VIRTIO_BLK=y CONFIG_BINMAN_DTB="./arch/arm/dts/zynqmp-binman-som.dtb" CONFIG_PANIC_HANG=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_SPL_GZIP=y CONFIG_TOOLS_MKFWUMDATA=y
configs/xilinx_zynqmp_virt_defconfig +1 -0
@@ -237,6 +237,7 @@ CONFIG_VIRTIO_BLK=y CONFIG_BINMAN_DTB="./arch/arm/dts/zynqmp-binman.dtb" CONFIG_PANIC_HANG=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_SPL_GZIP=y CONFIG_TOOLS_MKFWUMDATA=y
lib/mbedtls/Kconfig +16 -0
@@ -242,11 +242,16 @@ config MBEDTLS_LIB_X509 select X509_CERTIFICATE_PARSER_MBEDTLS if X509_CERTIFICATE_PARSER select PKCS7_MESSAGE_PARSER_MBEDTLS if PKCS7_MESSAGE_PARSER select MSCODE_PARSER_MBEDTLS if MSCODE_PARSER + select ECDSA_MBEDTLS if ECDSA help Enable MbedTLS certificate libraries. if MBEDTLS_LIB_X509 +config BIGNUM_MBEDTLS + bool + default n + config ASN1_DECODER_MBEDTLS bool "ASN1 decoder with MbedTLS certificate library" depends on MBEDTLS_LIB_X509 && ASN1_DECODER
@@ -264,6 +269,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 +298,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 + select ASN1_DECODER + select BIGNUM_MBEDTLS + help + This option enables support of ECDSA with the MbedTLS certificate + library. + endif # MBEDTLS_LIB_X509 config MBEDTLS_LIB_TLS
@@ -301,6 +316,7 @@ config MBEDTLS_LIB_TLS depends on ASYMMETRIC_PUBLIC_KEY_MBEDTLS depends on ASN1_DECODER_MBEDTLS depends on MBEDTLS_LIB + depends on ECDSA_MBEDTLS help Enable MbedTLS TLS library. Required for HTTPs support in wget
lib/mbedtls/Makefile +9 -7
@@ -39,13 +39,14 @@ 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_)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) += \
@@ -57,6 +58,12 @@ mbedtls_lib_x509-$(CONFIG_$(PHASE_)X509_CERTIFICATE_PARSER_MBEDTLS) += \ $(MBEDTLS_LIB_DIR)/x509_crt.o mbedtls_lib_x509-$(CONFIG_$(PHASE_)PKCS7_MESSAGE_PARSER_MBEDTLS) += \ $(MBEDTLS_LIB_DIR)/pkcs7.o +mbedtls_lib_x509-$(CONFIG_$(PHASE_)ECDSA_MBEDTLS) += \ + $(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)/pk_ecc.o #mbedTLS TLS support obj-$(CONFIG_$(XPL_)MBEDTLS_LIB_TLS) += mbedtls_lib_tls.o
@@ -64,7 +71,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 +88,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 \
lib/mbedtls/mbedtls_def_config.h +18 -0
@@ -89,6 +89,24 @@#define MBEDTLS_ASN1_WRITE_C #endif +#if CONFIG_IS_ENABLED (ECDSA_MBEDTLS ) +#define MBEDTLS_ECDSA_C +#define MBEDTLS_ECP_C +#define MBEDTLS_BIGNUM_C +#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 +#endif /* #if CONFIG_IS_ENABLED(MBEDTLS_LIB_X509) */ #if CONFIG_IS_ENABLED (MBEDTLS_LIB_TLS )
Signature · 1 line
2.43.0
Re: [RFC PATCH v2 1/9] mbedtls: enable support of ecc
Hi Philippe,
Quoted 126 lines · Philippe Reynes
Enables the support of ecc in mbedtls.
Signed-off-by Philippe Reynes <[email protected]>---
v2:
- move ecdsa toMBEDTLS_LIB_X509
- enhance depencendiesconfigs/amd_versal2_virt_defconfig | 1 + configs/qemu_arm64_lwip_defconfig | 1 + configs/starfive_visionfive2_defconfig | 1 + configs/xilinx_versal_net_virt_defconfig | 1 + configs/xilinx_versal_virt_defconfig | 1 + configs/xilinx_zynqmp_kria_defconfig | 1 + configs/xilinx_zynqmp_virt_defconfig | 1 + lib/mbedtls/Kconfig | 16 ++++++++++++++++ lib/mbedtls/Makefile | 16 +++++++++------- lib/mbedtls/mbedtls_def_config.h | 18 ++++++++++++++++++ 10 files changed, 50 insertions(+), 7 deletions(-)configs/amd_versal2_virt_defconfig +1
-0@@ -164,6 +164,7 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y # CONFIG_OPTEE_LIB is not set CONFIG_TOOLS_MKFWUMDATA=yconfigs/qemu_arm64_lwip_defconfig +1
-0@@ -11,3 +11,4 @@ CONFIG_CMD_WGET=y CONFIG_EFI_HTTP_BOOT=y CONFIG_WGET_HTTPS=y CONFIG_WGET_CACERT=y +CONFIG_ECDSA=yconfigs/starfive_visionfive2_defconfig +1
-0@@ -156,3 +156,4 @@ CONFIG_USB_GADGET=y CONFIG_WDT=y CONFIG_WDT_STARFIVE=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=yconfigs/xilinx_versal_net_virt_defconfig +1
-0@@ -154,4 +154,5 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=yconfigs/xilinx_versal_virt_defconfig +1
-0@@ -168,5 +168,6 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_TOOLS_MKFWUMDATA=yconfigs/xilinx_zynqmp_kria_defconfig +1
-0@@ -219,6 +219,7 @@ CONFIG_VIRTIO_BLK=y CONFIG_BINMAN_DTB="./arch/arm/dts/zynqmp-binman-som.dtb" CONFIG_PANIC_HANG=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_SPL_GZIP=y CONFIG_TOOLS_MKFWUMDATA=yconfigs/xilinx_zynqmp_virt_defconfig +1
-0@@ -237,6 +237,7 @@ CONFIG_VIRTIO_BLK=y CONFIG_BINMAN_DTB="./arch/arm/dts/zynqmp-binman.dtb" CONFIG_PANIC_HANG=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_SPL_GZIP=y CONFIG_TOOLS_MKFWUMDATA=ylib/mbedtls/Kconfig +6
-0@@ -242,11 +242,16 @@ config MBEDTLS_LIB_X509 select X509_CERTIFICATE_PARSER_MBEDTLS if X509_CERTIFICATE_PARSER select PKCS7_MESSAGE_PARSER_MBEDTLS if PKCS7_MESSAGE_PARSER select MSCODE_PARSER_MBEDTLS if MSCODE_PARSER + select ECDSA_MBEDTLS if ECDSA help Enable MbedTLS certificate libraries. if MBEDTLS_LIB_X509 +config BIGNUM_MBEDTLS + bool + default n + config ASN1_DECODER_MBEDTLS bool "ASN1 decoder with MbedTLS certificate library" depends on MBEDTLS_LIB_X509 && ASN1_DECODER@@ -264,6 +269,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.
lib/mbedtls/Kconfig config MSCODE_PARSER_MBEDTLS · line 304
Quoted 7 lines
lib/mbedtls/Kconfig +4
-0@@ -292,6 +298,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 + select ASN1_DECODER
This should be ASN1_DECODER_MBEDTLS.
Quoted 72 lines
lib/mbedtls/Kconfig +6
-0+ select BIGNUM_MBEDTLS + help + This option enables support of ECDSA with the MbedTLS certificate + library. + endif # MBEDTLS_LIB_X509 config MBEDTLS_LIB_TLS@@ -301,6 +316,7 @@ config MBEDTLS_LIB_TLS depends on ASYMMETRIC_PUBLIC_KEY_MBEDTLS depends on ASN1_DECODER_MBEDTLS depends on MBEDTLS_LIB + depends on ECDSA_MBEDTLS help Enable MbedTLS TLS library. Required for HTTPs support in wgetlib/mbedtls/Makefile +9
-7@@ -39,13 +39,14 @@ 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_)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) += \@@ -57,6 +58,12 @@ mbedtls_lib_x509-$(CONFIG_$(PHASE_)X509_CERTIFICATE_PARSER_MBEDTLS) += \ $(MBEDTLS_LIB_DIR)/x509_crt.o mbedtls_lib_x509-$(CONFIG_$(PHASE_)PKCS7_MESSAGE_PARSER_MBEDTLS) += \ $(MBEDTLS_LIB_DIR)/pkcs7.o +mbedtls_lib_x509-$(CONFIG_$(PHASE_)ECDSA_MBEDTLS) += \ + $(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)/pk_ecc.o #mbedTLS TLS support obj-$(CONFIG_$(XPL_)MBEDTLS_LIB_TLS) += mbedtls_lib_tls.o@@ -64,7 +71,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 +88,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 \lib/mbedtls/mbedtls_def_config.h +0
-0
lib/mbedtls/mbedtls_def_config.h line 92
Quoted 4 lines
lib/mbedtls/mbedtls_def_config.h +1
-0@@ -89,6 +89,24 @@#define MBEDTLS_ASN1_WRITE_C #endif +#if CONFIG_IS_ENABLED (ECDSA_MBEDTLS )
In the 'mbedtls_def_config.h' file, we use the kconfigs without the '_MBEDTLS' postfix.
Regards,
Raymond
Quoted 23 lines
lib/mbedtls/mbedtls_def_config.h +17
-1+#define MBEDTLS_ECDSA_C +#define MBEDTLS_ECP_C +#define MBEDTLS_BIGNUM_C +#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 +#endif /* #if CONFIG_IS_ENABLED(MBEDTLS_LIB_X509) */ #if CONFIG_IS_ENABLED (MBEDTLS_LIB_TLS ) --2.43.0
Re: [RFC PATCH v2 1/9] mbedtls: enable support of ecc
Hi Raymond,
Sorry for this very later answer.
Le 20/02/2026 à 16:18, Raymond Mao a écrit :
Quoted 134 lines
This Mail comes from Outside of SoftAtHome: Do not answer, click links or open attachments unless you recognize the sender and know the content is safe.
Hi Philippe,
Quoted 128 lines · Philippe Reynes
Enables the support of ecc in mbedtls.
Signed-off-by Philippe Reynes <[email protected]>---
v2:
- move ecdsa toMBEDTLS_LIB_X509
- enhance depencendiesconfigs/amd_versal2_virt_defconfig | 1 + configs/qemu_arm64_lwip_defconfig | 1 + configs/starfive_visionfive2_defconfig | 1 + configs/xilinx_versal_net_virt_defconfig | 1 + configs/xilinx_versal_virt_defconfig | 1 + configs/xilinx_zynqmp_kria_defconfig | 1 + configs/xilinx_zynqmp_virt_defconfig | 1 + lib/mbedtls/Kconfig | 16 ++++++++++++++++ lib/mbedtls/Makefile | 16 +++++++++------- lib/mbedtls/mbedtls_def_config.h | 18 ++++++++++++++++++ 10 files changed, 50 insertions(+), 7 deletions(-)configs/amd_versal2_virt_defconfig +1
-0@@ -164,6 +164,7 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y # CONFIG_OPTEE_LIB is not set CONFIG_TOOLS_MKFWUMDATA=yconfigs/qemu_arm64_lwip_defconfig +1
-0@@ -11,3 +11,4 @@ CONFIG_CMD_WGET=y CONFIG_EFI_HTTP_BOOT=y CONFIG_WGET_HTTPS=y CONFIG_WGET_CACERT=y +CONFIG_ECDSA=yconfigs/starfive_visionfive2_defconfig +1
-0@@ -156,3 +156,4 @@ CONFIG_USB_GADGET=y CONFIG_WDT=y CONFIG_WDT_STARFIVE=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=yconfigs/xilinx_versal_net_virt_defconfig +1
-0@@ -154,4 +154,5 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=yconfigs/xilinx_versal_virt_defconfig +1
-0@@ -168,5 +168,6 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_TOOLS_MKFWUMDATA=yconfigs/xilinx_zynqmp_kria_defconfig +1
-0@@ -219,6 +219,7 @@ CONFIG_VIRTIO_BLK=y CONFIG_BINMAN_DTB="./arch/arm/dts/zynqmp-binman-som.dtb" CONFIG_PANIC_HANG=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_SPL_GZIP=y CONFIG_TOOLS_MKFWUMDATA=yconfigs/xilinx_zynqmp_virt_defconfig +1
-0@@ -237,6 +237,7 @@ CONFIG_VIRTIO_BLK=y CONFIG_BINMAN_DTB="./arch/arm/dts/zynqmp-binman.dtb" CONFIG_PANIC_HANG=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_SPL_GZIP=y CONFIG_TOOLS_MKFWUMDATA=ylib/mbedtls/Kconfig +6
-0@@ -242,11 +242,16 @@ config MBEDTLS_LIB_X509 select X509_CERTIFICATE_PARSER_MBEDTLS if X509_CERTIFICATE_PARSER select PKCS7_MESSAGE_PARSER_MBEDTLS if PKCS7_MESSAGE_PARSER select MSCODE_PARSER_MBEDTLS if MSCODE_PARSER + select ECDSA_MBEDTLS if ECDSA help Enable MbedTLS certificate libraries. if MBEDTLS_LIB_X509 +config BIGNUM_MBEDTLS + bool + default n + config ASN1_DECODER_MBEDTLS bool "ASN1 decoder with MbedTLS certificate library" depends on MBEDTLS_LIB_X509 && ASN1_DECODER@@ -264,6 +269,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 +298,15 @@ config MSCODE_PARSER_MBEDTLS This option chooses MbedTLS certificate library for MS authenticode parser.
Quoted 5 lines
lib/mbedtls/Kconfig config MSCODE_PARSER_MBEDTLS · line 304
Quoted 4 lines
lib/mbedtls/Kconfig +4
-0+config ECDSA_MBEDTLS + bool "Enable ECDSA support with MbedTLS certificate library" + depends on MBEDTLS_LIB_X509 + select ASN1_DECODERThis should be
ASN1_DECODER_MBEDTLS.
It was my first try, but I reach an issue.
If ASN1_DECODER is not selected and we select ASN1_DECODER_MBEDTLS, there is a conflict because ASN1_DECODER_MBEDTLS depends on ASN1_DECODER. So to avoid this issue, I have kept ASN1_DECODER in V3.
Regards,
Philippe
Quoted 107 lines
Quoted 74 lines
lib/mbedtls/Kconfig +6
-0+ select BIGNUM_MBEDTLS + help + This option enables support of ECDSA with the MbedTLS certificate + library. + endif # MBEDTLS_LIB_X509 config MBEDTLS_LIB_TLS@@ -301,6 +316,7 @@ config MBEDTLS_LIB_TLS depends on ASYMMETRIC_PUBLIC_KEY_MBEDTLS depends on ASN1_DECODER_MBEDTLS depends on MBEDTLS_LIB + depends on ECDSA_MBEDTLS help Enable MbedTLS TLS library. Required for HTTPs support in wgetlib/mbedtls/Makefile +9
-7@@ -39,13 +39,14 @@ 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_)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) += \@@ -57,6 +58,12 @@ mbedtls_lib_x509-$(CONFIG_$(PHASE_)X509_CERTIFICATE_PARSER_MBEDTLS) += \ $(MBEDTLS_LIB_DIR)/x509_crt.o mbedtls_lib_x509-$(CONFIG_$(PHASE_)PKCS7_MESSAGE_PARSER_MBEDTLS) += \ $(MBEDTLS_LIB_DIR)/pkcs7.o +mbedtls_lib_x509-$(CONFIG_$(PHASE_)ECDSA_MBEDTLS) += \ + $(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)/pk_ecc.o #mbedTLS TLS support obj-$(CONFIG_$(XPL_)MBEDTLS_LIB_TLS) += mbedtls_lib_tls.o@@ -64,7 +71,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 +88,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 \lib/mbedtls/mbedtls_def_config.h +0
-0lib/mbedtls/mbedtls_def_config.h line 92
Quoted 4 lines
lib/mbedtls/mbedtls_def_config.h +1
-0@@ -89,6 +89,24 @@#define MBEDTLS_ASN1_WRITE_C #endif +#if CONFIG_IS_ENABLED (ECDSA_MBEDTLS )In the '
mbedtls_def_config.h' file, we use the kconfigs without the '_MBEDTLS' postfix.Regards,
RaymondQuoted 23 lines
lib/mbedtls/mbedtls_def_config.h +17
-1+#define MBEDTLS_ECDSA_C +#define MBEDTLS_ECP_C +#define MBEDTLS_BIGNUM_C +#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 +#endif /* #if CONFIG_IS_ENABLED(MBEDTLS_LIB_X509) */ #if CONFIG_IS_ENABLED (MBEDTLS_LIB_TLS ) --2.43.0
Re: [RFC PATCH v2 1/9] mbedtls: enable support of ecc
Hi Philippe,
Quoted 148 lines · Philippe Reynes
Hi Raymond,
Sorry for this very later answer.
Quoted 134 lines · Raymond Mao
This Mail comes from Outside of SoftAtHome: Do not answer, click links or open attachments unless you recognize the sender and know the content is safe.
Hi Philippe,
Quoted 128 lines · Philippe Reynes
Enables the support of ecc in mbedtls.
Signed-off-by Philippe Reynes <[email protected]>---
v2:
- move ecdsa toMBEDTLS_LIB_X509
- enhance depencendiesconfigs/amd_versal2_virt_defconfig | 1 + configs/qemu_arm64_lwip_defconfig | 1 + configs/starfive_visionfive2_defconfig | 1 + configs/xilinx_versal_net_virt_defconfig | 1 + configs/xilinx_versal_virt_defconfig | 1 + configs/xilinx_zynqmp_kria_defconfig | 1 + configs/xilinx_zynqmp_virt_defconfig | 1 + lib/mbedtls/Kconfig | 16 ++++++++++++++++ lib/mbedtls/Makefile | 16 +++++++++------- lib/mbedtls/mbedtls_def_config.h | 18 ++++++++++++++++++ 10 files changed, 50 insertions(+), 7 deletions(-)configs/amd_versal2_virt_defconfig +1
-0@@ -164,6 +164,7 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y # CONFIG_OPTEE_LIB is not set CONFIG_TOOLS_MKFWUMDATA=yconfigs/qemu_arm64_lwip_defconfig +1
-0@@ -11,3 +11,4 @@ CONFIG_CMD_WGET=y CONFIG_EFI_HTTP_BOOT=y CONFIG_WGET_HTTPS=y CONFIG_WGET_CACERT=y +CONFIG_ECDSA=yconfigs/starfive_visionfive2_defconfig +1
-0@@ -156,3 +156,4 @@ CONFIG_USB_GADGET=y CONFIG_WDT=y CONFIG_WDT_STARFIVE=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=yconfigs/xilinx_versal_net_virt_defconfig +1
-0@@ -154,4 +154,5 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=yconfigs/xilinx_versal_virt_defconfig +1
-0@@ -168,5 +168,6 @@ CONFIG_VIRTIO_MMIO=y CONFIG_VIRTIO_NET=y CONFIG_VIRTIO_BLK=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_TOOLS_MKFWUMDATA=yconfigs/xilinx_zynqmp_kria_defconfig +1
-0@@ -219,6 +219,7 @@ CONFIG_VIRTIO_BLK=y CONFIG_BINMAN_DTB="./arch/arm/dts/zynqmp-binman-som.dtb" CONFIG_PANIC_HANG=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_SPL_GZIP=y CONFIG_TOOLS_MKFWUMDATA=yconfigs/xilinx_zynqmp_virt_defconfig +1
-0@@ -237,6 +237,7 @@ CONFIG_VIRTIO_BLK=y CONFIG_BINMAN_DTB="./arch/arm/dts/zynqmp-binman.dtb" CONFIG_PANIC_HANG=y CONFIG_MBEDTLS_LIB=y +CONFIG_ECDSA=y CONFIG_TPM=y CONFIG_SPL_GZIP=y CONFIG_TOOLS_MKFWUMDATA=ylib/mbedtls/Kconfig +6
-0@@ -242,11 +242,16 @@ config MBEDTLS_LIB_X509 select X509_CERTIFICATE_PARSER_MBEDTLS if X509_CERTIFICATE_PARSER select PKCS7_MESSAGE_PARSER_MBEDTLS if PKCS7_MESSAGE_PARSER select MSCODE_PARSER_MBEDTLS if MSCODE_PARSER + select ECDSA_MBEDTLS if ECDSA help Enable MbedTLS certificate libraries. if MBEDTLS_LIB_X509 +config BIGNUM_MBEDTLS + bool + default n + config ASN1_DECODER_MBEDTLS bool "ASN1 decoder with MbedTLS certificate library" depends on MBEDTLS_LIB_X509 && ASN1_DECODER@@ -264,6 +269,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 +298,15 @@ config MSCODE_PARSER_MBEDTLS This option chooses MbedTLS certificate library for MS authenticode parser.Quoted 5 lines
lib/mbedtls/Kconfig config MSCODE_PARSER_MBEDTLS · line 304
Quoted 4 lines
lib/mbedtls/Kconfig +4
-0+config ECDSA_MBEDTLS + bool "Enable ECDSA support with MbedTLS certificate library" + depends on MBEDTLS_LIB_X509 + select ASN1_DECODERThis should be
ASN1_DECODER_MBEDTLS.
Quoted 6 lines
It was my first try, but I reach an issue.
IfASN1_DECODERis not selected and we selectASN1_DECODER_MBEDTLS, there is a conflict becauseASN1_DECODER_MBEDTLSdepends onASN1_DECODER. So to avoid this issue, I have keptASN1_DECODERin V3.
The dependency is intentional, I think you should have something like:
config ECDSA
select ASN1_DECODER
config MBEDTLS_LIB_X509
select ASN1_DECODER_MBEDTLS if ASN1_DECODER
config ECDSA_MBEDTLS
select ECDSA
select MBEDTLS_LIB_X509
This makes the kconfig dependency clear - all _MBEDTLS switches are under their origin.
Regards,
Raymond
Quoted 111 lines
Regards,
PhilippeQuoted 107 lines
Quoted 74 lines
lib/mbedtls/Kconfig +6
-0+ select BIGNUM_MBEDTLS + help + This option enables support of ECDSA with the MbedTLS certificate + library. + endif # MBEDTLS_LIB_X509 config MBEDTLS_LIB_TLS@@ -301,6 +316,7 @@ config MBEDTLS_LIB_TLS depends on ASYMMETRIC_PUBLIC_KEY_MBEDTLS depends on ASN1_DECODER_MBEDTLS depends on MBEDTLS_LIB + depends on ECDSA_MBEDTLS help Enable MbedTLS TLS library. Required for HTTPs support in wgetlib/mbedtls/Makefile +9
-7@@ -39,13 +39,14 @@ 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_)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) += \@@ -57,6 +58,12 @@ mbedtls_lib_x509-$(CONFIG_$(PHASE_)X509_CERTIFICATE_PARSER_MBEDTLS) += \ $(MBEDTLS_LIB_DIR)/x509_crt.o mbedtls_lib_x509-$(CONFIG_$(PHASE_)PKCS7_MESSAGE_PARSER_MBEDTLS) += \ $(MBEDTLS_LIB_DIR)/pkcs7.o +mbedtls_lib_x509-$(CONFIG_$(PHASE_)ECDSA_MBEDTLS) += \ + $(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)/pk_ecc.o #mbedTLS TLS support obj-$(CONFIG_$(XPL_)MBEDTLS_LIB_TLS) += mbedtls_lib_tls.o@@ -64,7 +71,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 +88,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 \lib/mbedtls/mbedtls_def_config.h +0
-0lib/mbedtls/mbedtls_def_config.h line 92
Quoted 4 lines
lib/mbedtls/mbedtls_def_config.h +1
-0@@ -89,6 +89,24 @@#define MBEDTLS_ASN1_WRITE_C #endif +#if CONFIG_IS_ENABLED (ECDSA_MBEDTLS )In the '
mbedtls_def_config.h' file, we use the kconfigs without the '_MBEDTLS' postfix.Regards,
RaymondQuoted 23 lines
lib/mbedtls/mbedtls_def_config.h +17
-1+#define MBEDTLS_ECDSA_C +#define MBEDTLS_ECP_C +#define MBEDTLS_BIGNUM_C +#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 +#endif /* #if CONFIG_IS_ENABLED(MBEDTLS_LIB_X509) */ #if CONFIG_IS_ENABLED (MBEDTLS_LIB_TLS ) --2.43.0
RFC PATCH v2 2/9 ecdsa: initial support of ecdsa using mbedtls
In reply to Philippe ReynesAdds an initial support of ecdsa verify using mbedtls.
---
v2:
- rename sw_ecdsa.c to ecdsa.c
include/crypto/internal/sw_ecdsa.h | 14 +++++ lib/mbedtls/Makefile | 3 + lib/mbedtls/ecdsa.c | 94 ++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 include/crypto/internal/sw_ecdsa.h create mode 100644 lib/mbedtls/ecdsa.c
include/crypto/internal/sw_ecdsa.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2026, Philippe Reynes <[email protected]> +*/ +#ifndef _SW_ECDSA +#define _SW_ECDSA + +struct ecdsa_public_key ; + +int sw_ecdsa_verify (const struct ecdsa_public_key *pubkey, +const void *hash,size_t hash_len, +const void *signature,size_t sig_len); + +#endif
lib/mbedtls/Makefile +3 -0
@@ -11,6 +11,9 @@ obj-$(CONFIG_$(PHASE_)SHA1_MBEDTLS) += sha1.o obj-$(CONFIG_$(PHASE_)SHA256_MBEDTLS) += sha256.o obj-$(CONFIG_$(PHASE_)SHA512_MBEDTLS) += sha512.o +# shim layer for ecdsa +obj-$(CONFIG_$(PHASE_)ECDSA_MBEDTLS) += ecdsa.o + # x509 libraries obj-$(CONFIG_$(PHASE_)ASYMMETRIC_PUBLIC_KEY_MBEDTLS) += \ public_key.o
lib/mbedtls/ecdsa.c new file +94 -0
94 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [RFC PATCH v2 2/9] ecdsa: initial support of ecdsa using mbedtls
Hi Philippe,
Quoted 9 lines · Philippe Reynes
Adds an initial support of ecdsa verify using mbedtls.
Signed-off-by Philippe Reynes <[email protected]>---
v2:
- renamesw_ecdsa.ctoecdsa.cinclude/crypto/internal/sw_ecdsa.h | 14 +++++
Please rename the file to 'ecdsa.h'.
Quoted 47 lines
lib/mbedtls/Makefile | 3 + lib/mbedtls/ecdsa.c | 94 ++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 include/crypto/internal/sw_ecdsa.h create mode 100644 lib/mbedtls/ecdsa.cinclude/crypto/internal/sw_ecdsa.h new file +14
-0@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2026, Philippe Reynes <[email protected]> +*/ +#ifndef _SW_ECDSA +#define _SW_ECDSA + +struct ecdsa_public_key ; + +int sw_ecdsa_verify (const struct ecdsa_public_key *pubkey, +const void *hash,size_t hash_len, +const void *signature,size_t sig_len); + +#endif lib/mbedtls/Makefile +3
-0@@ -11,6 +11,9 @@ obj-$(CONFIG_$(PHASE_)SHA1_MBEDTLS) += sha1.o obj-$(CONFIG_$(PHASE_)SHA256_MBEDTLS) += sha256.o obj-$(CONFIG_$(PHASE_)SHA512_MBEDTLS) += sha512.o +# shim layer for ecdsa +obj-$(CONFIG_$(PHASE_)ECDSA_MBEDTLS) += ecdsa.o + # x509 libraries obj-$(CONFIG_$(PHASE_)ASYMMETRIC_PUBLIC_KEY_MBEDTLS) += \ public_key.olib/mbedtls/ecdsa.c new file +1
-0@@ -0,0 +1,94 @@ +// SPDX-License-Identifier: GPL-2.0+
lib/mbedtls/ecdsa.c line 11
Quoted 10 lines
lib/mbedtls/ecdsa.c new file +10
-0+/* +* Copyright (C) 2026 Philippe Reynes <[email protected]> +*/ + +#include <crypto/ecdsa-uclass.h> +#include "mbedtls_options.h" /* required to access private fields */ +#include <mbedtls/ecdsa.h> +#include <mbedtls/ecp.h> + +static mbedtls_ecp_group_id sw_ecdsa_search_group_id (const char *curve_name)
Please remove the prefix 'sw_', using MbedTLS does not necessarily mean SW, as the library allows HW acceleration via hooks through '_ALT' configs.
Quoted 4 lines
lib/mbedtls/ecdsa.c new file +4
-0+{ +mbedtls_ecp_group_id grp_id =MBEDTLS_ECP_DP_NONE ; +const mbedtls_ecp_curve_info *info; +
lib/mbedtls/ecdsa.c line 25
Quoted 10 lines
lib/mbedtls/ecdsa.c new file +10
-0+if (!curve_name) + goto out; + +if (!strcmp (curve_name,"prime256v1" )) + grp_id =MBEDTLS_ECP_DP_SECP256R1 ; + + info =mbedtls_ecp_curve_list (); +while (info && info->name) { +if (!strcmp (curve_name, info->name)) + grp_id = info->grp_id;
If a match is found, the loop should break immediately.
Quoted 15 lines
lib/mbedtls/ecdsa.c new file +15
-0+ info++; + } + + out: +return grp_id; +} + +int sw_ecdsa_verify (const struct ecdsa_public_key *pubkey, +const void *hash,size_t hash_len, +const void *signature,size_t sig_len) +{ +mbedtls_ecp_group_id grp_id; +mbedtls_ecp_group grp; +const unsigned char *buf = hash; +size_t blen = hash_len;
lib/mbedtls/ecdsa.c line 50
Quoted 10 lines
lib/mbedtls/ecdsa.c new file +10
-0+mbedtls_ecp_point Q ; +mbedtls_mpi r, s; +int key_len; +int err =-1 ; + +if (!(pubkey->size_bits %8 )) + key_len = pubkey->size_bits /8 ; +else + key_len = pubkey->size_bits /8 +1 ; +
Missing signature length validation, for example:
if (sig_len != 2 * key_len)
return -EINVAL;
lib/mbedtls/ecdsa.c line 55
Quoted 5 lines
lib/mbedtls/ecdsa.c new file +5
-0+/* search the group */ + grp_id =sw_ecdsa_search_group_id (pubkey->curve_name); +if (grp_id ==MBEDTLS_ECP_DP_NONE ) { +printf ("%s: curve name %s not found\n" , + __func__, pubkey->curve_name);
Please use debug().
lib/mbedtls/ecdsa.c line 62
Quoted 7 lines
lib/mbedtls/ecdsa.c new file +7
-0+ goto out; + } + +/* init and load the group */ +mbedtls_ecp_group_init (&grp); + err =mbedtls_ecp_group_load (&grp, grp_id); +if (err <0 )
'if (err)'
lib/mbedtls/ecdsa.c line 69
Quoted 7 lines
lib/mbedtls/ecdsa.c new file +7
-0+ goto out; + +/* prepare the pubkey */ +mbedtls_ecp_point_init (&Q ); +mbedtls_mpi_init (&Q .X); +mbedtls_mpi_init (&Q .Y); +mbedtls_mpi_init (&Q .Z);
Redundant mpi_init on Q.X/Y/Z, as mbedtls_ecp_point_init() already initializes X, Y, Z.
lib/mbedtls/ecdsa.c line 71
Quoted 2 lines
lib/mbedtls/ecdsa.c new file +2
-0+mbedtls_mpi_read_binary (&Q .X, pubkey->x, key_len); +mbedtls_mpi_read_binary (&Q .Y, pubkey->y, key_len);
Missing return value checks for mbedtls_mpi_read_binary().
lib/mbedtls/ecdsa.c line 76
Quoted 5 lines
lib/mbedtls/ecdsa.c new file +5
-0+mbedtls_mpi_lset (&Q .Z,1 ); + +/* check if the pubkey is valid */ + err =mbedtls_ecp_check_pubkey (&grp, &Q ); +if (err <0 ) {
'if (err)'
lib/mbedtls/ecdsa.c line 77
Quoted 1 line
lib/mbedtls/ecdsa.c new file +1
-0+printf ("%s: public key is invalid (err = %d)\n" , __func__, err);
Please use debug().
lib/mbedtls/ecdsa.c line 83
Quoted 6 lines
lib/mbedtls/ecdsa.c new file +6
-0+ goto out; + } + +/* compute r */ +mbedtls_mpi_init (&r); +mbedtls_mpi_read_binary (&r, signature, key_len);
Missing return value checks for mbedtls_mpi_read_binary().
lib/mbedtls/ecdsa.c line 87
Quoted 4 lines
lib/mbedtls/ecdsa.c new file +4
-0+ +/* compute s */ +mbedtls_mpi_init (&s); +mbedtls_mpi_read_binary (&s, signature + key_len, key_len);
Missing return value checks for mbedtls_mpi_read_binary(). Please cast signature to const u8 * (or unsigned char *) before doing pointer arithmetic.
lib/mbedtls/ecdsa.c line 92
Quoted 5 lines
lib/mbedtls/ecdsa.c new file +5
-0+ +/* check the signature */ + err =mbedtls_ecdsa_verify (&grp, buf, blen, &Q , &r, &s); + + out:
Potential memory leak.
MbedTLS objects allocate internal memory after invoking mbedtls_ecp_group_load() or mbedtls_mpi_read_binary(), which must be freed before returning errors via:mbedtls_mpi_free()mbedtls_ecp_point_free()mbedtls_ecp_group_free()
lib/mbedtls/ecdsa.c line 93
Quoted 1 line
lib/mbedtls/ecdsa.c new file +1
-0+return err;
Please map all MbedTLS internal errors to U-Boot definitions.
Regards,
Raymond
Quoted 4 lines
lib/mbedtls/ecdsa.c new file +1
-1+} --2.43.0
RFC PATCH v2 3/9 test: lib: sw_ecdsa: add initial test
In reply to Philippe ReynesAdds tests to check that the function sw_ecdsa_verify using mbedtls is valid.
---
v2:
- little change to only use test with sha enabled
test/lib/Makefile | 1 + test/lib/sw_ecdsa.c | 465 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 466 insertions(+) create mode 100644 test/lib/sw_ecdsa.c
test/lib/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_$(PHASE_)UT_COMPRESSION) += compression.o ifeq ($(CONFIG_XPL_BUILD),) obj-y += abuf.o obj-y += alist.o +obj-$(CONFIG_ECDSA_MBEDTLS) += sw_ecdsa.o obj-$(CONFIG_EFI_LOADER) += efi_device_path.o efi_memory.o obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o ifdef CONFIG_RISCV
test/lib/sw_ecdsa.c new file +465 -0
465 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [RFC PATCH v2 3/9] test: lib: sw_ecdsa: add initial test
Hi Philippe,
Quoted 11 lines · Philippe Reynes
Adds tests to check that the function
sw_ecdsa_verifyusing mbedtls is valid.Signed-off-by Philippe Reynes <[email protected]>---
v2:
- little change to only use test with sha enabledtest/lib/Makefile | 1 + test/lib/sw_ecdsa.c | 465 ++++++++++++++++++++++++++++++++++++++++++++
Please rename the file to 'ecdsa.c'.
Quoted 29 lines
2 files changed, 466 insertions(+) create mode 100644 test/lib/sw_ecdsa.ctest/lib/Makefile +1
-0@@ -8,6 +8,7 @@ obj-$(CONFIG_$(PHASE_)UT_COMPRESSION) += compression.o ifeq ($(CONFIG_XPL_BUILD),) obj-y += abuf.o obj-y += alist.o +obj-$(CONFIG_ECDSA_MBEDTLS) += sw_ecdsa.o obj-$(CONFIG_EFI_LOADER) += efi_device_path.o efi_memory.o obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o ifdef CONFIG_RISCVtest/lib/sw_ecdsa.c new file +8
-0@@ -0,0 +1,465 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2026 Philippe Reynes <[email protected]> +*/ + +#include <command.h> +#include <image.h> +#include <test/lib.h>
test/lib/sw_ecdsa.c line 18
Quoted 10 lines
test/lib/sw_ecdsa.c new file +10
-0+#include <test/test.h> +#include <test/ut.h> +#include <crypto/ecdsa-uclass.h> +#include <crypto/internal/sw_ecdsa.h> + +#include <mbedtls/ecp.h> + +struct ecdsa_test_vector_s { +char *test_name; +char *curve_name;
'const char *' for both names.
test/lib/sw_ecdsa.c line 24
Quoted 6 lines
test/lib/sw_ecdsa.c new file +6
-0+unsigned char *x; +unsigned char *y; +int size_bits; +unsigned char *hash_type; +unsigned char *hash_message; +unsigned char *k;
The 'k' is unused throughout the code, please remove it from the structure and all the test vectors.
Quoted 341 lines
test/lib/sw_ecdsa.c new file +341
-0+unsigned char *r; +unsigned char *s; +int expected; +}; + +/* +* Those data come from RFC6979 +*/ + +struct ecdsa_test_vector_s ecdsa_test_vector[] = { +/* +* secp192r1 +*/ + { + .test_name ="secp192r1 sha1" , + .curve_name ="secp192r1" , + .x ="AC2C77F529F91689FEA0EA5EFEC7F210D8EEA0B9E047ED56" , + .y ="3BC723E57670BD4887EBC732C523063D0A7C957BC97C1C43" , + .size_bits =192 , + .hash_type ="sha-1" , + .hash_message ="sample" , + .k ="37D7CA00D2C7B0E5E412AC03BD44BA837FDD5B28CD3B0021" , + .r ="98C6BD12B23EAF5E2A2045132086BE3EB8EBD62ABF6698FF" , + .s ="57A22B07DEA9530F8DE9471B1DC6624472E8E2844BC25B64" , + .expected =0 , + }, + { + .test_name ="secp192r1 sha256" , + .curve_name ="secp192r1" , + .x ="AC2C77F529F91689FEA0EA5EFEC7F210D8EEA0B9E047ED56" , + .y ="3BC723E57670BD4887EBC732C523063D0A7C957BC97C1C43" , + .size_bits =192 , + .hash_type ="sha-256" , + .hash_message ="sample" , + .k ="32B1B6D7D42A05CB449065727A84804FB1A3E34D8F261496" , + .r ="4B0B8CE98A92866A2820E20AA6B75B56382E0F9BFD5ECB55" , + .s ="CCDB006926EA9565CBADC840829D8C384E06DE1F1E381B85" , + .expected =0 , + }, + { + .test_name ="secp192r1 sha384" , + .curve_name ="secp192r1" , + .x ="AC2C77F529F91689FEA0EA5EFEC7F210D8EEA0B9E047ED56" , + .y ="3BC723E57670BD4887EBC732C523063D0A7C957BC97C1C43" , + .size_bits =192 , + .hash_type ="sha-384" , + .hash_message ="sample" , + .k ="4730005C4FCB01834C063A7B6760096DBE284B8252EF4311" , + .r ="DA63BF0B9ABCF948FBB1E9167F136145F7A20426DCC287D5" , + .s ="C3AA2C960972BD7A2003A57E1C4C77F0578F8AE95E31EC5E" , + .expected =0 , + }, + { + .test_name ="secp192r1 sha512" , + .curve_name ="secp192r1" , + .x ="AC2C77F529F91689FEA0EA5EFEC7F210D8EEA0B9E047ED56" , + .y ="3BC723E57670BD4887EBC732C523063D0A7C957BC97C1C43" , + .size_bits =192 , + .hash_type ="sha-512" , + .hash_message ="sample" , + .k ="A2AC7AB055E4F20692D49209544C203A7D1F2C0BFBC75DB1" , + .r ="4D60C5AB1996BD848343B31C00850205E2EA6922DAC2E4B8" , + .s ="3F6E837448F027A1BF4B34E796E32A811CBB4050908D8F67" , + .expected =0 , + }, + { + .test_name ="secp192r1 sha512 error" , + .curve_name ="secp192r1" , + .x ="AC2C77F529F91689FEA0EA5EFEC7F210D8EEA0B9E047ED56" , + .y ="3BC723E57670BD4887EBC732C523063D0A7C957BC97C1C43" , + .size_bits =192 , + .hash_type ="sha-512" , + .hash_message ="sample" , + .k ="A2AC7AB055E4F20692D49209544C203A7D1F2C0BFBC75DB1" , + .r ="4D60C5AB1996BD848343B31C00850205E2EA6922DAC2E4B8" , + .s ="0F6E837448F027A1BF4B34E796E32A811CBB4050908D8F67" , + .expected =MBEDTLS_ERR_ECP_VERIFY_FAILED , + }, +/* +* secp224r1 +*/ + { + .test_name ="secp224r1 sha1" , + .curve_name ="secp224r1" , + .x ="00CF08DA5AD719E42707FA431292DEA11244D64FC51610D94B130D6C" , + .y ="EEAB6F3DEBE455E3DBF85416F7030CBD94F34F2D6F232C69F3C1385A" , + .size_bits =224 , + .hash_type ="sha-1" , + .hash_message ="sample" , + .k ="7EEFADD91110D8DE6C2C470831387C50D3357F7F4D477054B8B426BC" , + .r ="22226F9D40A96E19C4A301CE5B74B115303C0F3A4FD30FC257FB57AC" , + .s ="66D1CDD83E3AF75605DD6E2FEFF196D30AA7ED7A2EDF7AF475403D69" , + .expected =0 , + }, + { + .test_name ="secp224r1 sha256" , + .curve_name ="secp224r1" , + .x ="00CF08DA5AD719E42707FA431292DEA11244D64FC51610D94B130D6C" , + .y ="EEAB6F3DEBE455E3DBF85416F7030CBD94F34F2D6F232C69F3C1385A" , + .size_bits =224 , + .hash_type ="sha-256" , + .hash_message ="sample" , + .k ="AD3029E0278F80643DE33917CE6908C70A8FF50A411F06E41DEDFCDC" , + .r ="61AA3DA010E8E8406C656BC477A7A7189895E7E840CDFE8FF42307BA" , + .s ="BC814050DAB5D23770879494F9E0A680DC1AF7161991BDE692B10101" , + .expected =0 , + }, + { + .test_name ="secp224r1 sha384" , + .curve_name ="secp224r1" , + .x ="00CF08DA5AD719E42707FA431292DEA11244D64FC51610D94B130D6C" , + .y ="EEAB6F3DEBE455E3DBF85416F7030CBD94F34F2D6F232C69F3C1385A" , + .size_bits =224 , + .hash_type ="sha-384" , + .hash_message ="sample" , + .k ="52B40F5A9D3D13040F494E83D3906C6079F29981035C7BD51E5CAC40" , + .r ="0B115E5E36F0F9EC81F1325A5952878D745E19D7BB3EABFABA77E953" , + .s ="830F34CCDFE826CCFDC81EB4129772E20E122348A2BBD889A1B1AF1D" , + .expected =0 , + }, + { + .test_name ="secp224r1 sha512" , + .curve_name ="secp224r1" , + .x ="00CF08DA5AD719E42707FA431292DEA11244D64FC51610D94B130D6C" , + .y ="EEAB6F3DEBE455E3DBF85416F7030CBD94F34F2D6F232C69F3C1385A" , + .size_bits =224 , + .hash_type ="sha-512" , + .hash_message ="sample" , + .k ="9DB103FFEDEDF9CFDBA05184F925400C1653B8501BAB89CEA0FBEC14" , + .r ="074BD1D979D5F32BF958DDC61E4FB4872ADCAFEB2256497CDAC30397" , + .s ="A4CECA196C3D5A1FF31027B33185DC8EE43F288B21AB342E5D8EB084" , + .expected =0 , + }, + { + .test_name ="secp224r1 sha512 error" , + .curve_name ="secp224r1" , + .x ="00CF08DA5AD719E42707FA431292DEA11244D64FC51610D94B130D6C" , + .y ="EEAB6F3DEBE455E3DBF85416F7030CBD94F34F2D6F232C69F3C1385A" , + .size_bits =224 , + .hash_type ="sha-512" , + .hash_message ="sample" , + .k ="9DB103FFEDEDF9CFDBA05184F925400C1653B8501BAB89CEA0FBEC14" , + .r ="074BD1D979D5F32BF958DDC61E4FB4872ADCAFEB2256497CDAC30397" , + .s ="04CECA196C3D5A1FF31027B33185DC8EE43F288B21AB342E5D8EB084" , + .expected =MBEDTLS_ERR_ECP_VERIFY_FAILED , + }, +/* +* secp256r1 +*/ + { + .test_name ="secp256r1 sha1" , + .curve_name ="secp256r1" , + .x ="60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6" , + .y ="7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299" , + .size_bits =256 , + .hash_type ="sha-1" , + .hash_message ="sample" , + .k ="882905F1227FD620FBF2ABF21244F0BA83D0DC3A9103DBBEE43A1FB858109DB4" , + .r ="61340C88C3AAEBEB4F6D667F672CA9759A6CCAA9FA8811313039EE4A35471D32" , + .s ="6D7F147DAC089441BB2E2FE8F7A3FA264B9C475098FDCF6E00D7C996E1B8B7EB" , + .expected =0 , + }, + { + .test_name ="secp256r1 sha256" , + .curve_name ="secp256r1" , + .x ="60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6" , + .y ="7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299" , + .size_bits =256 , + .hash_type ="sha-256" , + .hash_message ="sample" , + .k ="A6E3C57DD01ABE90086538398355DD4C3B17AA873382B0F24D6129493D8AAD60" , + .r ="EFD48B2AACB6A8FD1140DD9CD45E81D69D2C877B56AAF991C34D0EA84EAF3716" , + .s ="F7CB1C942D657C41D436C7A1B6E29F65F3E900DBB9AFF4064DC4AB2F843ACDA8" , + .expected =0 , + }, + { + .test_name ="secp256r1 sha384" , + .curve_name ="secp256r1" , + .x ="60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6" , + .y ="7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299" , + .size_bits =256 , + .hash_type ="sha-384" , + .hash_message ="sample" , + .k ="09F634B188CEFD98E7EC88B1AA9852D734D0BC272F7D2A47DECC6EBEB375AAD4" , + .r ="0EAFEA039B20E9B42309FB1D89E213057CBF973DC0CFC8F129EDDDC800EF7719" , + .s ="4861F0491E6998B9455193E34E7B0D284DDD7149A74B95B9261F13ABDE940954" , + .expected =0 , + }, + { + .test_name ="secp256r1 sha512" , + .curve_name ="secp256r1" , + .x ="60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6" , + .y ="7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299" , + .size_bits =256 , + .hash_type ="sha-512" , + .hash_message ="sample" , + .k ="5FA81C63109BADB88C1F367B47DA606DA28CAD69AA22C4FE6AD7DF73A7173AA5" , + .r ="8496A60B5E9B47C825488827E0495B0E3FA109EC4568FD3F8D1097678EB97F00" , + .s ="2362AB1ADBE2B8ADF9CB9EDAB740EA6049C028114F2460F96554F61FAE3302FE" , + .expected =0 , + }, + { + .test_name ="secp256r1 sha512 error" , + .curve_name ="secp256r1" , + .x ="60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6" , + .y ="7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299" , + .size_bits =256 , + .hash_type ="sha-512" , + .hash_message ="sample" , + .k ="5FA81C63109BADB88C1F367B47DA606DA28CAD69AA22C4FE6AD7DF73A7173AA5" , + .r ="8496A60B5E9B47C825488827E0495B0E3FA109EC4568FD3F8D1097678EB97F00" , + .s ="0362AB1ADBE2B8ADF9CB9EDAB740EA6049C028114F2460F96554F61FAE3302FE" , + .expected =MBEDTLS_ERR_ECP_VERIFY_FAILED , + }, +/* +* secp384r1 +*/ + { + .test_name ="secp384r1 sha1" , + .curve_name ="secp384r1" , + .x ="EC3A4E415B4E19A4568618029F427FA5DA9A8BC4AE92E02E06AAE5286B300C64DEF8F0EA9055866064A254515480BC13" , + .y ="8015D9B72D7D57244EA8EF9AC0C621896708A59367F9DFB9F54CA84B3F1C9DB1288B231C3AE0D4FE7344FD2533264720" , + .size_bits =384 , + .hash_type ="sha-1" , + .hash_message ="sample" , + .k ="4471EF7518BB2C7C20F62EAE1C387AD0C5E8E470995DB4ACF694466E6AB096630F29E5938D25106C3C340045A2DB01A7" , + .r ="EC748D839243D6FBEF4FC5C4859A7DFFD7F3ABDDF72014540C16D73309834FA37B9BA002899F6FDA3A4A9386790D4EB2" , + .s ="A3BCFA947BEEF4732BF247AC17F71676CB31A847B9FF0CBC9C9ED4C1A5B3FACF26F49CA031D4857570CCB5CA4424A443" , + .expected =0 , + }, + { + .test_name ="secp384r1 sha256" , + .curve_name ="secp384r1" , + .x ="EC3A4E415B4E19A4568618029F427FA5DA9A8BC4AE92E02E06AAE5286B300C64DEF8F0EA9055866064A254515480BC13" , + .y ="8015D9B72D7D57244EA8EF9AC0C621896708A59367F9DFB9F54CA84B3F1C9DB1288B231C3AE0D4FE7344FD2533264720" , + .size_bits =384 , + .hash_type ="sha-256" , + .hash_message ="sample" , + .k ="180AE9F9AEC5438A44BC159A1FCB277C7BE54FA20E7CF404B490650A8ACC414E375572342863C899F9F2EDF9747A9B60" , + .r ="21B13D1E013C7FA1392D03C5F99AF8B30C570C6F98D4EA8E354B63A21D3DAA33BDE1E888E63355D92FA2B3C36D8FB2CD" , + .s ="F3AA443FB107745BF4BD77CB3891674632068A10CA67E3D45DB2266FA7D1FEEBEFDC63ECCD1AC42EC0CB8668A4FA0AB0" , + .expected =0 , + }, + { + .test_name ="secp384r1 sha384" , + .curve_name ="secp384r1" , + .x ="EC3A4E415B4E19A4568618029F427FA5DA9A8BC4AE92E02E06AAE5286B300C64DEF8F0EA9055866064A254515480BC13" , + .y ="8015D9B72D7D57244EA8EF9AC0C621896708A59367F9DFB9F54CA84B3F1C9DB1288B231C3AE0D4FE7344FD2533264720" , + .size_bits =384 , + .hash_type ="sha-384" , + .hash_message ="sample" , + .k ="94ED910D1A099DAD3254E9242AE85ABDE4BA15168EAF0CA87A555FD56D10FBCA2907E3E83BA95368623B8C4686915CF9" , + .r ="94EDBB92A5ECB8AAD4736E56C691916B3F88140666CE9FA73D64C4EA95AD133C81A648152E44ACF96E36DD1E80FABE46" , + .s ="99EF4AEB15F178CEA1FE40DB2603138F130E740A19624526203B6351D0A3A94FA329C145786E679E7B82C71A38628AC8" , + .expected =0 , + }, + { + .test_name ="secp384r1 sha512" , + .curve_name ="secp384r1" , + .x ="EC3A4E415B4E19A4568618029F427FA5DA9A8BC4AE92E02E06AAE5286B300C64DEF8F0EA9055866064A254515480BC13" , + .y ="8015D9B72D7D57244EA8EF9AC0C621896708A59367F9DFB9F54CA84B3F1C9DB1288B231C3AE0D4FE7344FD2533264720" , + .size_bits =384 , + .hash_type ="sha-512" , + .hash_message ="sample" , + .k ="92FC3C7183A883E24216D1141F1A8976C5B0DD797DFA597E3D7B32198BD35331A4E966532593A52980D0E3AAA5E10EC3" , + .r ="ED0959D5880AB2D869AE7F6C2915C6D60F96507F9CB3E047C0046861DA4A799CFE30F35CC900056D7C99CD7882433709" , + .s ="512C8CCEEE3890A84058CE1E22DBC2198F42323CE8ACA9135329F03C068E5112DC7CC3EF3446DEFCEB01A45C2667FDD5" , + .expected =0 , + }, + { + .test_name ="secp384r1 sha512 error" , + .curve_name ="secp384r1" , + .x ="EC3A4E415B4E19A4568618029F427FA5DA9A8BC4AE92E02E06AAE5286B300C64DEF8F0EA9055866064A254515480BC13" , + .y ="8015D9B72D7D57244EA8EF9AC0C621896708A59367F9DFB9F54CA84B3F1C9DB1288B231C3AE0D4FE7344FD2533264720" , + .size_bits =384 , + .hash_type ="sha-512" , + .hash_message ="sample" , + .k ="92FC3C7183A883E24216D1141F1A8976C5B0DD797DFA597E3D7B32198BD35331A4E966532593A52980D0E3AAA5E10EC3" , + .r ="ED0959D5880AB2D869AE7F6C2915C6D60F96507F9CB3E047C0046861DA4A799CFE30F35CC900056D7C99CD7882433709" , + .s ="012C8CCEEE3890A84058CE1E22DBC2198F42323CE8ACA9135329F03C068E5112DC7CC3EF3446DEFCEB01A45C2667FDD5" , + .expected =MBEDTLS_ERR_ECP_VERIFY_FAILED , + }, +/* +* secp521r1 +*/ + { + .test_name ="secp521r1 sha1" , + .curve_name ="secp521r1" , + .x ="01894550D0785932E00EAA23B694F213F8C3121F86DC97A04E5A7167DB4E5BCD371123D46E45DB6B5D5370A7F20FB633155D38FFA16D2BD761DCAC474B9A2F5023A4" , + .y ="00493101C962CD4D2FDDF782285E64584139C2F91B47F87FF82354D6630F746A28A0DB25741B5B34A828008B22ACC23F924FAAFBD4D33F81EA66956DFEAA2BFDFCF5" , + .size_bits =521 , + .hash_type ="sha-1" , + .hash_message ="sample" , + .k ="0089C071B419E1C2820962321787258469511958E80582E95D8378E0C2CCDB3CB42BEDE42F50E3FA3C71F5A76724281D31D9C89F0F91FC1BE4918DB1C03A5838D0F9" , + .r ="00343B6EC45728975EA5CBA6659BBB6062A5FF89EEA58BE3C80B619F322C87910FE092F7D45BB0F8EEE01ED3F20BABEC079D202AE677B243AB40B5431D497C55D75D" , + .s ="00E7B0E675A9B24413D448B8CC119D2BF7B2D2DF032741C096634D6D65D0DBE3D5694625FB9E8104D3B842C1B0E2D0B98BEA19341E8676AEF66AE4EBA3D5475D5D16" , + .expected =0 , + }, + { + .test_name ="secp521r1 sha256" , + .curve_name ="secp521r1" , + .x ="01894550D0785932E00EAA23B694F213F8C3121F86DC97A04E5A7167DB4E5BCD371123D46E45DB6B5D5370A7F20FB633155D38FFA16D2BD761DCAC474B9A2F5023A4" , + .y ="00493101C962CD4D2FDDF782285E64584139C2F91B47F87FF82354D6630F746A28A0DB25741B5B34A828008B22ACC23F924FAAFBD4D33F81EA66956DFEAA2BFDFCF5" , + .size_bits =521 , + .hash_type ="sha-256" , + .hash_message ="sample" , + .k ="00EDF38AFCAAECAB4383358B34D67C9F2216C8382AAEA44A3DAD5FDC9C32575761793FEF24EB0FC276DFC4F6E3EC476752F043CF01415387470BCBD8678ED2C7E1A0" , + .r ="01511BB4D675114FE266FC4372B87682BAECC01D3CC62CF2303C92B3526012659D16876E25C7C1E57648F23B73564D67F61C6F14D527D54972810421E7D87589E1A7" , + .s ="004A171143A83163D6DF460AAF61522695F207A58B95C0644D87E52AA1A347916E4F7A72930B1BC06DBE22CE3F58264AFD23704CBB63B29B931F7DE6C9D949A7ECFC" , + .expected =0 , + }, + { + .test_name ="secp521r1 sha384" , + .curve_name ="secp521r1" , + .x ="01894550D0785932E00EAA23B694F213F8C3121F86DC97A04E5A7167DB4E5BCD371123D46E45DB6B5D5370A7F20FB633155D38FFA16D2BD761DCAC474B9A2F5023A4" , + .y ="00493101C962CD4D2FDDF782285E64584139C2F91B47F87FF82354D6630F746A28A0DB25741B5B34A828008B22ACC23F924FAAFBD4D33F81EA66956DFEAA2BFDFCF5" , + .size_bits =521 , + .hash_type ="sha-384" , + .hash_message ="sample" , + .k ="01546A108BC23A15D6F21872F7DED661FA8431DDBD922D0DCDB77CC878C8553FFAD064C95A920A750AC9137E527390D2D92F153E66196966EA554D9ADFCB109C4211" , + .r ="01EA842A0E17D2DE4F92C15315C63DDF72685C18195C2BB95E572B9C5136CA4B4B576AD712A52BE9730627D16054BA40CC0B8D3FF035B12AE75168397F5D50C67451" , + .s ="01F21A3CEE066E1961025FB048BD5FE2B7924D0CD797BABE0A83B66F1E35EEAF5FDE143FA85DC394A7DEE766523393784484BDF3E00114A1C857CDE1AA203DB65D61" , + .expected =0 , + }, + { + .test_name ="secp521r1 sha512" , + .curve_name ="secp521r1" , + .x ="01894550D0785932E00EAA23B694F213F8C3121F86DC97A04E5A7167DB4E5BCD371123D46E45DB6B5D5370A7F20FB633155D38FFA16D2BD761DCAC474B9A2F5023A4" , + .y ="00493101C962CD4D2FDDF782285E64584139C2F91B47F87FF82354D6630F746A28A0DB25741B5B34A828008B22ACC23F924FAAFBD4D33F81EA66956DFEAA2BFDFCF5" , + .size_bits =521 , + .hash_type ="sha-512" , + .hash_message ="sample" , + .k ="01DAE2EA071F8110DC26882D4D5EAE0621A3256FC8847FB9022E2B7D28E6F10198B1574FDD03A9053C08A1854A168AA5A57470EC97DD5CE090124EF52A2F7ECBFFD3" , + .r ="00C328FAFCBD79DD77850370C46325D987CB525569FB63C5D3BC53950E6D4C5F174E25A1EE9017B5D450606ADD152B534931D7D4E8455CC91F9B15BF05EC36E377FA" , + .s ="00617CCE7CF5064806C467F678D3B4080D6F1CC50AF26CA209417308281B68AF282623EAA63E5B5C0723D8B8C37FF0777B1A20F8CCB1DCCC43997F1EE0E44DA4A67A" , + .expected =0 , + }, + { + .test_name ="secp521r1 sha512 error" , + .curve_name ="secp521r1" , + .x ="01894550D0785932E00EAA23B694F213F8C3121F86DC97A04E5A7167DB4E5BCD371123D46E45DB6B5D5370A7F20FB633155D38FFA16D2BD761DCAC474B9A2F5023A4" ,
test/lib/sw_ecdsa.c line 375
Quoted 10 lines
test/lib/sw_ecdsa.c new file +10
-0+ .y = "00493101C962CD4D2FDDF782285E64584139C2F91B47F87FF82354D6630F746A28A0DB25741B5B34A828008B22ACC23F924FAAFBD4D33F81EA66956DFEAA2BFDFCF5", + .size_bits = 521, + .hash_type = "sha-512", + .hash_message = "sample", + .k = "01DAE2EA071F8110DC26882D4D5EAE0621A3256FC8847FB9022E2B7D28E6F10198B1574FDD03A9053C08A1854A168AA5A57470EC97DD5CE090124EF52A2F7ECBFFD3", + .r = "00C328FAFCBD79DD77850370C46325D987CB525569FB63C5D3BC53950E6D4C5F174E25A1EE9017B5D450606ADD152B534931D7D4E8455CC91F9B15BF05EC36E377FA", + .s = "00017CCE7CF5064806C467F678D3B4080D6F1CC50AF26CA209417308281B68AF282623EAA63E5B5C0723D8B8C37FF0777B1A20F8CCB1DCCC43997F1EE0E44DA4A67A", + .expected = MBEDTLS_ERR_ECP_VERIFY_FAILED, + }, +};
All '.expected = MBEDTLS_ERR_ECP_VERIFY_FAILED' above should be changed to U-Boot error code, as I commented in your patch [2/9], we should map all MbedTLS internal error code to U-Boot error code.
test/lib/sw_ecdsa.c line 377
Quoted 2 lines
test/lib/sw_ecdsa.c new file +2
-0+ +int ecdsa_test (struct unit_test_state *uts,struct ecdsa_test_vector_s *tv)
static int ecdsa_test(struct unit_test_state *uts,
const struct ecdsa_test_vector_s *tv)
Quoted 7 lines
test/lib/sw_ecdsa.c new file +7
-0+{ +struct ecdsa_public_key pubkey; +unsigned char x[528 /8 ]; +unsigned char y[528 /8 ]; +unsigned char hash[512 /8 ]; +unsigned int hash_len; +unsigned char signature[528 /8 *2 ];
test/lib/sw_ecdsa.c line 394
Quoted 10 lines
test/lib/sw_ecdsa.c new file +10
-0+unsigned int sig_len; +int ret; + +if (!(tv->size_bits %8 )) + sig_len = tv->size_bits /8 ; +else + sig_len = tv->size_bits /8 +1 ; + + pubkey.curve_name = tv->curve_name; +hex2bin (x, tv->x,strlen (tv->x) /2 );
Please check the return value of hex2bin(), same for all below.
test/lib/sw_ecdsa.c line 404
Quoted 10 lines
test/lib/sw_ecdsa.c new file +10
-0+ pubkey.x = x; +hex2bin (y, tv->y,strlen (tv->y) /2 ); + pubkey.y = y; + pubkey.size_bits = tv->size_bits; + +if (!strcmp (tv->hash_type,"sha-1" )) { +#if CONFIG_IS_ENABLED (SHA1 ) + hash_len =SHA1_SUM_LEN ; +sha1_csum_wd (tv->hash_message,strlen (tv->hash_message), + hash, hash_len);
The last arg of 'sha*_csum_wd()' is the watchdog chunk size, not the hash output length.
Passing hash_len here happens to work (small chunk), but it is semantically wrong.
Please use 0 (no watchdog) or a proper chunk constant. Same for all 'sha*_csum_wd()' below.
Quoted 46 lines
test/lib/sw_ecdsa.c new file +46
-0+#else +/* sha1 is not supported so we skip this test */ + goto out; +#endif + }else if (!strcmp (tv->hash_type,"sha-256" )) { +#if CONFIG_IS_ENABLED (SHA256 ) + hash_len =SHA256_SUM_LEN ; +sha256_csum_wd (tv->hash_message,strlen (tv->hash_message), + hash, hash_len); +#else +/* sha256 is not supported so we skip this test */ + goto out; +#endif + }else if (!strcmp (tv->hash_type,"sha-384" )) { +#if CONFIG_IS_ENABLED (SHA384 ) + hash_len =SHA384_SUM_LEN ; +sha384_csum_wd (tv->hash_message,strlen (tv->hash_message), + hash, hash_len); +#else +/* sha384 is not supported so we skip this test */ + goto out; +#endif + }else if (!strcmp (tv->hash_type,"sha-512" )) { +#if CONFIG_IS_ENABLED (SHA512 ) + hash_len =SHA512_SUM_LEN ; +sha512_csum_wd (tv->hash_message,strlen (tv->hash_message), + hash, hash_len); +#else +/* sha512 is not supported so we skip this test */ + goto out; +#endif + }else { +ut_reportf ("Unknown hash type (%s)" , tv->hash_type); + goto out; + } + +memset (signature,0 ,sizeof (signature)); +hex2bin (signature, tv->r, sig_len); +hex2bin (signature + sig_len, tv->s, sig_len); + sig_len = sig_len *2 ; + + ret =sw_ecdsa_verify (&pubkey, + hash, hash_len, + signature, sig_len); +ut_asserteq (tv->expected, ret); +
test/lib/sw_ecdsa.c line 460
Quoted 10 lines
test/lib/sw_ecdsa.c new file +10
-0+ out: +return 0 ; +} + +static int lib_sw_ecdsa (struct unit_test_state *uts) +{ +int i, num_test =ARRAY_SIZE (ecdsa_test_vector); + +for (i =0 ; i < num_test; i++) +ecdsa_test (uts, &ecdsa_test_vector[i]);
Please check the return code here, or change ecdsa_test to void (Seems that it always returns 0).
Regards,
Raymond
Quoted 8 lines
test/lib/sw_ecdsa.c new file +5
-1+ +return 0 ; +} + +LIB_TEST (lib_sw_ecdsa,0 ); --2.43.0
RFC PATCH v2 4/9 drivers: crypto: add software ecdsa support
In reply to Philippe ReynesAdd an software ecdsa driver so it is
now possible to use ecdsa signature on
board without ecdsa hardware support.
---
v2:
- no change
drivers/crypto/Kconfig | 2 ++ drivers/crypto/Makefile | 1 + drivers/crypto/ecdsa/Kconfig | 6 ++++++ drivers/crypto/ecdsa/Makefile | 6 ++++++ drivers/crypto/ecdsa/ecdsa-sw.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 drivers/crypto/ecdsa/Kconfig create mode 100644 drivers/crypto/ecdsa/Makefile create mode 100644 drivers/crypto/ecdsa/ecdsa-sw.c
drivers/crypto/Kconfig +2 -0
@@ -12,4 +12,6 @@ source "drivers/crypto/nuvoton/Kconfig" source "drivers/crypto/tegra/Kconfig" +source "drivers/crypto/ecdsa/Kconfig" + endmenu
drivers/crypto/Makefile +1 -0
@@ -4,6 +4,7 @@ # http://www.samsung.com obj-$(CONFIG_EXYNOS_ACE_SHA) += ace_sha.o +obj-$(CONFIG_ECDSA) += ecdsa/ obj-y += aes/ obj-y += rsa_mod_exp/ obj-y += fsl/
drivers/crypto/ecdsa/Kconfig new file +6 -0
@@ -0,0 +1,6 @@ +config ECDSA_SW + bool "Enable driver for ECDSA in software" + depends on ECDSA_MBEDTLS + help + Enable driver for ECDSA operations in software. Currently + it supports multiple ECDSA algorithm.
drivers/crypto/ecdsa/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2026 Philippe Reynes <[email protected]> +# + +obj-$(CONFIG_ECDSA_SW) += ecdsa-sw.o
drivers/crypto/ecdsa/ecdsa-sw.c new file +33 -0
@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2026 Philippe Reynes <[email protected]> +*/ +#include <dm/device.h> +#include <linux/types.h> +#include <u-boot/ecdsa.h> +#include <crypto/ecdsa-uclass.h> +#include <dm/platdata.h> +#include <crypto/internal/sw_ecdsa.h> + +static int ops_sw_ecdsa_verify (__always_unused struct udevice *dev, +const struct ecdsa_public_key *pubkey, +const void *hash,size_t hash_len, +const void *signature,size_t sig_len) +{ +return sw_ecdsa_verify (pubkey, hash, hash_len, signature, sig_len); +} + +static const struct ecdsa_ops sw_ecdsa_ops = { + .verify = ops_sw_ecdsa_verify, +}; + +U_BOOT_DRIVER (sw_ecdsa) = { + .name ="sw_ecdsa" , + .id =UCLASS_ECDSA , + .ops = &sw_ecdsa_ops, + .flags =DM_FLAG_PRE_RELOC , +}; + +U_BOOT_DRVINFO (sw_ecdsa) = { + .name ="sw_ecdsa" , +};
Signature · 1 line
2.43.0
Re: [RFC PATCH v2 4/9] drivers: crypto: add software ecdsa support
Hi Philippe,
Quoted 49 lines · Philippe Reynes
Add an software ecdsa driver so it is
now possible to use ecdsa signature on
board without ecdsa hardware support.Signed-off-by Philippe Reynes <[email protected]>---
v2:
- no changedrivers/crypto/Kconfig | 2 ++ drivers/crypto/Makefile | 1 + drivers/crypto/ecdsa/Kconfig | 6 ++++++ drivers/crypto/ecdsa/Makefile | 6 ++++++ drivers/crypto/ecdsa/ecdsa-sw.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 drivers/crypto/ecdsa/Kconfig create mode 100644 drivers/crypto/ecdsa/Makefile create mode 100644 drivers/crypto/ecdsa/ecdsa-sw.cdrivers/crypto/Kconfig +2
-0@@ -12,4 +12,6 @@ source "drivers/crypto/nuvoton/Kconfig" source "drivers/crypto/tegra/Kconfig" +source "drivers/crypto/ecdsa/Kconfig" + endmenudrivers/crypto/Makefile +1
-0@@ -4,6 +4,7 @@ # http://www.samsung.com obj-$(CONFIG_EXYNOS_ACE_SHA) += ace_sha.o +obj-$(CONFIG_ECDSA) += ecdsa/ obj-y += aes/ obj-y += rsa_mod_exp/ obj-y += fsl/drivers/crypto/ecdsa/Kconfig new file +0
-0
drivers/crypto/ecdsa/Kconfig line 6
Quoted 6 lines
drivers/crypto/ecdsa/Kconfig new file +6
-0@@ -0,0 +1,6 @@ +config ECDSA_SW + bool "Enable driver for ECDSA in software" + depends on ECDSA_MBEDTLS + help + Enable driver for ECDSA operations in software. Currently + it supports multiple ECDSA algorithm.
Same comments as I placed in your patch [0/9], ECDSA_SW is not required and can be replaced by ECDSA_MBEDTLS.
Regards,
Raymond
Quoted 54 lines
drivers/crypto/ecdsa/Makefile new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2026 Philippe Reynes <[email protected]> +# + +obj-$(CONFIG_ECDSA_SW) += ecdsa-sw.odrivers/crypto/ecdsa/ecdsa-sw.c new file +33
-1@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2026 Philippe Reynes <[email protected]> +*/ +#include <dm/device.h> +#include <linux/types.h> +#include <u-boot/ecdsa.h> +#include <crypto/ecdsa-uclass.h> +#include <dm/platdata.h> +#include <crypto/internal/sw_ecdsa.h> + +static int ops_sw_ecdsa_verify (__always_unused struct udevice *dev, +const struct ecdsa_public_key *pubkey, +const void *hash,size_t hash_len, +const void *signature,size_t sig_len) +{ +return sw_ecdsa_verify (pubkey, hash, hash_len, signature, sig_len); +} + +static const struct ecdsa_ops sw_ecdsa_ops = { + .verify = ops_sw_ecdsa_verify, +}; + +U_BOOT_DRIVER (sw_ecdsa) = { + .name ="sw_ecdsa" , + .id =UCLASS_ECDSA , + .ops = &sw_ecdsa_ops, + .flags =DM_FLAG_PRE_RELOC , +}; + +U_BOOT_DRVINFO (sw_ecdsa) = { + .name ="sw_ecdsa" , +}; --2.43.0
Re: [RFC PATCH v2 4/9] drivers: crypto: add software ecdsa support
Hi Raymond,
Le 20/02/2026 à 17:40, Raymond Mao a écrit :
Quoted 55 lines
This Mail comes from Outside of SoftAtHome: Do not answer, click links or open attachments unless you recognize the sender and know the content is safe.
Hi Philippe,
Quoted 49 lines · Philippe Reynes
Add an software ecdsa driver so it is
now possible to use ecdsa signature on
board without ecdsa hardware support.Signed-off-by Philippe Reynes <[email protected]>---
v2:
- no changedrivers/crypto/Kconfig | 2 ++ drivers/crypto/Makefile | 1 + drivers/crypto/ecdsa/Kconfig | 6 ++++++ drivers/crypto/ecdsa/Makefile | 6 ++++++ drivers/crypto/ecdsa/ecdsa-sw.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+)create mode 100644
drivers/crypto/ecdsa/Kconfigcreate mode 100644drivers/crypto/ecdsa/Makefilecreate mode 100644drivers/crypto/ecdsa/ecdsa-sw.cdrivers/crypto/Kconfig +2
-0@@ -12,4 +12,6 @@ source "drivers/crypto/nuvoton/Kconfig" source "drivers/crypto/tegra/Kconfig" +source "drivers/crypto/ecdsa/Kconfig" + endmenudrivers/crypto/Makefile +1
-0@@ -4,6 +4,7 @@ # http://www.samsung.com/ obj-$(CONFIG_EXYNOS_ACE_SHA) += ace_sha.o +obj-$(CONFIG_ECDSA) += ecdsa/ obj-y += aes/ obj-y += rsa_mod_exp/ obj-y += fsl/drivers/crypto/ecdsa/Kconfig new file +1
-0@@ -0,0 +1,6 @@ +config ECDSA_SW
Quoted 8 lines
drivers/crypto/ecdsa/Kconfig line 6
Quoted 5 lines
drivers/crypto/ecdsa/Kconfig new file +5
-0+ bool "Enable driver for ECDSA in software" + depends on ECDSA_MBEDTLS + help + Enable driver for ECDSA operations in software. Currently + it supports multiple ECDSA algorithm.Same comments as I placed in your patch [0/9],
ECDSA_SWis not required and can be replaced byECDSA_MBEDTLS.
I have discovered that this driver should also depend on ECDSA_VERIFY.
Otherwise we may define a driver (defined in this file) without a device (defined in lib/ecdsa/ecdsa-verify.c), and that leads to a crash à boot.
So I have kept this config in v3.
Quoted 3 lines
Regards,
Raymond
Regards,
Philippe
Quoted 55 lines
Quoted 55 lines
drivers/crypto/ecdsa/Makefile new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2026 Philippe Reynes <[email protected]> +# + +obj-$(CONFIG_ECDSA_SW) += ecdsa-sw.odrivers/crypto/ecdsa/ecdsa-sw.c new file +33
-1@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2026 Philippe Reynes <[email protected]> +*/ +#include <dm/device.h> +#include <linux/types.h> +#include <u-boot/ecdsa.h> +#include <crypto/ecdsa-uclass.h> +#include <dm/platdata.h> +#include <crypto/internal/sw_ecdsa.h> + +static int ops_sw_ecdsa_verify (__always_unused struct udevice *dev, +const struct ecdsa_public_key *pubkey, +const void *hash,size_t hash_len, +const void *signature,size_t sig_len) +{ +return sw_ecdsa_verify (pubkey, hash, hash_len, signature, sig_len); +} + +static const struct ecdsa_ops sw_ecdsa_ops = { + .verify = ops_sw_ecdsa_verify, +}; + +U_BOOT_DRIVER (sw_ecdsa) = { + .name ="sw_ecdsa" , + .id =UCLASS_ECDSA , + .ops = &sw_ecdsa_ops, + .flags =DM_FLAG_PRE_RELOC , +}; + +U_BOOT_DRVINFO (sw_ecdsa) = { + .name ="sw_ecdsa" , +}; --2.43.0
Re: [RFC PATCH v2 4/9] drivers: crypto: add software ecdsa support
Hi Philippe,
Quoted 68 lines · Philippe Reynes
Hi Raymond,
Quoted 55 lines · Raymond Mao
This Mail comes from Outside of SoftAtHome: Do not answer, click links or open attachments unless you recognize the sender and know the content is safe.
Hi Philippe,
Quoted 49 lines · Philippe Reynes
Add an software ecdsa driver so it is
now possible to use ecdsa signature on
board without ecdsa hardware support.Signed-off-by Philippe Reynes <[email protected]>---
v2:
- no changedrivers/crypto/Kconfig | 2 ++ drivers/crypto/Makefile | 1 + drivers/crypto/ecdsa/Kconfig | 6 ++++++ drivers/crypto/ecdsa/Makefile | 6 ++++++ drivers/crypto/ecdsa/ecdsa-sw.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+)create mode 100644
drivers/crypto/ecdsa/Kconfigcreate mode 100644drivers/crypto/ecdsa/Makefilecreate mode 100644drivers/crypto/ecdsa/ecdsa-sw.cdrivers/crypto/Kconfig +2
-0@@ -12,4 +12,6 @@ source "drivers/crypto/nuvoton/Kconfig" source "drivers/crypto/tegra/Kconfig" +source "drivers/crypto/ecdsa/Kconfig" + endmenudrivers/crypto/Makefile +1
-0@@ -4,6 +4,7 @@ # http://www.samsung.com/ obj-$(CONFIG_EXYNOS_ACE_SHA) += ace_sha.o +obj-$(CONFIG_ECDSA) += ecdsa/ obj-y += aes/ obj-y += rsa_mod_exp/ obj-y += fsl/drivers/crypto/ecdsa/Kconfig new file +1
-0@@ -0,0 +1,6 @@ +config ECDSA_SWQuoted 8 lines
drivers/crypto/ecdsa/Kconfig line 6
Quoted 5 lines
drivers/crypto/ecdsa/Kconfig new file +5
-0+ bool "Enable driver for ECDSA in software" + depends on ECDSA_MBEDTLS + help + Enable driver for ECDSA operations in software. Currently + it supports multiple ECDSA algorithm.Same comments as I placed in your patch [0/9],
ECDSA_SWis not required and can be replaced byECDSA_MBEDTLS.
Quoted 6 lines
I have discovered that this driver should also depend on
ECDSA_VERIFY. Otherwise we may define a driver (defined in this file) without a device (defined inlib/ecdsa/ecdsa-verify.c),
and that leads to a crash à boot.
So I have kept this config in v3.
Can the implementation of RSA be a reference?
It has RSA, RSA_VERIFY without coupling with impl '_SW' or '_MBEDTLS'.
Raymond
Quoted 61 lines
Quoted 3 lines
Regards,
RaymondRegards,
PhilippeQuoted 55 lines
Quoted 55 lines
drivers/crypto/ecdsa/Makefile new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2026 Philippe Reynes <[email protected]> +# + +obj-$(CONFIG_ECDSA_SW) += ecdsa-sw.odrivers/crypto/ecdsa/ecdsa-sw.c new file +33
-1@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2026 Philippe Reynes <[email protected]> +*/ +#include <dm/device.h> +#include <linux/types.h> +#include <u-boot/ecdsa.h> +#include <crypto/ecdsa-uclass.h> +#include <dm/platdata.h> +#include <crypto/internal/sw_ecdsa.h> + +static int ops_sw_ecdsa_verify (__always_unused struct udevice *dev, +const struct ecdsa_public_key *pubkey, +const void *hash,size_t hash_len, +const void *signature,size_t sig_len) +{ +return sw_ecdsa_verify (pubkey, hash, hash_len, signature, sig_len); +} + +static const struct ecdsa_ops sw_ecdsa_ops = { + .verify = ops_sw_ecdsa_verify, +}; + +U_BOOT_DRIVER (sw_ecdsa) = { + .name ="sw_ecdsa" , + .id =UCLASS_ECDSA , + .ops = &sw_ecdsa_ops, + .flags =DM_FLAG_PRE_RELOC , +}; + +U_BOOT_DRVINFO (sw_ecdsa) = { + .name ="sw_ecdsa" , +}; --2.43.0
RFC PATCH v2 5/9 ecdsa: fix support of secp521r1
In reply to Philippe ReynesCurrent implementation of ecdsa only supports key len aligned on 8 bits. But the curve secp521r1 use a key of 521 bits which is not aligned on 8 bits. In this commit, we update the key management for ecdsa to support key of any lenght.
---
v2:
- intitial version
lib/ecdsa/ecdsa-libcrypto.c | 21 +++++++++++++++++++-- lib/ecdsa/ecdsa-verify.c | 24 ++++++++++++++++++++++-- lib/fdt-libcrypto.c | 2 +- tools/image-sig-host.c | 2 +- 4 files changed, 43 insertions(+), 6 deletions(-)
lib/ecdsa/ecdsa-libcrypto.c +19 -2
@@ -45,6 +45,7 @@ static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node) {int x_len;int y_len; +int expected_len; key->curve_name =fdt_getprop (fdt, node,"ecdsa,curve" ,NULL );if (!key->curve_name)
@@ -54,6 +55,8 @@ static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node) key->size_bits =256 ; else if (!strcmp(key->curve_name, "secp384r1")) key->size_bits =384 ; + else if (!strcmp(key->curve_name, "secp521r1")) + key->size_bits =521 ; else return -EINVAL;
@@ -63,7 +66,19 @@ static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node)if (!key->x || !key->y)return -EINVAL ; -if (x_len != key->size_bits /8 || y_len != key->size_bits /8 ) +/* +* the public key is stored as an array of u32, so if the key size if +* not a multiple of 32 (for example 521), we may have extra bytes. +* To avoid any issue later, we shift the x and y pointer to the first +* useful byte. +*/ + expected_len = (key->size_bits +7 ) /8 ; +if (x_len > expected_len) + key->x += x_len - expected_len; +if (y_len > expected_len) + key->y += y_len - expected_len; + +if (x_len < expected_len || y_len < expected_len)return -EINVAL ;return 0 ;
@@ -89,6 +104,8 @@ static int read_key_from_fdt(struct signer *ctx, const void *fdt, int node) nid = NID_X9_62_prime256v1; }else if (!strcmp (pubkey.curve_name,"secp384r1" )) { nid = NID_secp384r1; + }else if (!strcmp (pubkey.curve_name,"secp521r1" )) { + nid = NID_secp521r1; }else {fprintf (stderr,"Unsupported curve name: '%s'\n" , pubkey.curve_name);return -EINVAL ;
@@ -111,7 +128,7 @@ static int read_key_from_fdt(struct signer *ctx, const void *fdt, int node)return -ENOMEM ; } - len = pubkey.size_bits /8 ; + len = (pubkey.size_bits +7 ) /8 ;uint8_t buf[1 + len *2 ];
lib/ecdsa/ecdsa-verify.c +22 -2
@@ -24,13 +24,15 @@ static int ecdsa_key_size(const char *curve_name)return 256 ; else if (!strcmp(curve_name, "secp384r1"))return 384 ; + else if (!strcmp(curve_name, "secp521r1")) +return 521 ;return 0 ; }static int fdt_get_key (struct ecdsa_public_key *key,const void *fdt,int node) { -int x_len, y_len; +int expected_len, x_len, y_len; key->curve_name =fdt_getprop (fdt, node,"ecdsa,curve" ,NULL );if (!key->curve_name) {
@@ -50,7 +52,19 @@ static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node)if (!key->x || !key->y)return -EINVAL ; -if (x_len != (key->size_bits /8 ) || y_len != (key->size_bits /8 )) { +/* +* the public key is stored as an array of u32, so if the key size if +* not a multiple of 32 (for example 521), we may have extra bytes. +* To avoid any issue later, we shift the x and y pointer to the first +* useful byte. +*/ + expected_len = (key->size_bits +7 ) /8 ; +if (x_len > expected_len) + key->x += x_len - expected_len; +if (y_len > expected_len) + key->y += y_len - expected_len; + +if (x_len < expected_len || y_len < expected_len) {printf ("%s: node=%d, curve@%p x@%p+%i y@%p+%i\n" , __func__, node, key->curve_name, key->x, x_len, key->y, y_len);return -EINVAL ;
@@ -135,6 +149,12 @@ U_BOOT_CRYPTO_ALGO(ecdsa384) = { .verify = ecdsa_verify, }; +U_BOOT_CRYPTO_ALGO (ecdsa521) = { + .name ="ecdsa521" , + .key_len =ECDSA521_BYTES , + .verify = ecdsa_verify, +}; +/* * uclass definition for ECDSA API *
lib/fdt-libcrypto.c +1 -1
@@ -10,7 +10,7 @@int fdt_add_bignum (void *blob,int noffset,const char *prop_name,BIGNUM *num,int num_bits) { -int nwords = num_bits /32 ; +int nwords = (num_bits +31 ) /32 ;int size;uint32_t *buf, *ptr;BIGNUM *tmp, *big2, *big32, *big2_32;
tools/image-sig-host.c +1 -1
@@ -84,7 +84,7 @@ struct crypto_algo crypto_algos[] = { .verify = ecdsa_verify, }, { - .name = "secp521r1", + .name = "ecdsa521", .key_len = ECDSA521_BYTES, .sign = ecdsa_sign, .add_verify_data = ecdsa_add_verify_data,
Signature · 1 line
2.43.0
Re: [RFC PATCH v2 5/9] ecdsa: fix support of secp521r1
Hi Philippe,
Quoted 39 lines · Philippe Reynes
Current implementation of ecdsa only supports key len aligned on 8 bits. But the curve secp521r1 use a key of 521 bits which is not aligned on 8 bits. In this commit, we update the key management for ecdsa to support key of any lenght.
Signed-off-by Philippe Reynes <[email protected]>---
v2:
- intitial versionlib/ecdsa/ecdsa-libcrypto.c | 21 +++++++++++++++++++-- lib/ecdsa/ecdsa-verify.c | 24 ++++++++++++++++++++++-- lib/fdt-libcrypto.c | 2 +- tools/image-sig-host.c | 2 +- 4 files changed, 43 insertions(+), 6 deletions(-)lib/ecdsa/ecdsa-libcrypto.c +3
-0@@ -45,6 +45,7 @@ static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node) {int x_len;int y_len; +int expected_len; key->curve_name =fdt_getprop (fdt, node,"ecdsa,curve" ,NULL );if (!key->curve_name)@@ -54,6 +55,8 @@ static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node) key->size_bits =256 ; else if (!strcmp(key->curve_name, "secp384r1")) key->size_bits =384 ; + else if (!strcmp(key->curve_name, "secp521r1")) + key->size_bits =521 ; else return -EINVAL;
lib/ecdsa/ecdsa-libcrypto.c static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node) · line 70
Quoted 6 lines
lib/ecdsa/ecdsa-libcrypto.c +2
-1@@ -63,7 +66,19 @@ static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node)if (!key->x || !key->y)return -EINVAL ; -if (x_len != key->size_bits /8 || y_len != key->size_bits /8 ) +/* +* the public key is stored as an array of u32, so if the key size if
s/if/is/
Quoted 54 lines
lib/ecdsa/ecdsa-libcrypto.c +14
-1+* not a multiple of 32 (for example 521), we may have extra bytes. +* To avoid any issue later, we shift the x and y pointer to the first +* useful byte. +*/ + expected_len = (key->size_bits +7 ) /8 ; +if (x_len > expected_len) + key->x += x_len - expected_len; +if (y_len > expected_len) + key->y += y_len - expected_len; + +if (x_len < expected_len || y_len < expected_len)return -EINVAL ;return 0 ;@@ -89,6 +104,8 @@ static int read_key_from_fdt(struct signer *ctx, const void *fdt, int node) nid = NID_X9_62_prime256v1; }else if (!strcmp (pubkey.curve_name,"secp384r1" )) { nid = NID_secp384r1; + }else if (!strcmp (pubkey.curve_name,"secp521r1" )) { + nid = NID_secp521r1; }else {fprintf (stderr,"Unsupported curve name: '%s'\n" , pubkey.curve_name);return -EINVAL ;@@ -111,7 +128,7 @@ static int read_key_from_fdt(struct signer *ctx, const void *fdt, int node)return -ENOMEM ; } - len = pubkey.size_bits /8 ; + len = (pubkey.size_bits +7 ) /8 ;uint8_t buf[1 + len *2 ];lib/ecdsa/ecdsa-verify.c +3
-1@@ -24,13 +24,15 @@ static int ecdsa_key_size(const char *curve_name)return 256 ; else if (!strcmp(curve_name, "secp384r1"))return 384 ; + else if (!strcmp(curve_name, "secp521r1")) +return 521 ;return 0 ; }static int fdt_get_key (struct ecdsa_public_key *key,const void *fdt,int node) { -int x_len, y_len; +int expected_len, x_len, y_len; key->curve_name =fdt_getprop (fdt, node,"ecdsa,curve" ,NULL );if (!key->curve_name) {
lib/ecdsa/ecdsa-verify.c static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node) · line 56
Quoted 6 lines
lib/ecdsa/ecdsa-verify.c +2
-1@@ -50,7 +52,19 @@ static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node)if (!key->x || !key->y)return -EINVAL ; -if (x_len != (key->size_bits /8 ) || y_len != (key->size_bits /8 )) { +/* +* the public key is stored as an array of u32, so if the key size if
s/if/is/
Regards,
Raymond
Quoted 56 lines
lib/ecdsa/ecdsa-verify.c +17
-0+* not a multiple of 32 (for example 521), we may have extra bytes. +* To avoid any issue later, we shift the x and y pointer to the first +* useful byte. +*/ + expected_len = (key->size_bits +7 ) /8 ; +if (x_len > expected_len) + key->x += x_len - expected_len; +if (y_len > expected_len) + key->y += y_len - expected_len; + +if (x_len < expected_len || y_len < expected_len) {printf ("%s: node=%d, curve@%p x@%p+%i y@%p+%i\n" , __func__, node, key->curve_name, key->x, x_len, key->y, y_len);return -EINVAL ;@@ -135,6 +149,12 @@ U_BOOT_CRYPTO_ALGO(ecdsa384) = { .verify = ecdsa_verify, }; +U_BOOT_CRYPTO_ALGO (ecdsa521) = { + .name ="ecdsa521" , + .key_len =ECDSA521_BYTES , + .verify = ecdsa_verify, +}; +/* * uclass definition for ECDSA API * lib/fdt-libcrypto.c +1
-1@@ -10,7 +10,7 @@int fdt_add_bignum (void *blob,int noffset,const char *prop_name,BIGNUM *num,int num_bits) { -int nwords = num_bits /32 ; +int nwords = (num_bits +31 ) /32 ;int size;uint32_t *buf, *ptr;BIGNUM *tmp, *big2, *big32, *big2_32;tools/image-sig-host.c +1
-2@@ -84,7 +84,7 @@ struct crypto_algo crypto_algos[] = { .verify = ecdsa_verify, }, { - .name = "secp521r1", + .name = "ecdsa521", .key_len = ECDSA521_BYTES, .sign = ecdsa_sign, .add_verify_data = ecdsa_add_verify_data, --2.43.0
RFC PATCH v2 6/9 test: dm: ecdsa.c: clean this test as software ecdsa is now implemented
In reply to Philippe ReynesThe test ecdsa was done when ecdsa was only supported by hardware. So it wasn't possible to test ecdsa on sandbox, and there is a test to check that ecdsa is not supported on sandbox.
Now, there is a software implementation of ecdsa. So we remove this outdated test.
---
v2:
- initial version
test/dm/ecdsa.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
test/dm/ecdsa.c +2 -16
@@ -9,29 +9,15 @@/* * Basic test of the ECDSA uclass and ecdsa_verify() * -* ECDSA implementations in u-boot are hardware-dependent. Until we have a -* software implementation that can be compiled into the sandbox, all we can -* test is the uclass support. -* -* The uclass_get() test is redundant since ecdsa_verify() would also fail. We -* run both functions in order to isolate the cause more clearly. i.e. is -* ecdsa_verify() failing because the UCLASS is absent/broken? +* ECDSA software implementation is tested in another test, +* so we only check that the class UCLASS_ECDSA may be reached. */ static int dm_test_ecdsa_verify (struct unit_test_state *uts) {struct uclass *ucp; -struct checksum_algo algo = { - .checksum_len =256 , - }; - -struct image_sign_info info = { - .checksum = &algo, - }; -ut_assertok (uclass_get (UCLASS_ECDSA , &ucp));ut_assertnonnull (ucp); -ut_asserteq (-ENODEV ,ecdsa_verify (&info,NULL ,0 ,NULL ,0 ));return 0 ; }
Signature · 1 line
2.43.0
RFC PATCH v2 7/9 configs: sandbox: enable the software ecdsa driver
In reply to Philippe ReynesThis commit enables the software ecdsa driver so
ecdsa may by used to check fit signature.
---
v2:
- initial version
configs/sandbox_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/sandbox_defconfig +1 -0
@@ -398,3 +398,4 @@ CONFIG_UTHREAD=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_ECDSA_SW=y
Signature · 1 line
2.43.0
Re: [RFC PATCH v2 7/9] configs: sandbox: enable the software ecdsa driver
Quoted 4 lines · Philippe Reynes
This commit enables the software ecdsa driver so
ecdsa may by used to check fit signature.
Quoted 8 lines
Signed-off-by Philippe Reynes <[email protected]>---
v2:
- initial versionconfigs/sandbox_defconfig | 1 + 1 file changed, 1 insertion(+)
Sometimes we just use 'default y if SANDBOX' on the Kconfig
RFC PATCH v2 8/9 test: py: vboot: prepare integration test for ecdsa
In reply to Philippe ReynesThe vboot tests only consider rsa algo for signature. To prepare the integration of ecdsa test, the signature algo is now explicit.
---
v2:
- initial version
test/py/tests/test_fit_ecdsa.py | 2 +-
test/py/tests/test_vboot.py | 99 ++++++++++---------
....its => sign-configs-sha1-rsa2048-pss.its} | 0
...sha1.its => sign-configs-sha1-rsa2048.its} | 0
... sign-configs-sha256-rsa2048-pss-prod.its} | 0
...ts => sign-configs-sha256-rsa2048-pss.its} | 0
...56.its => sign-configs-sha256-rsa2048.its} | 0
...84.its => sign-configs-sha384-rsa3072.its} | 0
...s.its => sign-images-sha1-rsa2048-pss.its} | 0
...-sha1.its => sign-images-sha1-rsa2048.its} | 0
...its => sign-images-sha256-rsa2048-pss.its} | 0
...256.its => sign-images-sha256-rsa2048.its} | 0
...384.its => sign-images-sha384-rsa3072.its} | 0
13 files changed, 51 insertions(+), 50 deletions(-)
rename test/py/tests/vboot/{sign-configs-sha1-pss.its => sign-configs-sha1-rsa2048-pss.its} (100%)
rename test/py/tests/vboot/{sign-configs-sha1.its => sign-configs-sha1-rsa2048.its} (100%)
rename test/py/tests/vboot/{sign-configs-sha256-pss-prod.its => sign-configs-sha256-rsa2048-pss-prod.its} (100%)
rename test/py/tests/vboot/{sign-configs-sha256-pss.its => sign-configs-sha256-rsa2048-pss.its} (100%)
rename test/py/tests/vboot/{sign-configs-sha256.its => sign-configs-sha256-rsa2048.its} (100%)
rename test/py/tests/vboot/{sign-configs-sha384.its => sign-configs-sha384-rsa3072.its} (100%)
rename test/py/tests/vboot/{sign-images-sha1-pss.its => sign-images-sha1-rsa2048-pss.its} (100%)
rename test/py/tests/vboot/{sign-images-sha1.its => sign-images-sha1-rsa2048.its} (100%)
rename test/py/tests/vboot/{sign-images-sha256-pss.its => sign-images-sha256-rsa2048-pss.its} (100%)
rename test/py/tests/vboot/{sign-images-sha256.its => sign-images-sha256-rsa2048.its} (100%)
rename test/py/tests/vboot/{sign-images-sha384.its => sign-images-sha384-rsa3072.its} (100%)test/py/tests/test_fit_ecdsa.py +1 -1
@@ -102,7 +102,7 @@ def test_fit_ecdsa(ubman): with open(key_file, 'w') as f: f.write(key.export_key(format='PEM')) - assemble_fit_image(fit_file, f'{datadir}/sign-images-sha256.its', tempdir) + assemble_fit_image(fit_file, f'{datadir}/sign-images-sha256-rsa2048.its', tempdir) fit = SignableFitImage(ubman, fit_file) nodes = fit.find_signable_image_nodes()
test/py/tests/test_vboot.py +50 -49
198 lines not on this page · raw message
test/py/tests/vboot/sign-configs-sha1-rsa2048-pss.its renamed from test/py/tests/vboot/sign-configs-sha1-pss.its +0 -0
test/py/tests/vboot/sign-configs-sha1-rsa2048.its renamed from test/py/tests/vboot/sign-configs-sha1.its +0 -0
test/py/tests/vboot/sign-configs-sha256-rsa2048-pss-prod.its renamed from test/py/tests/vboot/sign-configs-sha256-pss-prod.its +0 -0
test/py/tests/vboot/sign-configs-sha256-rsa2048-pss.its renamed from test/py/tests/vboot/sign-configs-sha256-pss.its +0 -0
test/py/tests/vboot/sign-configs-sha256-rsa2048.its renamed from test/py/tests/vboot/sign-configs-sha256.its +0 -0
test/py/tests/vboot/sign-configs-sha384-rsa3072.its renamed from test/py/tests/vboot/sign-configs-sha384.its +0 -0
test/py/tests/vboot/sign-images-sha1-rsa2048-pss.its renamed from test/py/tests/vboot/sign-images-sha1-pss.its +0 -0
test/py/tests/vboot/sign-images-sha1-rsa2048.its renamed from test/py/tests/vboot/sign-images-sha1.its +0 -0
test/py/tests/vboot/sign-images-sha256-rsa2048-pss.its renamed from test/py/tests/vboot/sign-images-sha256-pss.its +0 -0
test/py/tests/vboot/sign-images-sha256-rsa2048.its renamed from test/py/tests/vboot/sign-images-sha256.its +0 -0
test/py/tests/vboot/sign-images-sha384-rsa3072.its renamed from test/py/tests/vboot/sign-images-sha384.its +0 -0
Signature · 1 line
2.43.0
Re: [RFC PATCH v2 8/9] test: py: vboot: prepare integration test for ecdsa
Quoted 27 lines · Philippe Reynes
The vboot tests only consider rsa algo for signature. To prepare the integration of ecdsa test, the signature algo is now explicit.
Signed-off-by Philippe Reynes <[email protected]>---
v2:
- initial versiontest/py/tests/test_fit_ecdsa.py | 2 +- test/py/tests/test_vboot.py | 99 ++++++++++--------- ....its => sign-configs-sha1-rsa2048-pss.its} | 0 ...sha1.its => sign-configs-sha1-rsa2048.its} | 0 ... sign-configs-sha256-rsa2048-pss-prod.its} | 0 ...ts => sign-configs-sha256-rsa2048-pss.its} | 0 ...56.its => sign-configs-sha256-rsa2048.its} | 0 ...84.its => sign-configs-sha384-rsa3072.its} | 0 ...s.its => sign-images-sha1-rsa2048-pss.its} | 0 ...-sha1.its => sign-images-sha1-rsa2048.its} | 0 ...its => sign-images-sha256-rsa2048-pss.its} | 0 ...256.its => sign-images-sha256-rsa2048.its} | 0 ...384.its => sign-images-sha384-rsa3072.its} | 0 13 files changed, 51 insertions(+), 50 deletions(-) rename test/py/tests/vboot/{sign-configs-sha1-pss.its => sign-configs-sha1-rsa2048-pss.its} (100%) rename test/py/tests/vboot/{sign-configs-sha1.its => sign-configs-sha1-rsa2048.its} (100%) rename test/py/tests/vboot/{sign-configs-sha256-pss-prod.its => sign-configs-sha256-rsa2048-pss-prod.its} (100%)
Quoted 9 lines
rename test/py/tests/vboot/{sign-configs-sha256-pss.its => sign-configs-sha256-rsa2048-pss.its} (100%)
rename test/py/tests/vboot/{sign-configs-sha256.its => sign-configs-sha256-rsa2048.its} (100%)
rename test/py/tests/vboot/{sign-configs-sha384.its => sign-configs-sha384-rsa3072.its} (100%)
rename test/py/tests/vboot/{sign-images-sha1-pss.its => sign-images-sha1-rsa2048-pss.its} (100%)
rename test/py/tests/vboot/{sign-images-sha1.its => sign-images-sha1-rsa2048.its} (100%)
rename test/py/tests/vboot/{sign-images-sha256-pss.its => sign-images-sha256-rsa2048-pss.its} (100%)
rename test/py/tests/vboot/{sign-images-sha256.its => sign-images-sha256-rsa2048.its} (100%)
rename test/py/tests/vboot/{sign-images-sha384.its => sign-images-sha384-rsa3072.its} (100%)RFC PATCH v2 9/9 test: vboot: add test for ecdsa
In reply to Philippe ReynesThis commit adds test case for ecdsa on fit, but not (yet) for the global image signature (preload).
---
v2:
- initial version
test/py/tests/test_vboot.py | 29 ++++++++++++ .../vboot/sign-configs-sha256-ecdsa256.its | 45 +++++++++++++++++++ .../vboot/sign-configs-sha256-ecdsa384.its | 45 +++++++++++++++++++ .../vboot/sign-configs-sha256-ecdsa521.its | 45 +++++++++++++++++++ .../vboot/sign-images-sha256-ecdsa256.its | 42 +++++++++++++++++ .../vboot/sign-images-sha256-ecdsa384.its | 42 +++++++++++++++++ .../vboot/sign-images-sha256-ecdsa521.its | 42 +++++++++++++++++ 7 files changed, 290 insertions(+) create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa256.its create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa384.its create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa521.its create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa256.its create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa384.its create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa521.its
test/py/tests/test_vboot.py +29 -0
@@ -94,6 +94,9 @@ TESTDATA_IN = [ ['sha256-pss-pad', 'sha256', '-rsa2048', '-pss', '-E -p 0x10000', False, False, False, False], ['sha256-pss-required', 'sha256', '-rsa2048', '-pss', None, True, False, False, False], ['sha256-pss-pad-required', 'sha256', '-rsa2048', '-pss', '-E -p 0x10000', True, True, False, False], + ['sha256-basic-ecdsa256', 'sha256', '-ecdsa256', '', None, False, False, False, False], + ['sha256-basic-ecdsa384', 'sha256', '-ecdsa384', '', None, False, False, False, False], + ['sha256-basic-ecdsa521', 'sha256', '-ecdsa521', '', None, False, False, False, False], ['sha384-basic', 'sha384', '-rsa3072', '', None, False, False, False, False], ['sha384-pad', 'sha384', '-rsa3072', '', '-E -p 0x10000', False, False, False, False], ['algo-arg', 'algo-arg', '', '', '-o sha256,rsa2048', False, False, True, False],
@@ -287,6 +290,29 @@ def test_vboot(ubman, name, sha_algo, sig_algo, padding, sign_options, required, utils.run_and_log(ubman, 'openssl req -batch -new -x509 -key %s%s.key ' '-out %s%s.crt' % (tmpdir, name, tmpdir, name)) + def create_ecdsa_pair(name): + """Generate a new ECDSA key pair + + Args: + name: Name of of the key (e.g. 'dev') + """ + + if sig_algo == "-ecdsa256": + curve_name = "secp256r1" + elif sig_algo == "-ecdsa384": + curve_name = "secp384r1" + elif sig_algo == "-ecdsa521": + curve_name = "secp521r1" + else: + curve_name = "unknownCurve" + + utils.run_and_log(ubman, 'openssl ecparam -name %s -genkey -noout -out %s%s.pem' % + (curve_name, tmpdir, name)) + + # Create a certificate containing the public key + utils.run_and_log(ubman, 'openssl req -batch -new -x509 -key %s%s.pem ' + '-out %s%s.crt' % (tmpdir, name, tmpdir, name)) + def test_with_algo(sha_algo, sig_algo, padding, sign_options): """Test verified boot with the given hash algorithm.
@@ -523,6 +549,9 @@ def test_vboot(ubman, name, sha_algo, sig_algo, padding, sign_options, required, if sig_algo == "-rsa2048" or sig_algo == "-rsa3072" or sig_algo == "": create_rsa_pair('dev') create_rsa_pair('prod') + elif sig_algo == "-ecdsa256" or sig_algo == "-ecdsa384" or sig_algo == "-ecdsa521": + create_ecdsa_pair('dev') + create_ecdsa_pair('prod') # Create a number kernel image with zeroes with open('%stest-kernel.bin' % tmpdir, 'wb') as fd:
test/py/tests/vboot/sign-configs-sha256-ecdsa256.its new file +45 -0
45 lines not on this page · raw message
test/py/tests/vboot/sign-configs-sha256-ecdsa384.its new file +45 -0
45 lines not on this page · raw message
test/py/tests/vboot/sign-configs-sha256-ecdsa521.its new file +45 -0
45 lines not on this page · raw message
test/py/tests/vboot/sign-images-sha256-ecdsa256.its new file +42 -0
42 lines not on this page · raw message
test/py/tests/vboot/sign-images-sha256-ecdsa384.its new file +42 -0
42 lines not on this page · raw message
test/py/tests/vboot/sign-images-sha256-ecdsa521.its new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [RFC PATCH v2 9/9] test: vboot: add test for ecdsa
Quoted 9 lines · Philippe Reynes
This commit adds test case for ecdsa on fit, but not (yet) for the global image signature (preload).
Signed-off-by Philippe Reynes <[email protected]>---
v2:
- initial version
Quoted 15 lines
test/py/tests/test_vboot.py | 29 ++++++++++++ .../vboot/sign-configs-sha256-ecdsa256.its | 45 +++++++++++++++++++ .../vboot/sign-configs-sha256-ecdsa384.its | 45 +++++++++++++++++++ .../vboot/sign-configs-sha256-ecdsa521.its | 45 +++++++++++++++++++ .../vboot/sign-images-sha256-ecdsa256.its | 42 +++++++++++++++++ .../vboot/sign-images-sha256-ecdsa384.its | 42 +++++++++++++++++ .../vboot/sign-images-sha256-ecdsa521.its | 42 +++++++++++++++++ 7 files changed, 290 insertions(+) create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa256.its create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa384.its create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa521.its create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa256.its create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa384.its create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa521.its
Nice!
Quoted 8 lines · Philippe Reynes
This serie adds the support of ecdsa with software using mbedtls. So boards without ecdsa hardware may also use signature with ecdsa.
To add the support of ecdsa with mbedtls, I have:
- enabled ecdsa in mbedtls
- add a functionsw_ecdsa_verifythat uses mbedtls
- add a driversw_ecdsathat callsw_ecdsa_verify
on top of 7dca54ef4c44c82bdc6716ac6cdc84c22c66e9ed (Feb 18).
I tested this in the same way as the initial series:
https://lists.denx.de/pipermail/u-boot/2026-February/610196.html
My crude patch for including bignum*.o has been made unnecessary in by the BIGNUM_MBEDTLS configuration option in patch 1/9.
Thank you!
Marko
Hi Philippe,
Quoted 10 lines · Philippe Reynes
This serie adds the support of ecdsa with software using mbedtls. So boards without ecdsa hardware may also use signature with ecdsa.
To add the support of ecdsa with mbedtls, I have:
- enabled ecdsa in mbedtls
- add a functionsw_ecdsa_verifythat uses mbedtls
- add a driversw_ecdsathat callsw_ecdsa_verify
Quoted 6 lines
I have tested this code with sandbox, and I have followed those steps:
0) build u-boot using
sandbox_defconfigand adding those options:CONFIG_ECDSA_SW=yCONFIG_ECDSA_MBEDTLS=y
As this series introduces a MbedTLS-only solution, duplicating a CONFIG_ECDSA_SW is not necessary, you can just use CONFIG_ECDSA_MBEDTLS when linking with ecdsa-sw.o.
Regards,
Raymond
Quoted 124 lines
CONFIG_ECDSA=yCONFIG_ECDSA_VERIFY=y1) add a signature node to an its file
signature-256 { algo = "sha256,ecdsa256"; key-name-hint = "private-key-256"; };2) generate an ecdsa key
openssl ecparam -name prime256v1 -genkey -noout -out private-key-256.pem3) create the itb file
./tools/mkimage-f <file.its> -k . -Karch/sandbox/dts/test.dtb<file.itb>4) launch sandbox u-boot
./u-boot -d
arch/sandbox/dts/test.dtb5) on sandbox u-boot prompt, load the itb and launch bootm on it
=> host load hostfs - 1000000 uboot-ecdsa.itb
4628674 bytes read in 1 ms (4.3 GiB/s)
=> bootm 1000000
...
...
Verifying Hash Integrity ... sha256,ecdsa256:private-key-256+ OKI have tested with success ecdsa256 and ecdsa384, but there is an issue with secp521r1.
Changes in v2:
- moveECDSA_MBEDTLStoMBEDTLS_LIB_X509
- renamelib/mbedtls/sw_ecdsa.ctolib/mbedtls/ecdsa.c
- enhance dependancies forECDSA_MBEDTLS
- fix support of ecdsa521/secp521r1
- add vboot test using ecdsaPhilippe Reynes (9):
mbedtls: enable support of ecc
ecdsa: initial support of ecdsa using mbedtls
test: lib:sw_ecdsa: add initial test
drivers: crypto: add software ecdsa support
ecdsa: fix support of secp521r1
test: dm:ecdsa.c: clean this test as software ecdsa is now
implemented
configs: sandbox: enable the software ecdsa driver
test: py: vboot: prepare integration test for ecdsa
test: vboot: add test for ecdsaconfigs/amd_versal2_virt_defconfig | 1 + configs/qemu_arm64_lwip_defconfig | 1 + configs/sandbox_defconfig | 1 + configs/starfive_visionfive2_defconfig | 1 + configs/xilinx_versal_net_virt_defconfig | 1 + configs/xilinx_versal_virt_defconfig | 1 + configs/xilinx_zynqmp_kria_defconfig | 1 + configs/xilinx_zynqmp_virt_defconfig | 1 + drivers/crypto/Kconfig | 2 + drivers/crypto/Makefile | 1 + drivers/crypto/ecdsa/Kconfig | 6 + drivers/crypto/ecdsa/Makefile | 6 + drivers/crypto/ecdsa/ecdsa-sw.c | 33 ++ include/crypto/internal/sw_ecdsa.h | 14 + lib/ecdsa/ecdsa-libcrypto.c | 21 +- lib/ecdsa/ecdsa-verify.c | 24 +- lib/fdt-libcrypto.c | 2 +- lib/mbedtls/Kconfig | 16 + lib/mbedtls/Makefile | 19 +- lib/mbedtls/ecdsa.c | 94 ++++ lib/mbedtls/mbedtls_def_config.h | 18 + test/dm/ecdsa.c | 18 +- test/lib/Makefile | 1 + test/lib/sw_ecdsa.c | 465 ++++++++++++++++++ test/py/tests/test_fit_ecdsa.py | 2 +- test/py/tests/test_vboot.py | 128 +++-- ....its => sign-configs-sha1-rsa2048-pss.its} | 0 ...sha1.its => sign-configs-sha1-rsa2048.its} | 0 .../vboot/sign-configs-sha256-ecdsa256.its | 45 ++ .../vboot/sign-configs-sha256-ecdsa384.its | 45 ++ .../vboot/sign-configs-sha256-ecdsa521.its | 45 ++ ... sign-configs-sha256-rsa2048-pss-prod.its} | 0 ...ts => sign-configs-sha256-rsa2048-pss.its} | 0 ...56.its => sign-configs-sha256-rsa2048.its} | 0 ...84.its => sign-configs-sha384-rsa3072.its} | 0 ...s.its => sign-images-sha1-rsa2048-pss.its} | 0 ...-sha1.its => sign-images-sha1-rsa2048.its} | 0 .../vboot/sign-images-sha256-ecdsa256.its | 42 ++ .../vboot/sign-images-sha256-ecdsa384.its | 42 ++ .../vboot/sign-images-sha256-ecdsa521.its | 42 ++ ...its => sign-images-sha256-rsa2048-pss.its} | 0 ...256.its => sign-images-sha256-rsa2048.its} | 0 ...384.its => sign-images-sha384-rsa3072.its} | 0 tools/image-sig-host.c | 2 +- 44 files changed, 1062 insertions(+), 79 deletions(-) create mode 100644 drivers/crypto/ecdsa/Kconfig create mode 100644 drivers/crypto/ecdsa/Makefile create mode 100644 drivers/crypto/ecdsa/ecdsa-sw.c create mode 100644 include/crypto/internal/sw_ecdsa.h create mode 100644 lib/mbedtls/ecdsa.c create mode 100644 test/lib/sw_ecdsa.c rename test/py/tests/vboot/{sign-configs-sha1-pss.its => sign-configs-sha1-rsa2048-pss.its} (100%) rename test/py/tests/vboot/{sign-configs-sha1.its => sign-configs-sha1-rsa2048.its} (100%) create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa256.its create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa384.its create mode 100644 test/py/tests/vboot/sign-configs-sha256-ecdsa521.its rename test/py/tests/vboot/{sign-configs-sha256-pss-prod.its => sign-configs-sha256-rsa2048-pss-prod.its} (100%) rename test/py/tests/vboot/{sign-configs-sha256-pss.its => sign-configs-sha256-rsa2048-pss.its} (100%) rename test/py/tests/vboot/{sign-configs-sha256.its => sign-configs-sha256-rsa2048.its} (100%) rename test/py/tests/vboot/{sign-configs-sha384.its => sign-configs-sha384-rsa3072.its} (100%) rename test/py/tests/vboot/{sign-images-sha1-pss.its => sign-images-sha1-rsa2048-pss.its} (100%) rename test/py/tests/vboot/{sign-images-sha1.its => sign-images-sha1-rsa2048.its} (100%) create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa256.its create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa384.its create mode 100644 test/py/tests/vboot/sign-images-sha256-ecdsa521.its rename test/py/tests/vboot/{sign-images-sha256-pss.its => sign-images-sha256-rsa2048-pss.its} (100%) rename test/py/tests/vboot/{sign-images-sha256.its => sign-images-sha256-rsa2048.its} (100%) rename test/py/tests/vboot/{sign-images-sha384.its => sign-images-sha384-rsa3072.its} (100%)--
2.43.0
Quoted 17 lines · Raymond Mao
Hi Philippe,
Quoted 13 lines · Philippe Reynes
This serie adds the support of ecdsa with software using mbedtls. So boards without ecdsa hardware may also use signature with ecdsa.
To add the support of ecdsa with mbedtls, I have:
- enabled ecdsa in mbedtls
- add a functionsw_ecdsa_verifythat uses mbedtls
- add a driversw_ecdsathat callsw_ecdsa_verifyI have tested this code with sandbox, and I have
followed those steps:
Quoted 7 lines
Quoted 3 lines
0) build u-boot using
sandbox_defconfigand adding those options:CONFIG_ECDSA_SW=yCONFIG_ECDSA_MBEDTLS=yAs this series introduces a MbedTLS-only solution, duplicating a
CONFIG_ECDSA_SWis not necessary, you can just useCONFIG_ECDSA_MBEDTLSwhen linking with ecdsa-sw.o.
And for the next RFC can we see this enabled in sandbox, and then the tests being able to be run in CI? Thanks!
Signature · 1 line
Tom