From 30a1f67e43f7215ecc3c3fdcd5a7ae05ad91a21e Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Fri, 9 Aug 2024 15:46:15 +0200 Subject: [PATCH] Added 32bit simulator via TARGET=sim FORCE_32BIT=1 (#485) * Added 32bit simulator via TARGET=sim FORCE_32BIT=1 Tests can now run on 32bit simulator (e.g. to match XMALLOC fixed sizes with sp_math and WOLFBOOT_SMALL_STACK). * Added draft for new workflow: test simulator with different memory config * Fix 64bit, SMALL_STACK xmalloc sizes * Test defaults to SPMATH * Fixed test: defaults to spmath. Added RSA tests (failing) * Fixed RSA allocation sizes for 64bit build * Added 64bit fastmath test (failing) * Fixed ecc_point size for 64bit builds (FASTMATH) * simulator config: use SPMATH by default * Attempt to fix i386 libc dep in workflow * Added HUGE_STACK to silence warning in FASTMATH+RSA4096 tests --- .github/workflows/test-sunnyday-simulator.yml | 548 ++++++++++++++++++ arch.mk | 4 + .../examples/sim-nobackup-flags-home.config | 1 - .../sim-nobackup-nvm-writeonce.config | 1 - config/examples/sim-nobackup.config | 1 - config/examples/sim.config | 3 +- config/examples/sim32.config | 22 + src/xmalloc.c | 26 +- test-app/Makefile | 4 + 9 files changed, 601 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/test-sunnyday-simulator.yml create mode 100644 config/examples/sim32.config diff --git a/.github/workflows/test-sunnyday-simulator.yml b/.github/workflows/test-sunnyday-simulator.yml new file mode 100644 index 000000000..a73c3cd2d --- /dev/null +++ b/.github/workflows/test-sunnyday-simulator.yml @@ -0,0 +1,548 @@ +name: test with simulator targets on RSA/ECC to detect xmalloc failures + +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +jobs: + simulator_tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Workaround for sources.list + run: sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu/|http://mirror.arizona.edu/ubuntu/|g' /etc/apt/sources.list + + - name: Update repository + run: sudo apt-get update + + - name: Install 32-bit libc + run: | + sudo apt-get install -y libc6-dev-i386 + + # 32 Bit simulator, SP_MATH + # + - name: make clean + run: | + make distclean + + - name: Select config (32 bit simulator) + run: | + cp config/examples/sim32.config .config + + - name: Build tools + run: | + make -C tools/keytools && make -C tools/bin-assemble + + - name: Build wolfboot.elf (ECC256) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC256 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC256, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC256 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (ECC384) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC384 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC384, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC384 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (ECC521) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC521 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC521, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC521 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA2048) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA2048 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA2048, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA2048 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA3072) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA3072 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA3072, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA3072 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA4096) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA4096 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA4096, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA4096 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + # 32 Bit simulator, FASTMATH + # + - name: make clean + run: | + make distclean + + - name: Select config (32 bit simulator) + run: | + cp config/examples/sim32.config .config + + - name: Build tools + run: | + make -C tools/keytools && make -C tools/bin-assemble + + - name: Build wolfboot.elf (ECC256, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC256 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC256, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC256 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (ECC384, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC384 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC384, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC384 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (ECC521, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC521 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC521, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC521 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA2048, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA2048 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA2048, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA2048 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA3072, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA3072 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA3072, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA3072 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA4096, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA4096 SPMATH=0 WOLFBOOT_HUGE_STACK=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA4096, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA4096 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + + # 64 Bit simulator, SP_MATH + # + - name: make clean + run: | + make distclean + + - name: Select config (64 bit simulator) + run: | + cp config/examples/sim.config .config + + - name: Build tools + run: | + make -C tools/keytools && make -C tools/bin-assemble + + - name: Build wolfboot.elf (ECC256) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC256 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC256, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC256 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (ECC384) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC384 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC384, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC384 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (ECC521) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC521 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC521, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC521 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA2048) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA2048 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA2048, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA2048 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA3072) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA3072 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA3072, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA3072 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA4096) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA4096 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA4096, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA4096 WOLFBOOT_SMALL_STACK=1 SPMATH=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + # 64 Bit simulator, FASTMATH + # + - name: make clean + run: | + make distclean + + - name: Select config (64 bit simulator) + run: | + cp config/examples/sim.config .config + + - name: Build tools + run: | + make -C tools/keytools && make -C tools/bin-assemble + + - name: Build wolfboot.elf (ECC256, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC256 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC256, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC256 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (ECC384, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC384 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC384, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC384 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (ECC521, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC521 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (ECC521, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=ECC521 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA2048, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA2048 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA2048, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA2048 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA3072, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA3072 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA3072, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA3072 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Cleanup to change key type + run: | + make -C tools/keytools clean && make keysclean && make -C tools/keytools + + - name: Build wolfboot.elf (RSA4096, FASTMATH) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA4096 SPMATH=0 WOLFBOOT_HUGE_STACK=1 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + + - name: Build wolfboot.elf (RSA4096, FASTMATH, WOLFBOOT_SMALL_STACK) + run: | + make clean && make test-sim-internal-flash-with-update SIGN=RSA4096 WOLFBOOT_SMALL_STACK=1 SPMATH=0 + + - name: Run sunny day update test + run: | + tools/scripts/sim-sunnyday-update.sh + diff --git a/arch.mk b/arch.mk index b95155e02..45838a9d8 100644 --- a/arch.mk +++ b/arch.mk @@ -964,6 +964,10 @@ ifeq ($(TARGET),sim) LD_END_GROUP= BOOT_IMG=test-app/image.elf CFLAGS+=-DARCH_SIM + ifeq ($(FORCE_32BIT),1) + CFLAGS+=-m32 + LDFLAGS+=-m32 + endif ifeq ($(SPMATH),1) MATH_OBJS += ./lib/wolfssl/wolfcrypt/src/sp_c32.o CFLAGS+=-DWOLFSSL_SP_DIV_WORD_HALF diff --git a/config/examples/sim-nobackup-flags-home.config b/config/examples/sim-nobackup-flags-home.config index ae3389e12..a0387eebf 100644 --- a/config/examples/sim-nobackup-flags-home.config +++ b/config/examples/sim-nobackup-flags-home.config @@ -5,7 +5,6 @@ HASH?=SHA256 WOLFBOOT_SMALL_STACK?=1 SPI_FLASH=0 DEBUG=1 -SPMATH?=0 DISABLE_BACKUP=1 FLAGS_HOME=1 diff --git a/config/examples/sim-nobackup-nvm-writeonce.config b/config/examples/sim-nobackup-nvm-writeonce.config index aa70af340..4f7f5af94 100644 --- a/config/examples/sim-nobackup-nvm-writeonce.config +++ b/config/examples/sim-nobackup-nvm-writeonce.config @@ -5,7 +5,6 @@ HASH?=SHA256 WOLFBOOT_SMALL_STACK?=1 SPI_FLASH=0 DEBUG=1 -SPMATH?=0 DISABLE_BACKUP=1 NVM_FLASH_WRITEONCE=1 diff --git a/config/examples/sim-nobackup.config b/config/examples/sim-nobackup.config index fd67a8149..1da51fb17 100644 --- a/config/examples/sim-nobackup.config +++ b/config/examples/sim-nobackup.config @@ -5,7 +5,6 @@ HASH?=SHA256 WOLFBOOT_SMALL_STACK?=1 SPI_FLASH=0 DEBUG=1 -SPMATH?=0 DISABLE_BACKUP=1 # sizes should be multiple of system page size diff --git a/config/examples/sim.config b/config/examples/sim.config index 6bd914dff..b0fefa34b 100644 --- a/config/examples/sim.config +++ b/config/examples/sim.config @@ -2,10 +2,9 @@ ARCH=sim TARGET=sim SIGN?=ED25519 HASH?=SHA256 -WOLFBOOT_SMALL_STACK?=1 +WOLFBOOT_SMALL_STACK?=0 SPI_FLASH=0 DEBUG=1 -SPMATH?=0 # sizes should be multiple of system page size WOLFBOOT_PARTITION_SIZE=0x40000 diff --git a/config/examples/sim32.config b/config/examples/sim32.config new file mode 100644 index 000000000..09a1021d6 --- /dev/null +++ b/config/examples/sim32.config @@ -0,0 +1,22 @@ +ARCH=sim +TARGET=sim +SIGN?=ECC256 +HASH?=SHA256 +WOLFBOOT_SMALL_STACK?=0 +SPI_FLASH=0 +DEBUG=1 +FORCE_32BIT=1 + +# sizes should be multiple of system page size +WOLFBOOT_PARTITION_SIZE=0x40000 +WOLFBOOT_SECTOR_SIZE=0x1000 +WOLFBOOT_PARTITION_BOOT_ADDRESS=0x80000 +# if on external flash, it should be multiple of system page size +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 diff --git a/src/xmalloc.c b/src/xmalloc.c index 7ab2e2cae..47900951c 100644 --- a/src/xmalloc.c +++ b/src/xmalloc.c @@ -63,6 +63,7 @@ struct xmalloc_slot { # error "No hash mechanism selected." #endif + #if defined(WOLFBOOT_SIGN_ECC256) || defined(WOLFBOOT_SIGN_ECC384) || defined(WOLFBOOT_SIGN_ECC521) #ifndef USE_FAST_MATH @@ -135,7 +136,12 @@ struct xmalloc_slot { #define MP_SCHEME "TFM ECC256" #define MP_CURVE_SPECS_SIZE (MP_INT_TYPE_SIZE) #define MP_CURVE_FIELD_COUNT_SIZE (380) - #define ECC_POINT_SIZE (228) + #ifndef _LP64 + #define ECC_POINT_SIZE (228) + #else + #define ECC_POINT_SIZE (312) + #define MP_INT_BUFFER_SIZE_1 (MP_INT_TYPE_SIZE * 5) + #endif #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 6) #define MP_DIGIT_BUFFER_MONT_SIZE (sizeof(fp_digit)*(FP_SIZE + 1)) #endif @@ -143,7 +149,11 @@ struct xmalloc_slot { #define MP_SCHEME "TFM ECC384" #define MP_CURVE_SPECS_SIZE (MP_INT_TYPE_SIZE) #define MP_CURVE_FIELD_COUNT_SIZE (380) - #define ECC_POINT_SIZE (408) + #ifndef _LP64 + #define ECC_POINT_SIZE (408) + #else + #define ECC_POINT_SIZE (504) + #endif #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 5) #define MP_INT_BUFFER_SIZE_1 (MP_INT_TYPE_SIZE * 6) #define MP_DIGIT_BUFFER_MONT_SIZE (sizeof(fp_digit)*(FP_SIZE + 1)) @@ -152,7 +162,11 @@ struct xmalloc_slot { #define MP_SCHEME "TFM ECC521" #define MP_CURVE_SPECS_SIZE (MP_INT_TYPE_SIZE) #define MP_CURVE_FIELD_COUNT_SIZE (380) - #define ECC_POINT_SIZE (516) + #ifndef _LP64 + #define ECC_POINT_SIZE (516) + #else + #define ECC_POINT_SIZE (600) + #endif #define MP_INT_BUFFER_SIZE (MP_INT_TYPE_SIZE * 5) #define MP_INT_BUFFER_SIZE_1 (MP_INT_TYPE_SIZE * 6) #define MP_DIGIT_BUFFER_MONT_SIZE (sizeof(fp_digit)*(FP_SIZE + 1)) @@ -280,7 +294,11 @@ static struct xmalloc_slot xmalloc_pool[] = { static uint32_t sha_block[HASH_BLOCK_SIZE]; +#ifndef _LP64 #define ASNCHECK_BUF_SIZE (224) +#else +#define ASNCHECK_BUF_SIZE (320) +#endif static uint8_t asncheck_buf[ASNCHECK_BUF_SIZE]; #ifndef USE_FAST_MATH @@ -326,7 +344,7 @@ static uint8_t asncheck_buf[ASNCHECK_BUF_SIZE]; #endif { NULL, 0, 0} }; -#else +#else /* FAST MATH */ #define MP_SCHEME "TFM RSA" #define MP_INT_TYPE_SIZE (sizeof(mp_int)) #define MP_MONT_REDUCE_BUF_SIZE (sizeof(fp_digit)*(FP_SIZE + 1)) diff --git a/test-app/Makefile b/test-app/Makefile index 74bc55c1d..a377e4788 100644 --- a/test-app/Makefile +++ b/test-app/Makefile @@ -215,6 +215,10 @@ ifeq ($(TARGET),sim) # LD on MacOS does not support "-Map=" LDMAPSUPPORTED=$(shell $(CC) -Wl,-Map=image.map 2>&1 | grep 'unknown option') LDFLAGS= + ifeq ($(FORCE_32BIT),1) + LDFLAGS+=-m32 + CFLAGS+=-m32 + endif ifeq ($(LDMAPSUPPORTED),) # Override linker flags LDFLAGS+=-Wl,-Map=image.map