diff --git a/arch.mk b/arch.mk index 43f55caa..abca961a 100644 --- a/arch.mk +++ b/arch.mk @@ -1111,10 +1111,25 @@ ifeq ($(ARCH),RISCV64) ifneq ($(NO_ASM),1) CFLAGS+=-DWOLFSSL_RISCV_ASM - WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha256.o \ - $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha512.o \ - $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha3.o \ - $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-aes.o + # wolfSSL moved this port to wolfcrypt/src/port/riscv64/ and split each + # primitive into a generated -asm.S plus a -asm_c.c. Only one + # is live: the .S builds unless WOLFSSL_RISCV_ASM_INLINE is defined, which + # wolfBoot does not define, and the _asm_c.c compiles to an empty + # translation unit in that case. Pick whichever layout the pinned + # submodule actually has so this builds against wolfSSL before and after + # the move. + RISCV_ASM_DIR := $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv64 + ifneq ($(wildcard $(RISCV_ASM_DIR)/riscv-64-sha256-asm.S),) + WOLFCRYPT_OBJS+=$(RISCV_ASM_DIR)/riscv-64-sha256-asm.o \ + $(RISCV_ASM_DIR)/riscv-64-sha512-asm.o \ + $(RISCV_ASM_DIR)/riscv-64-sha3-asm.o \ + $(RISCV_ASM_DIR)/riscv-64-aes-asm.o + else + WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha256.o \ + $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha512.o \ + $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha3.o \ + $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-aes.o + endif endif endif diff --git a/include/user_settings.h b/include/user_settings.h index 28e98c07..5b329f58 100644 --- a/include/user_settings.h +++ b/include/user_settings.h @@ -122,12 +122,18 @@ #define CTYPE_USER /* don't let wolfCrypt types.h include ctype.h */ #ifndef WOLFSSL_ARMASM +/* Not when preprocessing a .S: this header is pulled into wolfSSL's generated + * assembly (riscv64 and others) via libwolfssl_sources_asm.h, and a C + * declaration reaching the assembler is a syntax error. The macros below are + * harmless there; only the prototypes need hiding. */ +#ifndef __ASSEMBLER__ #ifndef toupper extern int toupper(int c); #endif #ifndef tolower extern int tolower(int c); #endif +#endif /* !__ASSEMBLER__ */ #define XTOUPPER(c) toupper((c)) #define XTOLOWER(c) tolower((c)) #endif diff --git a/lib/wolfssl b/lib/wolfssl index 5418d6cf..e71b086f 160000 --- a/lib/wolfssl +++ b/lib/wolfssl @@ -1 +1 @@ -Subproject commit 5418d6cfdc4acd126983331a498ba2a8c70839c7 +Subproject commit e71b086fc83758ca05bf80f7896fa6d770a1787a diff --git a/tools/test.mk b/tools/test.mk index 4080c3f4..cbc82c3d 100644 --- a/tools/test.mk +++ b/tools/test.mk @@ -1228,43 +1228,49 @@ test-all: clean test-size-all: + # Several limits below are raised relative to upstream. This branch bumps + # lib/wolfssl to the ti_c25 merge for CHAR_BIT!=8 wide-byte support, which + # costs 4-48 bytes depending on configuration (most of it in the no-ASM + # SP-math and ML-DSA paths). No wolfBoot code changed in these builds, and + # each new value is the measured size, matching upstream's convention. + # Measured with the CI container (ghcr.io/wolfssl/wolfboot-ci-arm). make test-size SIGN=NONE LIMIT=5116 NO_ARM_ASM=1 make keysclean make test-size SIGN=ED25519 LIMIT=12228 NO_ARM_ASM=1 make keysclean make test-size SIGN=ECC256 LIMIT=18924 NO_ARM_ASM=1 make clean - make test-size SIGN=ECC256 NO_ASM=1 LIMIT=13956 NO_ARM_ASM=1 + make test-size SIGN=ECC256 NO_ASM=1 LIMIT=13968 NO_ARM_ASM=1 make keysclean - make test-size SIGN=RSA2048 LIMIT=11808 NO_ARM_ASM=1 + make test-size SIGN=RSA2048 LIMIT=11816 NO_ARM_ASM=1 make clean make test-size SIGN=RSA2048 NO_ASM=1 LIMIT=12372 NO_ARM_ASM=1 make keysclean - make test-size SIGN=RSA4096 LIMIT=12108 NO_ARM_ASM=1 + make test-size SIGN=RSA4096 LIMIT=12116 NO_ARM_ASM=1 make clean - make test-size SIGN=RSA4096 NO_ASM=1 LIMIT=12652 NO_ARM_ASM=1 + make test-size SIGN=RSA4096 NO_ASM=1 LIMIT=12660 NO_ARM_ASM=1 make keysclean make test-size SIGN=ECC384 LIMIT=19608 NO_ARM_ASM=1 make clean - make test-size SIGN=ECC384 NO_ASM=1 LIMIT=15316 NO_ARM_ASM=1 + make test-size SIGN=ECC384 NO_ASM=1 LIMIT=15328 NO_ARM_ASM=1 make keysclean make test-size SIGN=ED448 LIMIT=14256 NO_ARM_ASM=1 make keysclean - make test-size SIGN=RSA3072 LIMIT=11948 NO_ARM_ASM=1 + make test-size SIGN=RSA3072 LIMIT=11956 NO_ARM_ASM=1 make clean make test-size SIGN=RSA3072 NO_ASM=1 LIMIT=12480 NO_ARM_ASM=1 make keysclean - make test-size SIGN=RSAPSS2048 LIMIT=13744 NO_ARM_ASM=1 + make test-size SIGN=RSAPSS2048 LIMIT=13748 NO_ARM_ASM=1 make clean make test-size SIGN=RSAPSS2048 NO_ASM=1 LIMIT=14304 NO_ARM_ASM=1 make keysclean - make test-size SIGN=RSAPSS3072 LIMIT=13912 NO_ARM_ASM=1 + make test-size SIGN=RSAPSS3072 LIMIT=13916 NO_ARM_ASM=1 make clean make test-size SIGN=RSAPSS3072 NO_ASM=1 LIMIT=14436 NO_ARM_ASM=1 make keysclean - make test-size SIGN=RSAPSS4096 LIMIT=14084 NO_ARM_ASM=1 + make test-size SIGN=RSAPSS4096 LIMIT=14088 NO_ARM_ASM=1 make clean - make test-size SIGN=RSAPSS4096 NO_ASM=1 LIMIT=14624 NO_ARM_ASM=1 + make test-size SIGN=RSAPSS4096 NO_ASM=1 LIMIT=14628 NO_ARM_ASM=1 make keysclean make test-size SIGN=LMS LMS_LEVELS=2 LMS_HEIGHT=5 LMS_WINTERNITZ=8 \ WOLFBOOT_SMALL_STACK=0 IMAGE_SIGNATURE_SIZE=2644 \ @@ -1272,8 +1278,8 @@ test-size-all: make keysclean make test-size SIGN=XMSS XMSS_PARAMS='XMSS-SHA2_10_256' \ IMAGE_SIGNATURE_SIZE=2500 IMAGE_HEADER_SIZE?=4096 \ - LIMIT=8768 NO_ARM_ASM=1 + LIMIT=8772 NO_ARM_ASM=1 make keysclean make clean - make test-size SIGN=ML_DSA ML_DSA_LEVEL=2 LIMIT=19582 \ + make test-size SIGN=ML_DSA ML_DSA_LEVEL=2 LIMIT=19630 \ IMAGE_SIGNATURE_SIZE=2420 IMAGE_HEADER_SIZE?=8192