Add a software ecdsa driver so it is now possible to use ecdsa signature on board without ecdsa hardware support.
Reviewed-by: Raymond Mao <[email protected]> Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Philippe Reynes <[email protected]> --- v2: - no change v3: - add depends on ECDSA_VERIFY to ECDSA_SW - change sw_ecdsa_verify to ecdsa_hash_verify - v4 - use ECDSA_MBEDTLS to build the driver - clean include (change order) v5: - use $(PHASE_) in the Makefile for the driver v6: - remove include u-boot/ecdsa.h from ecdsa-sw.c v7: - no change drivers/crypto/Makefile | 1 + drivers/crypto/ecdsa/Makefile | 6 ++++++ drivers/crypto/ecdsa/ecdsa-sw.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 drivers/crypto/ecdsa/Makefile create mode 100644 drivers/crypto/ecdsa/ecdsa-sw.c diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile index e4a4482b7f3..8170e4cae9c 100644 --- a/drivers/crypto/Makefile +++ b/drivers/crypto/Makefile @@ -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/ diff --git a/drivers/crypto/ecdsa/Makefile b/drivers/crypto/ecdsa/Makefile new file mode 100644 index 00000000000..89be50824cb --- /dev/null +++ b/drivers/crypto/ecdsa/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2026 Philippe Reynes <[email protected]> +# + +obj-$(CONFIG_$(PHASE_)ECDSA_VERIFY_MBEDTLS) += ecdsa-sw.o diff --git a/drivers/crypto/ecdsa/ecdsa-sw.c b/drivers/crypto/ecdsa/ecdsa-sw.c new file mode 100644 index 00000000000..2af1405f73b --- /dev/null +++ b/drivers/crypto/ecdsa/ecdsa-sw.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2026 Philippe Reynes <[email protected]> + */ +#include <crypto/ecdsa-uclass.h> +#include <crypto/internal/ecdsa.h> +#include <dm.h> +#include <linux/types.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 ecdsa_hash_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

