From ea5eb0c1d0906ac88faa5b230b337180d033a7d8 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Nihei Date: Thu, 19 Aug 2021 12:07:51 -0300 Subject: [PATCH] boot/mcuboot: Default to Tinycrypt as crypto backend Signed-off-by: Gustavo Henrique Nihei --- boot/mcuboot/Kconfig | 9 +++++++++ boot/mcuboot/Make.defs | 7 +++++++ boot/mcuboot/Makefile | 12 +++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/boot/mcuboot/Kconfig b/boot/mcuboot/Kconfig index 4a5f0c5f7..530e5dc31 100644 --- a/boot/mcuboot/Kconfig +++ b/boot/mcuboot/Kconfig @@ -22,6 +22,15 @@ config MCUBOOT_ENABLE_LOGGING ---help--- Enable MCUboot's logging infrastructure. +choice + prompt "Cryptographic backend" + default MCUBOOT_USE_TINYCRYPT + +config MCUBOOT_USE_TINYCRYPT + bool "TinyCrypt" + +endchoice # Cryptographic backend + config MCUBOOT_BOOTLOADER bool "MCUboot bootloader application" default n diff --git a/boot/mcuboot/Make.defs b/boot/mcuboot/Make.defs index 65a5af894..ea684ad19 100644 --- a/boot/mcuboot/Make.defs +++ b/boot/mcuboot/Make.defs @@ -31,4 +31,11 @@ CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/boot/mcuboot/mcuboo CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/boot/mcuboot/mcuboot/boot/bootutil/include} CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/boot/mcuboot/mcuboot/boot/bootutil/include} +# It allows import of MCUboot's crypto backend library headers. + +ifeq ($(CONFIG_MCUBOOT_USE_TINYCRYPT),y) +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/boot/mcuboot/mcuboot/ext/tinycrypt/lib/include/} +CXXFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/boot/mcuboot/mcuboot/ext/tinycrypt/lib/include/} +endif + endif diff --git a/boot/mcuboot/Makefile b/boot/mcuboot/Makefile index 40419a248..7e8005881 100644 --- a/boot/mcuboot/Makefile +++ b/boot/mcuboot/Makefile @@ -73,6 +73,16 @@ ifneq ($(CONFIG_MCUBOOT_WATCHDOG),) CSRCS += mcuboot/boot/nuttx/src/watchdog/watchdog.c endif +ifneq ($(CONFIG_MCUBOOT_USE_TINYCRYPT),) +CSRCS += mcuboot/ext/tinycrypt/lib/source/aes_encrypt.c \ + mcuboot/ext/tinycrypt/lib/source/aes_decrypt.c \ + mcuboot/ext/tinycrypt/lib/source/ctr_mode.c \ + mcuboot/ext/tinycrypt/lib/source/hmac.c \ + mcuboot/ext/tinycrypt/lib/source/ecc_dh.c \ + mcuboot/ext/tinycrypt/lib/source/sha256.c \ + mcuboot/ext/tinycrypt/lib/source/utils.c +endif + $(MCUBOOT_TARBALL): $(Q) echo "Downloading MCUboot-$(MCUBOOT_VERSION)" $(Q) curl -O -L https://github.com/mcu-tools/mcuboot/archive/$(MCUBOOT_TARBALL) @@ -89,4 +99,4 @@ distclean:: $(call DELFILE, $(MCUBOOT_TARBALL)) $(call DELDIR, $(MCUBOOT_UNPACK)) -include $(APPDIR)/Application.mk \ No newline at end of file +include $(APPDIR)/Application.mk