From 0ee918f9f642b04cbef233352977253179bfa8a4 Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 16 Aug 2023 17:13:06 -0700 Subject: [PATCH] Fixes for simulator malloc/free. Fix for RSA encrypt missing `wc_RsaPublicEncrypt_ex`. --- include/user_settings.h | 11 +++++++++-- options.mk | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/user_settings.h b/include/user_settings.h index 86bf6b236..c83e24ccd 100644 --- a/include/user_settings.h +++ b/include/user_settings.h @@ -136,7 +136,9 @@ extern int tolower(int c); # define WOLFSSL_RSA_VERIFY_INLINE # define WOLFSSL_RSA_VERIFY_ONLY # endif -# define WC_NO_RSA_OAEP +# ifndef WOLFBOOT_TPM_KEYSTORE +# define WC_NO_RSA_OAEP +# endif # define FP_MAX_BITS (2048 * 2) /* sp math */ # if !defined(USE_FAST_MATH) && !defined(WOLFSSL_SP_MATH_ALL) @@ -229,6 +231,9 @@ extern int tolower(int c); #endif #ifdef WOLFBOOT_TPM + /* Do not use heap */ + #define WOLFTPM2_NO_HEAP + #ifdef WOLFBOOT_TPM_KEYSTORE /* Enable AES CFB (parameter encryption) and HMAC (for KDF) */ #define WOLFSSL_AES_CFB @@ -319,7 +324,9 @@ extern int tolower(int c); # define WOLFSSL_SP_NO_MALLOC # define WOLFSSL_SP_NO_DYN_STACK # endif -# define WOLFSSL_NO_MALLOC +# ifndef ARCH_SIM +# define WOLFSSL_NO_MALLOC +# endif #else # if defined(WOLFBOOT_HUGE_STACK) # error "Cannot use SMALL_STACK=1 with HUGE_STACK=1" diff --git a/options.mk b/options.mk index d68086a6d..26a97b712 100644 --- a/options.mk +++ b/options.mk @@ -187,6 +187,7 @@ ifeq ($(SIGN),RSA2048) ./lib/wolfssl/wolfcrypt/src/rsa.o \ ./lib/wolfssl/wolfcrypt/src/asn.o \ ./lib/wolfssl/wolfcrypt/src/hash.o \ + ./lib/wolfssl/wolfcrypt/src/memory.o \ ./lib/wolfssl/wolfcrypt/src/wolfmath.o \ ./lib/wolfssl/wolfcrypt/src/wc_port.o CFLAGS+=-D"WOLFBOOT_SIGN_RSA2048" $(RSA_EXTRA_CFLAGS) @@ -221,6 +222,7 @@ ifeq ($(SIGN),RSA3072) ./lib/wolfssl/wolfcrypt/src/rsa.o \ ./lib/wolfssl/wolfcrypt/src/asn.o \ ./lib/wolfssl/wolfcrypt/src/hash.o \ + ./lib/wolfssl/wolfcrypt/src/memory.o \ ./lib/wolfssl/wolfcrypt/src/wolfmath.o \ ./lib/wolfssl/wolfcrypt/src/wc_port.o CFLAGS+=-D"WOLFBOOT_SIGN_RSA3072" $(RSA_EXTRA_CFLAGS) @@ -258,6 +260,7 @@ ifeq ($(SIGN),RSA4096) ./lib/wolfssl/wolfcrypt/src/rsa.o \ ./lib/wolfssl/wolfcrypt/src/asn.o \ ./lib/wolfssl/wolfcrypt/src/hash.o \ + ./lib/wolfssl/wolfcrypt/src/memory.o \ ./lib/wolfssl/wolfcrypt/src/wolfmath.o \ ./lib/wolfssl/wolfcrypt/src/wc_port.o CFLAGS+=-D"WOLFBOOT_SIGN_RSA4096" $(RSA_EXTRA_CFLAGS)