aspeed: ast2700: Add Caliptra ECDSA driver
Subsystems (3)
v3 cover aspeed: ast2700: Add Caliptra ECDSA driver
Aspeed AST2700 SoCs integrates the Caliptra secure IP, where an ECDSA384 signature verification HW interface is exported for SoC crypto needs.
This patch series firstly extends the FIT image signing/verify common code to support the ECDSA384 algorithm. For better convenience, the device tree for ECDSA public key storage is also revised by referring to RSA implementations.
After the FIT common code revision, the driver is implemented for AST2700 to leverage the Caliptra ECDSA384 signature verification.
These are verified by signed FIT images with the algorithm "sha384,ecdsa384".
v3 change:
- rebase on master branch and drop "[PATCH v2 2/4] lib: ecdsa: Create device tree node automatically" due to the duplicate change.
v2 change:
- revise the commit message of padding check removal for better explanation
- remove redundant check in static function
- revise errno and error message as suggested by Simon
- collect Reviewed-by tags
Chia-Wei Wang (3):
lib: ecdsa: Add ECDSA384 support
image-fit-sig: Remove padding check drivers/crypto: aspeed: Add Caliptra ECDSA384 support
boot/image-fit-sig.c | 2 +- drivers/crypto/aspeed/Kconfig | 10 ++ drivers/crypto/aspeed/Makefile | 1 + drivers/crypto/aspeed/cptra_ecdsa.c | 184 ++++++++++++++++++++++++++++ include/u-boot/ecdsa.h | 1 + lib/ecdsa/ecdsa-verify.c | 14 ++- tools/image-sig-host.c | 7 ++ 7 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 drivers/crypto/aspeed/cptra_ecdsa.c
Signature · 1 line
2.25.1
PATCH v3 1/3 lib: ecdsa: Add ECDSA384 support
Add ECDSA384 algorithm support for image signing and verification.
--- include/u-boot/ecdsa.h | 1 + lib/ecdsa/ecdsa-verify.c | 14 +++++++++++--- tools/image-sig-host.c | 7 +++++++ 3 files changed, 19 insertions(+), 3 deletions(-)
include/u-boot/ecdsa.h +1 -0
@@ -65,6 +65,7 @@ int ecdsa_verify(struct image_sign_info *info,/** @} */ #define ECDSA256_BYTES (256 / 8) +#define ECDSA384_BYTES (384 / 8)#define ECDSA521_BYTES ((521 + 7) / 8)#endif
lib/ecdsa/ecdsa-verify.c +11 -3
@@ -22,8 +22,10 @@ static int ecdsa_key_size(const char *curve_name) {if (!strcmp (curve_name,"prime256v1" ))return 256 ; -else -return 0 ; +else if (!strcmp (curve_name,"secp384r1" )) +return 384 ; + +return 0 ; }static int fdt_get_key (struct ecdsa_public_key *key,const void *fdt,int node)
@@ -121,12 +123,18 @@ int ecdsa_verify(struct image_sign_info *info,return ecdsa_verify_hash (dev, info, hash, sig, sig_len); } -U_BOOT_CRYPTO_ALGO (ecdsa) = { +U_BOOT_CRYPTO_ALGO (ecdsa256) = { .name ="ecdsa256" , .key_len =ECDSA256_BYTES , .verify = ecdsa_verify, }; +U_BOOT_CRYPTO_ALGO (ecdsa384) = { + .name ="ecdsa384" , + .key_len =ECDSA384_BYTES , + .verify = ecdsa_verify, +}; +/* * uclass definition for ECDSA API *
tools/image-sig-host.c +7 -0
@@ -76,6 +76,13 @@ struct crypto_algo crypto_algos[] = { .add_verify_data = ecdsa_add_verify_data, .verify = ecdsa_verify, }, + { + .name = "ecdsa384", + .key_len = ECDSA384_BYTES, + .sign = ecdsa_sign, + .add_verify_data = ecdsa_add_verify_data, + .verify = ecdsa_verify, + }, { .name = "secp521r1", .key_len = ECDSA521_BYTES,
Signature · 1 line
2.25.1
PATCH v3 2/3 image-fit-sig: Remove padding check
In reply to Chia-Wei WangThe padding algorithm is not mandatory for all signing algorithm. For example, ECDSA does not require a padding method.
For RSA requiring PKCS padding, the belonging info->crypto(), assigned with rsa_verify_key(), also has the check on the validity of info->padding().
Thus, remove the info->padding check from the upper, general layer.
--- boot/image-fit-sig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
boot/image-fit-sig.c +1 -1
@@ -95,7 +95,7 @@ static int fit_image_setup_verify(struct image_sign_info *info, info->required_keynode = required_keynode;printf ("%s:%s" , algo_name, info->keyname); -if (!info->checksum || !info->crypto || !info->padding) { +if (!info->checksum || !info->crypto) { *err_msgp ="Unknown signature algorithm" ;return -1 ; }
Signature · 1 line
2.25.1
PATCH v3 3/3 drivers/crypto: aspeed: Add Caliptra ECDSA384 support
In reply to Chia-Wei WangAspeed AST27xx SoCs integrate the CPTRA 1.0 secure IP, which export an ECDSA384_SIGNATURE_VERIFY mailbox command service for SoC to use.
This patch is verified by the FIT signature verification using the "sha384,ecdsa384" algorithm.
--- drivers/crypto/aspeed/Kconfig | 10 ++ drivers/crypto/aspeed/Makefile | 1 + drivers/crypto/aspeed/cptra_ecdsa.c | 184 ++++++++++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 drivers/crypto/aspeed/cptra_ecdsa.c
drivers/crypto/aspeed/Kconfig +10 -0
@@ -28,3 +28,13 @@ config ASPEED_CPTRA_SHA Enabling this allows the use of SHA operations in hardware. Note that only SHA384 and SHA512 are supported by Caliptra 1.0. + +config ASPEED_CPTRA_ECDSA + bool "Caliptra ECDSA384 signature verifier for Aspeed SoCs" + depends on ECDSA_VERIFY || SPL_ECDSA_VERIFY + help + Select this option to enable a driver for using the ECDSA384_SIGNATURE_VERIFY + feature of Caliptra, which is integrated in AST27xx BMC SoCs. + + Enabling this allows the use of ECDSA384 signature verification in hardware. + Note that only ECDSA384 is supported by Caliptra.
drivers/crypto/aspeed/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-$(CONFIG_ASPEED_HACE) += aspeed_hace.o obj-$(CONFIG_ASPEED_ACRY) += aspeed_acry.o obj-$(CONFIG_ASPEED_CPTRA_SHA) += cptra_sha.o +obj-$(CONFIG_ASPEED_CPTRA_ECDSA) += cptra_ecdsa.o
drivers/crypto/aspeed/cptra_ecdsa.c new file +184 -0
184 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 9 lines · Chia-Wei Wang
Aspeed AST2700 SoCs integrates the Caliptra secure IP, where an ECDSA384 signature verification HW interface is exported for SoC crypto needs.
This patch series firstly extends the FIT image signing/verify common code to support the ECDSA384 algorithm. For better convenience, the device tree for ECDSA public key storage is also revised by referring to RSA implementations.
[...]
Applied to u-boot/master, thanks!
Signature · 1 line
Tom