Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for edge cases (Mac OS, library.o) #371

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/test-configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,42 @@ jobs:
config-file: ./config/examples/raspi3.config
make-args: wolfboot.bin CROSS_COMPILE=aarch64-linux-gnu-

sim_test:
sim_tfm_smallstack_test:
uses: ./.github/workflows/test-build.yml
with:
arch: host
config-file: ./config/examples/sim.config
make-args: WOLFBOOT_SMALL_STACK=1

sim_tfm_bigstack_test:
uses: ./.github/workflows/test-build.yml
with:
arch: host
config-file: ./config/examples/sim.config
make-args: WOLFBOOT_SMALL_STACK=0 WOLFBOOT_HUGE_STACK=1

sim_spmathall_smallstack_test:
uses: ./.github/workflows/test-build.yml
with:
arch: host
config-file: ./config/examples/sim.config
make-args: SPMATHALL=1 WOLFBOOT_SMALL_STACK=1

sim_spmathall_bigsack_test:
uses: ./.github/workflows/test-build.yml
with:
arch: host
config-file: ./config/examples/sim.config
make-args: SPMATHALL=1 WOLFBOOT_SMALL_STACK=0 WOLFBOOT_HUGE_STACK=1

sim_spmath_bigstack_test:
uses: ./.github/workflows/test-build.yml
with:
arch: host
config-file: ./config/examples/sim.config
make-args: SPMATH=1 WOLFBOOT_SMALL_STACK=0 WOLFBOOT_HUGE_STACK=1

# TODO: SP math with small stack has issues

stm32f4_small_blocks_uart_update_test:
uses: ./.github/workflows/test-build.yml
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-keytools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:

- name: Select config
run: |
cp config/examples/sim-ecc.config .config && make include/target.h
cp config/examples/sim.config .config && make include/target.h

- name: Build tools
run: |
make -C tools/keytools && make -C tools/bin-assemble

- name: Build wolfboot
run: |
make ${{inputs.make-args}}
make SIGN=ECC256 HASH=SHA256

- name: Generate external key
run: |
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:

- name: Build wolfboot
run: |
make ${{inputs.make-args}}
make SIGN=ED25519 HASH=SHA256

- name: Generate external key
run: |
Expand Down Expand Up @@ -107,15 +107,15 @@ jobs:

- name: Select config
run: |
cp config/examples/sim-rsa.config .config && make include/target.h
cp config/examples/sim.config .config && make include/target.h

- name: Build tools
run: |
make -C tools/keytools && make -C tools/bin-assemble

- name: Build wolfboot
run: |
make ${{inputs.make-args}}
make SIGN=RSA2048 HASH=SHA256

- name: Generate external key
run: |
Expand Down
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ if(SIGN STREQUAL "NONE")
set(WOLFBOOT_SIGNING_PRIVATE_KEY
""
CACHE INTERNAL "")
set(STACK_USAGE 1216)
if(HASH STREQUAL "SHA384")
set(STACK_USAGE 3760)
else()
set(STACK_USAGE 1216)
endif()
list(APPEND SIGN_OPTIONS WOLFBOOT_NO_SIGN)
else()
set(WOLFBOOT_SIGNING_PRIVATE_KEY ${CMAKE_CURRENT_BINARY_DIR}/wolfboot_signing_private_key.der)
Expand All @@ -312,9 +316,9 @@ if(SIGN STREQUAL "ECC256")
if(WOLFBOOT_SMALL_STACK)
set(STACK_USAGE 4096)
elseif(NOT SPMATH)
set(STACK_USAGE 5008)
set(STACK_USAGE 5264)
else()
set(STACK_USAGE 3952)
set(STACK_USAGE 7632)
endif()

if(${IMAGE_HEADER_SIZE} LESS 256)
Expand All @@ -333,7 +337,7 @@ if(SIGN STREQUAL "ECC384")
elseif(NOT SPMATH)
set(STACK_USAGE 11248)
else()
set(STACK_USAGE 5880)
set(STACK_USAGE 11216)
endif()

if(${IMAGE_HEADER_SIZE} LESS 512)
Expand Down Expand Up @@ -367,7 +371,7 @@ if(SIGN STREQUAL "ED25519")
list(APPEND SIGN_OPTIONS WOLFBOOT_SIGN_ED25519)

if(NOT DEFINED STACK_USAGE)
set(STACK_USAGE 1180)
set(STACK_USAGE 5000)
endif()

if(${IMAGE_HEADER_SIZE} LESS 256)
Expand Down Expand Up @@ -412,7 +416,7 @@ if(SIGN STREQUAL "RSA2048")
elseif(NOT SPMATH)
set(STACK_USAGE 35952)
else()
set(STACK_USAGE 12288)
set(STACK_USAGE 17568)
endif()

if(${IMAGE_HEADER_SIZE} LESS 512)
Expand All @@ -430,7 +434,7 @@ if(SIGN STREQUAL "RSA4096")
if(NOT SPMATH)
set(STACK_USAGE 5888)
else()
set(STACK_USAGE 4096)
set(STACK_USAGE 5768)
endif()
elseif(NOT SPMATH)
set(STACK_USAGE 69232)
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ stage1/loader_stage1.bin: FORCE
@echo "\t[BIN] $@"
$(Q)$(MAKE) -C $(dir $@) $(notdir $@)

