Skip to content

Commit aec2809

Browse files
dgarskedanielinux
authored andcommitted
Cleanups after hybrid signing PR.
1 parent b333317 commit aec2809

File tree

8 files changed

+43
-41
lines changed

8 files changed

+43
-41
lines changed

arch.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ ifeq ($(ARCH),x86_64)
5959
endif
6060
endif
6161

62-
## ARM
62+
## ARM Cortex-A
6363
ifeq ($(ARCH),AARCH64)
6464
CROSS_COMPILE?=aarch64-none-elf-
6565
CFLAGS+=-DARCH_AARCH64 -march=armv8-a
@@ -71,6 +71,7 @@ ifeq ($(ARCH),AARCH64)
7171
endif
7272
endif
7373

74+
## ARM Cortex-M
7475
ifeq ($(ARCH),ARM)
7576
CROSS_COMPILE?=arm-none-eabi-
7677
CFLAGS+=-DARCH_ARM

hal/raspi3.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,6 @@ void* hal_get_dts_update_address(void)
264264
return NULL; /* Not yet supported */
265265
}
266266

267-
/* QSPI functions */
268-
void qspi_init(uint32_t cpu_clock, uint32_t flash_freq)
269-
{
270-
}
271-
272-
void zynq_init(uint32_t cpu_clock)
273-
{
274-
}
275-
276267
#if defined(DISPLAY_CLOCKS)
277268
static uint32_t getclocks(uint8_t cid)
278269
{

include/image.h

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ int wolfBot_get_dts_size(void *dts_addr);
6666
# endif
6767
#endif
6868

69+
#ifndef UNUSEDFUNCTION
70+
# if defined(__GNUC__) || defined(__CC_ARM)
71+
# define UNUSEDFUNCTION __attribute__((unused))
72+
# else
73+
# define UNUSEDFUNCTION
74+
# endif
75+
#endif
76+
6977

7078
#ifndef WOLFBOOT_FLAGS_INVERT
7179
#define SECT_FLAG_NEW 0x0F
@@ -79,32 +87,32 @@ int wolfBot_get_dts_size(void *dts_addr);
7987
#define SECT_FLAG_UPDATED 0x0f
8088
#endif
8189

82-
#ifdef WOLFBOOT_SIGN_PRIMARY_ED25519
90+
#ifdef WOLFBOOT_SIGN_ED25519
8391
#define wolfBoot_verify_signature_primary wolfBoot_verify_signature_ed25519
8492
#endif
85-
#ifdef WOLFBOOT_SIGN_PRIMARY_ED448
93+
#ifdef WOLFBOOT_SIGN_ED448
8694
#define wolfBoot_verify_signature_primary wolfBoot_verify_signature_ed448
8795
#endif
88-
#if defined (WOLFBOOT_SIGN_PRIMARY_RSA2048) || \
89-
defined (WOLFBOOT_SIGN_PRIMARY_RSA3072) || \
90-
defined (WOLFBOOT_SIGN_PRIMARY_RSA4096) || \
91-
defined (WOLFBOOT_SIGN_PRIMARY_RSA2048ENC) || \
92-
defined (WOLFBOOT_SIGN_PRIMARY_RSA3072ENC) || \
93-
defined (WOLFBOOT_SIGN_PRIMARY_RSA4096ENC)
96+
#if defined (WOLFBOOT_SIGN_RSA2048) || \
97+
defined (WOLFBOOT_SIGN_RSA3072) || \
98+
defined (WOLFBOOT_SIGN_RSA4096) || \
99+
defined (WOLFBOOT_SIGN_RSA2048ENC) || \
100+
defined (WOLFBOOT_SIGN_RSA3072ENC) || \
101+
defined (WOLFBOOT_SIGN_RSA4096ENC)
94102
#define wolfBoot_verify_signature_primary wolfBoot_verify_signature_rsa
95103
#endif
96-
#if defined (WOLFBOOT_SIGN_PRIMARY_ECC256) || \
97-
defined (WOLFBOOT_SIGN_PRIMARY_ECC384) || \
98-
defined (WOLFBOOT_SIGN_PRIMARY_ECC521)
104+
#if defined (WOLFBOOT_SIGN_ECC256) || \
105+
defined (WOLFBOOT_SIGN_ECC384) || \
106+
defined (WOLFBOOT_SIGN_ECC521)
99107
#define wolfBoot_verify_signature_primary wolfBoot_verify_signature_ecc
100108
#endif
101-
#if defined(WOLFBOOT_SIGN_PRIMARY_LMS) || defined(WOLFBOOT_SIGN_PRIMARY_ext_LMS)
109+
#if defined(WOLFBOOT_SIGN_LMS) || defined(WOLFBOOT_SIGN_ext_LMS)
102110
#define wolfBoot_verify_signature_primary wolfBoot_verify_signature_lms
103111
#endif
104-
#if defined(WOLFBOOT_SIGN_PRIMARY_XMSS ) || defined(WOLFBOOT_SIGN_PRIMARY_ext_XMSS)
112+
#if defined(WOLFBOOT_SIGN_XMSS ) || defined(WOLFBOOT_SIGN_ext_XMSS)
105113
#define wolfBoot_verify_signature_primary wolfBoot_verify_signature_xmss
106114
#endif
107-
#ifdef WOLFBOOT_SIGN_PRIMARY_ML_DSA
115+
#ifdef WOLFBOOT_SIGN_ML_DSA
108116
#define wolfBoot_verify_signature_primary wolfBoot_verify_signature_ml_dsa
109117
#endif
110118

@@ -598,12 +606,15 @@ struct wolfBoot_image {
598606
uint8_t not_ext : 1; /* image is no longer external */
599607
};
600608

609+
601610
/* do not warn if this is not used */
602-
static void wolfBoot_image_confirm_signature_ok(struct wolfBoot_image *img)
611+
static void UNUSEDFUNCTION wolfBoot_image_confirm_signature_ok(
612+
struct wolfBoot_image *img)
603613
{
604614
img->signature_ok = 1;
605615
}
606-
static void wolfBoot_image_clear_signature_ok(struct wolfBoot_image *img)
616+
static void UNUSEDFUNCTION wolfBoot_image_clear_signature_ok(
617+
struct wolfBoot_image *img)
607618
{
608619
img->signature_ok = 0;
609620
}

options.mk

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ ifeq ($(SIGN),ML_DSA)
478478
ifneq ($(HASH),SHA3)
479479
WOLFCRYPT_OBJS+=./lib/wolfssl/wolfcrypt/src/sha3.o
480480
endif
481-
481+
482482
ifeq ($(WOLFBOOT_SMALL_STACK),1)
483483
$(error WOLFBOOT_SMALL_STACK with ML-DSA not supported yet)
484484
else
@@ -540,8 +540,6 @@ ifneq ($(SIGN_SECONDARY),)
540540
endif
541541

542542

543-
CFLAGS+=-DWOLFBOOT_SIGN_PRIMARY_$(SIGN)
544-
545543
ifeq ($(RAM_CODE),1)
546544
CFLAGS+= -D"RAM_CODE"
547545
endif

src/image.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,7 @@ int wolfBoot_verify_authenticity(struct wolfBoot_image *img)
12601260
*
12611261
*/
12621262
wolfBoot_verify_signature_primary(key_slot, img, stored_signature);
1263+
(void)stored_signature_size;
12631264
if (img->signature_ok == 1)
12641265
#ifdef SIGN_HYBRID
12651266
{

src/update_ram.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ extern int wolfBoot_get_dts_size(void *dts_addr);
3939
extern uint32_t kernel_load_addr;
4040
extern uint32_t dts_load_addr;
4141

42-
#if (defined(EXT_FLASH) && defined(NO_XIP)) || \
43-
(defined(EXT_ENCRYPTED) && defined(MMU)) && \
42+
#if ((defined(EXT_FLASH) && defined(NO_XIP)) || \
43+
(defined(EXT_ENCRYPTED) && defined(MMU))) && \
4444
!defined(WOLFBOOT_NO_RAMBOOT)
4545
/* Load firmware to RAM on boot (single flash read) */
4646
#undef WOLFBOOT_USE_RAMBOOT

tools/keytools/sign.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ static int load_key_rsa(int sign_type, uint32_t rsa_keysz, uint32_t rsa_pubkeysz
490490
CMD.sign = sign_type;
491491
CMD.signature_sz = keySzOut;
492492
}
493-
printf("Found RSA%d key\n", keySzOut);
493+
printf("Found RSA%d key\n", keySzOut*8);
494494
}
495495
}
496496
return ret;

