From 9b7c753165acf75568515f6d8f37abe060726d22 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Tue, 25 Aug 2020 23:26:57 -0500 Subject: [PATCH] wolfssl/wolfcrypt/types.h: make DECLARE_VAR() et al use heap allocation not only when WOLFSSL_ASYNC_CRYPT but also when WOLFSSL_SMALL_STACK. --- wolfcrypt/test/test.c | 13 +++++++++++++ wolfssl/wolfcrypt/types.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 0b541462f..3e29f6dac 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -18897,6 +18897,19 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount, ecc_key userA, userB, pubKey; int curveSize; +#ifdef WOLFSSL_SMALL_STACK +#if (defined(HAVE_ECC_DHE) || defined(HAVE_ECC_CDH)) && \ + !defined(WOLFSSL_ATECC508A) && !defined(WOLFSSL_ATECC608A) + if ((sharedA == NULL) || (sharedB == NULL)) + ERROR_OUT(-9652, done); +#endif + +#ifdef HAVE_ECC_SIGN + if ((sig == NULL) || (digest == NULL)) + ERROR_OUT(-9653, done); +#endif +#endif /* WOLFSSL_SMALL_STACK */ + (void)testVerifyCount; (void)dp; (void)x; diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index b1f3177d3..26472ac58 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -396,7 +396,7 @@ decouple library dependencies with standard string, memory and so on. #endif /* declare/free variable handling for async */ - #ifdef WOLFSSL_ASYNC_CRYPT + #if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_SMALL_STACK) #define DECLARE_VAR(VAR_NAME, VAR_TYPE, VAR_SIZE, HEAP) \ VAR_TYPE* VAR_NAME = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT); #define DECLARE_VAR_INIT(VAR_NAME, VAR_TYPE, VAR_SIZE, INIT_VALUE, HEAP) \