From f62dc729eb495e370f312111cd158dff9d1fee02 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Tue, 7 Apr 2026 12:07:24 +0200 Subject: [PATCH 1/4] Updated submodules to latest --- lib/wolfPKCS11 | 2 +- lib/wolfPSA | 2 +- lib/wolfTPM | 2 +- lib/wolfssl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/wolfPKCS11 b/lib/wolfPKCS11 index a1c62599d2..8fec69592d 160000 --- a/lib/wolfPKCS11 +++ b/lib/wolfPKCS11 @@ -1 +1 @@ -Subproject commit a1c62599d24f40cbdb3e90bf4ef00023be3b4fe9 +Subproject commit 8fec69592d99bf4d8f01e36acd16f7d27b4639f4 diff --git a/lib/wolfPSA b/lib/wolfPSA index bb36f76632..f289a6f127 160000 --- a/lib/wolfPSA +++ b/lib/wolfPSA @@ -1 +1 @@ -Subproject commit bb36f766321230c516af1b50e3264ed290fe5955 +Subproject commit f289a6f12788237224f26635f8586b1f63c817e4 diff --git a/lib/wolfTPM b/lib/wolfTPM index d1756f96c2..efaab4afe6 160000 --- a/lib/wolfTPM +++ b/lib/wolfTPM @@ -1 +1 @@ -Subproject commit d1756f96c2da425b56cbfac164c7226fb8d00e52 +Subproject commit efaab4afe67fbe8616a08d46b721cb0cbd375894 diff --git a/lib/wolfssl b/lib/wolfssl index 63f6f0511b..b5874a6d9e 160000 --- a/lib/wolfssl +++ b/lib/wolfssl @@ -1 +1 @@ -Subproject commit 63f6f0511b76c78f4266d5bee3114506d890cfcc +Subproject commit b5874a6d9ef95bb6ddde416c720e1f195d0c1b43 From c710fe907855dbef49c352112b5ea7548180915f Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Tue, 7 Apr 2026 12:36:30 +0200 Subject: [PATCH 2/4] Fixed xmalloc pools for new wolfSSL ECC+SMALLSTACK --- src/xmalloc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/xmalloc.c b/src/xmalloc.c index 69962d6aec..fa9b235fd9 100644 --- a/src/xmalloc.c +++ b/src/xmalloc.c @@ -171,9 +171,10 @@ struct xmalloc_slot { #define MP_CURVE_FIELD_COUNT_SIZE (380) #ifndef _LP64 #define ECC_POINT_SIZE (232) + #define MP_INT_BUFFER_SIZE_1 (MP_INT_TYPE_SIZE * 6) #else #define ECC_POINT_SIZE (320) - #define MP_INT_BUFFER_SIZE_1 (MP_INT_TYPE_SIZE * 5) + #define MP_INT_BUFFER_SIZE_1 (MP_INT_TYPE_SIZE * 6) #endif #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) #define MP_DIGIT_BUFFER_MONT_SIZE (sizeof(fp_digit)*(FP_SIZE + 1)) @@ -186,8 +187,11 @@ struct xmalloc_slot { #define ECC_POINT_SIZE (412) #else #define ECC_POINT_SIZE (512) + #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) #endif + #ifndef MP_INT_BUFFER_SIZE #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 5) + #endif #define MP_INT_BUFFER_SIZE_1 (MP_INT_TYPE_SIZE * 6) #define MP_DIGIT_BUFFER_MONT_SIZE (sizeof(fp_digit)*(FP_SIZE + 1)) #endif @@ -199,8 +203,11 @@ struct xmalloc_slot { #define ECC_POINT_SIZE (520) #else #define ECC_POINT_SIZE (608) + #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) #endif + #ifndef MP_INT_BUFFER_SIZE #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 5) + #endif #define MP_INT_BUFFER_SIZE_1 (MP_INT_TYPE_SIZE * 6) #define MP_DIGIT_BUFFER_MONT_SIZE (sizeof(fp_digit)*(FP_SIZE + 1)) #endif From 201c2c5c7e033e0572ca039abb03c352bd0cdff5 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Tue, 7 Apr 2026 14:14:44 +0200 Subject: [PATCH 3/4] Adjust BIGINT limits for new wolfSSL ECC+SMALLSTACK --- Makefile | 2 ++ src/xmalloc.c | 2 ++ test-app/Makefile | 9 +++++++-- tools/keytools/Makefile | 13 +++++++------ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index a5a81c18b5..0acddd3252 100644 --- a/Makefile +++ b/Makefile @@ -261,6 +261,8 @@ ifeq ($(TARGET),raspi3) endif ifeq ($(TARGET),sim) + CFLAGS+=-fno-pie + LDFLAGS+=-no-pie MAIN_TARGET:=wolfboot.bin tools/bin-assemble/bin-assemble test-app/image_v1_signed.bin internal_flash.dd endif diff --git a/src/xmalloc.c b/src/xmalloc.c index fa9b235fd9..1cdbf08fc4 100644 --- a/src/xmalloc.c +++ b/src/xmalloc.c @@ -185,6 +185,7 @@ struct xmalloc_slot { #define MP_CURVE_FIELD_COUNT_SIZE (380) #ifndef _LP64 #define ECC_POINT_SIZE (412) + #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) #else #define ECC_POINT_SIZE (512) #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) @@ -201,6 +202,7 @@ struct xmalloc_slot { #define MP_CURVE_FIELD_COUNT_SIZE (380) #ifndef _LP64 #define ECC_POINT_SIZE (520) + #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) #else #define ECC_POINT_SIZE (608) #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) diff --git a/test-app/Makefile b/test-app/Makefile index 3a58795173..a2e54effa9 100644 --- a/test-app/Makefile +++ b/test-app/Makefile @@ -53,7 +53,10 @@ ifeq ($(HASH),SHA3_384) CFLAGS+=-D"WOLFBOOT_HASH_SHA3_384" endif - +STACK_USAGE_LIMIT:=1024 +ifeq ($(TARGET),sim) + STACK_USAGE_LIMIT:=4608 +endif ifeq ($(TARGET),ti_hercules) APP_OBJS:=app_$(TARGET).o ../test-app/libwolfboot.o @@ -63,7 +66,7 @@ else # Stack usage computation not supported on TriCore ifneq ($(ARCH),AURIX_TC3) ifneq ($(USE_CLANG),1) - CFLAGS+=-Wstack-usage=1024 + CFLAGS+=-Wstack-usage=$(STACK_USAGE_LIMIT) endif endif CFLAGS+=-DTARGET_$(TARGET) -I../include @@ -509,6 +512,8 @@ ifeq ($(TARGET),sim) # LD on MacOS does not support "-Map=" LDMAPSUPPORTED=$(shell $(CC) -Wl,-Map=image.map 2>&1 | grep 'unknown option') LDFLAGS= + CFLAGS+=-fno-pie + LDFLAGS+=-no-pie ifeq ($(FORCE_32BIT),1) LDFLAGS+=-m32 CFLAGS+=-m32 diff --git a/tools/keytools/Makefile b/tools/keytools/Makefile index a746beb914..7029295ba6 100644 --- a/tools/keytools/Makefile +++ b/tools/keytools/Makefile @@ -1,7 +1,5 @@ # wolfBoot KeyGen and Signing Tool --include ../../.config - V?=0 ifeq ($(V),0) Q=@ @@ -18,6 +16,7 @@ LD = gcc WOLFBOOTDIR = ../.. CFLAGS = -Wall -Wextra -Werror CFLAGS += -I. -DWOLFSSL_USER_SETTINGS -I$(WOLFBOOT_LIB_WOLFSSL) -I$(WOLFBOOTDIR)/include +DEPFLAGS = -MMD -MP LDFLAGS = OBJDIR = ./ LIBS = @@ -112,6 +111,7 @@ OBJS_REAL+=\ OBJS_REAL+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/dilithium.o OBJS_VIRT=$(addprefix $(OBJDIR), $(notdir $(OBJS_REAL))) +DEPS=$(OBJS_VIRT:.o=.d) sign.d keygen.d vpath %.c $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/ vpath %.c $(WOLFBOOTDIR)/src/ vpath %.c ./ @@ -125,11 +125,11 @@ debug: all # build objects $(OBJDIR)/%.o: %.c - $(Q)$(CC) $(CFLAGS) -c -o $@ $< + $(Q)$(CC) $(CFLAGS) $(DEPFLAGS) -c -o $@ $< $(OBJDIR)/%.o: $(WOLFBOOTDIR)/src/%.c - $(Q)$(CC) $(CFLAGS) -c -o $@ $< + $(Q)$(CC) $(CFLAGS) $(DEPFLAGS) -c -o $@ $< $(OBJDIR)/%.o: $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/%.c - $(Q)$(CC) $(CFLAGS) -c -o $@ $< + $(Q)$(CC) $(CFLAGS) $(DEPFLAGS) -c -o $@ $< # build templates sign: $(OBJS_VIRT) $(LIBS) sign.o @@ -141,5 +141,6 @@ keygen: $(OBJS_VIRT) $(LIBS) keygen.o $(Q)$(LD) -o $@ $@.o $(OBJS_VIRT) $(LIBS) $(LDFLAGS) clean: - rm -f sign keygen *.o + rm -f sign keygen *.o *.d +-include $(DEPS) From c03d251599072b396aadb649246c80f71da4d872 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Tue, 7 Apr 2026 15:02:21 +0200 Subject: [PATCH 4/4] Addressed copilot's comment --- src/xmalloc.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/xmalloc.c b/src/xmalloc.c index 1cdbf08fc4..a484ecd866 100644 --- a/src/xmalloc.c +++ b/src/xmalloc.c @@ -185,14 +185,10 @@ struct xmalloc_slot { #define MP_CURVE_FIELD_COUNT_SIZE (380) #ifndef _LP64 #define ECC_POINT_SIZE (412) - #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) #else #define ECC_POINT_SIZE (512) - #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) - #endif - #ifndef MP_INT_BUFFER_SIZE - #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 5) #endif + #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) #define MP_INT_BUFFER_SIZE_1 (MP_INT_TYPE_SIZE * 6) #define MP_DIGIT_BUFFER_MONT_SIZE (sizeof(fp_digit)*(FP_SIZE + 1)) #endif @@ -202,14 +198,10 @@ struct xmalloc_slot { #define MP_CURVE_FIELD_COUNT_SIZE (380) #ifndef _LP64 #define ECC_POINT_SIZE (520) - #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) #else #define ECC_POINT_SIZE (608) - #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) - #endif - #ifndef MP_INT_BUFFER_SIZE - #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 5) #endif + #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) #define MP_INT_BUFFER_SIZE_1 (MP_INT_TYPE_SIZE * 6) #define MP_DIGIT_BUFFER_MONT_SIZE (sizeof(fp_digit)*(FP_SIZE + 1)) #endif