tools/unit-tests/unit-image.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#define ENCRYPT_KEY "123456789abcdef0123456789abcdef0123456789abcdef"
4545
#define KEYSTORE_PUBKEY_SIZE KEYSTORE_PUBKEY_SIZE_ECC256
46-
#define WOLFBOOT_SIGN_PRIMARY_ECC256
46+
#define WOLFBOOT_SIGN_ECC256
4747

4848
#include <stdio.h>
4949
#include <check.h>
@@ -267,7 +267,7 @@ int wc_ecc_import_unsigned(ecc_key* key, const byte* qx, const byte* qy,
267267
{
268268
if (ecc_import_fail)
269269
return -1;
270-
270+
271271
key->type = ECC_PUBLICKEY;
272272
return 0;
273273
}
@@ -285,7 +285,7 @@ START_TEST(test_verify_signature)
285285
{
286286
uint8_t pubkey[32];
287287
struct wolfBoot_image test_img;
288-
288+
289289
test_img.part = PART_UPDATE;
290290
test_img.fw_size = test_img_len;
291291
test_img.fw_base = 0;
@@ -455,15 +455,15 @@ START_TEST(test_verify_authenticity)
455455
find_header_mocked = 1;
456456
ret = wolfBoot_verify_authenticity(&test_img);
457457
ck_assert_int_eq(ret, -1);
458-
458+
459459
/* Wrong pubkey */
460460
find_header_mocked = 0;
461461
hdr_cpy_done = 0;
462462
ext_flash_write(0, test_img_v200000000_wrong_pubkey_bin,
463463
test_img_len);
464464
ret = wolfBoot_verify_authenticity(&test_img);
465465
ck_assert_int_lt(ret, 0);
466-
466+
467467
/* Wrong signature */
468468
find_header_mocked = 0;
469469
find_header_fail = 0;
@@ -539,7 +539,7 @@ START_TEST(test_open_image)
539539
ck_assert_ptr_eq(img.hdr, (void *)WOLFBOOT_PARTITION_SWAP_ADDRESS);
540540
ck_assert_ptr_eq(img.hdr, img.fw_base);
541541
ck_assert_uint_eq(img.fw_size, WOLFBOOT_SECTOR_SIZE);
542-
542+
543543
/* Valid image */
544544
hdr_cpy_done = 0;
545545
ext_flash_write(0, test_img_v200000000_signed_bin,
@@ -574,17 +574,17 @@ Suite *wolfboot_suite(void)
574574
tcase_set_timeout(tcase_headers, 20);
575575
tcase_add_test(tcase_headers, test_headers);
576576
suite_add_tcase(s, tcase_headers);
577-
577+
578578
TCase* tcase_verify_authenticity = tcase_create("verify_authenticity");
579579
tcase_set_timeout(tcase_verify_authenticity, 20);
580580
tcase_add_test(tcase_verify_authenticity, test_verify_authenticity);
581581
suite_add_tcase(s, tcase_verify_authenticity);
582-
582+
583583
TCase* tcase_verify_integrity = tcase_create("verify_integrity");
584584
tcase_set_timeout(tcase_verify_integrity, 20);
585585
tcase_add_test(tcase_verify_integrity, test_verify_integrity);
586586
suite_add_tcase(s, tcase_verify_integrity);
587-
587+
588588
TCase* tcase_open_image = tcase_create("open_image");
589589
tcase_set_timeout(tcase_open_image, 20);
590590
tcase_add_test(tcase_open_image, test_open_image);

0 commit comments

Comments
 (0)