From 59f1d29c0c357ef05d8729a0c33f4e854197c32a Mon Sep 17 00:00:00 2001 From: Sigvart Hovland Date: Wed, 28 Oct 2020 14:40:09 +0100 Subject: [PATCH] bootutil: ecdsa: Fix CC310 for nRF devices This contains fixes for CC310 for nRF devices using the nrfxlib. Removed some const for compilation warnings and added `NUM_ECC_BYTES` define. Signed-off-by: Sigvart Hovland --- boot/bootutil/include/bootutil/crypto/ecdsa_p256.h | 2 +- boot/bootutil/src/image_ec256.c | 3 +++ boot/zephyr/nrf52840dk_nrf52840_cc310_ecdsa.conf | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 boot/zephyr/nrf52840dk_nrf52840_cc310_ecdsa.conf diff --git a/boot/bootutil/include/bootutil/crypto/ecdsa_p256.h b/boot/bootutil/include/bootutil/crypto/ecdsa_p256.h index faa8ea39..b77cd347 100644 --- a/boot/bootutil/include/bootutil/crypto/ecdsa_p256.h +++ b/boot/bootutil/include/bootutil/crypto/ecdsa_p256.h @@ -69,7 +69,7 @@ static inline void bootutil_ecdsa_p256_drop(bootutil_ecdsa_p256_context *ctx) (void)ctx; } -static inline int bootutil_ecdsa_p256_verify(bootutil_ecdsa_p256_context *ctx, const uint8_t *pk, const uint8_t *hash, const uint8_t *sig) +static inline int bootutil_ecdsa_p256_verify(bootutil_ecdsa_p256_context *ctx, uint8_t *pk, uint8_t *hash, uint8_t *sig) { (void)ctx; return cc310_ecdsa_verify_secp256r1(hash, pk, sig, BOOTUTIL_CRYPTO_ECDSA_P256_HASH_SIZE); diff --git a/boot/bootutil/src/image_ec256.c b/boot/bootutil/src/image_ec256.c index 185624c7..f5b81359 100644 --- a/boot/bootutil/src/image_ec256.c +++ b/boot/bootutil/src/image_ec256.c @@ -30,6 +30,9 @@ #ifdef MCUBOOT_SIGN_EC256 /*TODO: remove this after cypress port mbedtls to abstract crypto api */ +#ifdef MCUBOOT_USE_CC310 +#define NUM_ECC_BYTES (256 / 8) +#endif #if defined (MCUBOOT_USE_TINYCRYPT) || defined (MCUBOOT_USE_CC310) #include "bootutil/sign_key.h" diff --git a/boot/zephyr/nrf52840dk_nrf52840_cc310_ecdsa.conf b/boot/zephyr/nrf52840dk_nrf52840_cc310_ecdsa.conf new file mode 100644 index 00000000..d1959653 --- /dev/null +++ b/boot/zephyr/nrf52840dk_nrf52840_cc310_ecdsa.conf @@ -0,0 +1,2 @@ +CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y +CONFIG_BOOT_ECDSA_CC310=y