test-lib: $(OBJS)
$(Q)$(CC) $(CFLAGS) -o $@ $^
test-lib: include/target.h $(OBJS)
$(Q)$(CC) $(CFLAGS) -o $@ $(OBJS)

wolfboot.efi: wolfboot.elf
@echo "\t[BIN] $@"
Expand Down
7 changes: 7 additions & 0 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,10 @@ ifeq ($(TARGET),sim)
LD_END_GROUP=
BOOT_IMG=test-app/image.elf
CFLAGS+=-DARCH_SIM
ifeq ($(SPMATH),1)
MATH_OBJS += ./lib/wolfssl/wolfcrypt/src/sp_c32.o
CFLAGS+=-DWOLFSSL_SP_DIV_WORD_HALF
endif
endif

CFLAGS+=-DARCH_FLASH_OFFSET=$(ARCH_FLASH_OFFSET)
Expand All @@ -731,9 +735,12 @@ ifeq ($(DUALBANK_SWAP),1)
UPDATE_OBJS:=src/update_flash_hwswap.o
endif

# Set default update object (if not library)
ifneq ($(TARGET),library)
ifeq ($(UPDATE_OBJS),)
UPDATE_OBJS:=./src/update_flash.o
endif
endif

## wolfBoot origin
ifeq ($(WOLFBOOT_ORIGIN),)
Expand Down
2 changes: 0 additions & 2 deletions config/examples/library.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
ARCH=
NO_LOADER=1
USE_GCC_HEADLESS=0
# ends up double including this to work around defaulting to update_flash
UPDATE_OBJS:=hal/library.o
TARGET=library
WOLFBOOT_SMALL_STACK=1
SIGN?=ED25519
Expand Down
18 changes: 0 additions & 18 deletions config/examples/sim-ecc.config

This file was deleted.

19 changes: 0 additions & 19 deletions config/examples/sim-rsa.config

This file was deleted.

12 changes: 8 additions & 4 deletions config/examples/sim.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ ARCH=sim
TARGET=sim
SIGN?=ED25519
HASH?=SHA256
WOLFBOOT_SMALL_STACK=1
WOLFBOOT_SMALL_STACK?=1
SPI_FLASH=0
DEBUG=1
SPMATH?=0

# sizes should be multiple of system page size
WOLFBOOT_PARTITION_SIZE=0x40000
WOLFBOOT_SECTOR_SIZE=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x20000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x80000
# if on external flash, it should be multiple of system page size
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x60000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0xA0000
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x100000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x180000

# required for keytools
WOLFBOOT_FIXED_PARTITIONS=1

# For debugging XMALLOC/XFREE
#CFLAGS_EXTRA+=-DWOLFBOOT_DEBUG_MALLOC
13 changes: 8 additions & 5 deletions include/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
# include "test-app/wcs/user_settings.h"
#else


#include <target.h>

/* System */
#define WOLFSSL_GENERAL_ALIGNMENT 4
#define SINGLE_THREADED
#define WOLFSSL_USER_MUTEX /* avoid wc_port.c wc_InitAndAllocMutex */
#define WOLFCRYPT_ONLY
#define SIZEOF_LONG_LONG 8

Expand Down Expand Up @@ -166,14 +166,14 @@ extern int tolower(int c);
defined(WOLFBOOT_SIGN_RSA4096) || \
defined(WOLFCRYPT_SECURE_MODE)


# define WC_RSA_BLINDING
# define WC_RSA_BLINDING
# define WC_RSA_DIRECT
# define RSA_LOW_MEM
# define WC_ASN_HASH_SHA256
# if !defined(WOLFBOOT_TPM) && !defined(WOLFCRYPT_SECURE_MODE)
# define WOLFSSL_RSA_VERIFY_INLINE
# define WOLFSSL_RSA_VERIFY_ONLY
# define WOLFSSL_RSA_PUBLIC_ONLY
# define WC_NO_RSA_OAEP
# endif
# if !defined(USE_FAST_MATH) && !defined(WOLFSSL_SP_MATH_ALL)
Expand Down Expand Up @@ -369,6 +369,9 @@ extern int tolower(int c);
#define WOLFSSL_NO_SOCK
#define WOLFSSL_IGNORE_FILE_WARN
#define NO_ERROR_STRINGS
#define NO_PKCS12
#define NO_PKCS8
#define NO_CHECK_PRIVATE_KEY

#define BENCH_EMBEDDED
#define NO_CRYPT_TEST
Expand All @@ -392,13 +395,13 @@ extern int tolower(int c);
# define WOLFSSL_SP_NO_MALLOC
# define WOLFSSL_SP_NO_DYN_STACK
# endif
# if !defined(ARCH_SIM) && !defined(SECURE_PKCS11)
# if !defined(SECURE_PKCS11)
# define WOLFSSL_NO_MALLOC
# endif
#else
# if defined(WOLFBOOT_HUGE_STACK)
# error "Cannot use SMALL_STACK=1 with HUGE_STACK=1"
#endif
# endif
# define WOLFSSL_SMALL_STACK
#endif

Expand Down
4 changes: 2 additions & 2 deletions options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ ifeq ($(SIGN),ECC256)
STACK_USAGE=6680
else
ifneq ($(SPMATH),1)
STACK_USAGE=5008
STACK_USAGE=5264
else
STACK_USAGE=7600
STACK_USAGE=7632
endif
endif
endif
Expand Down
Loading