Fixes and cleanups for STM32:

* Fix for STM32 Hash peripherals (like on F437) with FIFO depth = 1.
* Cleanups for `XREALLOC` and new `WOLFSSL_NO_REALLOC` to force undef of `XREALLOC`.
* Change STM32 Cube to default to `NO_TLS_UART_TEST`.
pull/6033/head
David Garske 2023-01-30 16:44:47 -08:00
parent 08538b69f3
commit 2d03a052e1
4 changed files with 23 additions and 11 deletions

View File

@ -64,8 +64,12 @@ extern ${variable.value} ${variable.name};
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* Hardware platform */ /* Hardware platform */
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* Setup default (No crypto hardware acceleration or TLS UART test).
* Use undef in platform section to enable it.
*/
#define NO_STM32_HASH #define NO_STM32_HASH
#define NO_STM32_CRYPTO #define NO_STM32_CRYPTO
#define NO_TLS_UART_TEST
#if defined(STM32WB55xx) #if defined(STM32WB55xx)
#define WOLFSSL_STM32WB #define WOLFSSL_STM32WB
@ -98,6 +102,9 @@ extern ${variable.value} ${variable.name};
#undef NO_STM32_HASH #undef NO_STM32_HASH
#undef NO_STM32_CRYPTO #undef NO_STM32_CRYPTO
#define HAL_CONSOLE_UART huart3 #define HAL_CONSOLE_UART huart3
#elif defined(STM32H723xx)
#define WOLFSSL_STM32H7
#define HAL_CONSOLE_UART huart3
#elif defined(STM32L4A6xx) #elif defined(STM32L4A6xx)
#define WOLFSSL_STM32L4 #define WOLFSSL_STM32L4
#undef NO_STM32_HASH #undef NO_STM32_HASH
@ -130,12 +137,12 @@ extern ${variable.value} ${variable.name};
#define WOLFSSL_STM32F4 #define WOLFSSL_STM32F4
#define HAL_CONSOLE_UART huart2 #define HAL_CONSOLE_UART huart2
#define NO_STM32_RNG #define NO_STM32_RNG
#define WOLFSSL_GENSEED_FORTEST #define WOLFSSL_GENSEED_FORTEST /* no HW RNG is available use test seed */
#elif defined(STM32G071xx) #elif defined(STM32G071xx)
#define WOLFSSL_STM32G0 #define WOLFSSL_STM32G0
#define HAL_CONSOLE_UART huart2 #define HAL_CONSOLE_UART huart2
#define NO_STM32_RNG #define NO_STM32_RNG
#define WOLFSSL_GENSEED_FORTEST #define WOLFSSL_GENSEED_FORTEST /* no HW RNG is available use test seed */
#elif defined(STM32U575xx) || defined(STM32U585xx) #elif defined(STM32U575xx) || defined(STM32U585xx)
#define HAL_CONSOLE_UART huart1 #define HAL_CONSOLE_UART huart1
#define WOLFSSL_STM32U5 #define WOLFSSL_STM32U5

View File

@ -306,13 +306,15 @@ int wc_Stm32_Hash_Update(STM32_HASH_Context* stmCtx, word32 algo,
} }
if (wroteToFifo) { if (wroteToFifo) {
/* If we wrote a block send one more 32-bit to FIFO to trigger #if defined(STM32_HASH_FIFO_SIZE) && STM32_HASH_FIFO_SIZE > 1
* start. We cannot leave 16 deep FIFO filled before saving off /* If FIFO depth > 1 and we wrote a block send one more 32-bit to
* context */ * FIFO to trigger start. We cannot leave 16 deep FIFO filled before
* saving off context */
wc_Stm32_Hash_Data(stmCtx, 4); wc_Stm32_Hash_Data(stmCtx, 4);
stmCtx->fifoBytes += 4; stmCtx->fifoBytes += 4;
(void)wc_Stm32_Hash_WaitDone(stmCtx); (void)wc_Stm32_Hash_WaitDone(stmCtx);
#endif
/* save hash state for next operation */ /* save hash state for next operation */
wc_Stm32_Hash_SaveContext(stmCtx); wc_Stm32_Hash_SaveContext(stmCtx);

View File

@ -13065,7 +13065,7 @@ WOLFSSL_TEST_SUBROUTINE int memory_test(void)
} }
#endif #endif
#if !defined(USE_FAST_MATH) && !defined(WOLFSSL_NO_MALLOC) #if !defined(USE_FAST_MATH) && !defined(WOLFSSL_NO_MALLOC) && defined(XREALLOC)
/* realloc test */ /* realloc test */
{ {
byte *c = NULL; byte *c = NULL;

View File

@ -806,12 +806,11 @@ extern void uITRON4_free(void *p) ;
#define XMALLOC(s, h, type) pvPortMalloc((s)) #define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p)) #define XFREE(p, h, type) vPortFree((p))
/* FreeRTOS pvPortRealloc() implementation can be found here: /* FreeRTOS pvPortRealloc() implementation can be found here:
https://github.com/wolfSSL/wolfssl-freertos/pull/3/files */ * https://github.com/wolfSSL/wolfssl-freertos/pull/3/files */
#if !defined(USE_FAST_MATH) || defined(HAVE_ED25519) || \ #if defined(USE_INTEGER_HEAP_MATH) || defined(OPENSSL_EXTRA)
defined(HAVE_ED448)
#if defined(WOLFSSL_ESPIDF) #if defined(WOLFSSL_ESPIDF)
/*In IDF, realloc(p, n) is equivalent to /* In IDF, realloc(p, n) is equivalent to
heap_caps_realloc(p, s, MALLOC_CAP_8BIT) */ * heap_caps_realloc(p, s, MALLOC_CAP_8BIT) */
#define XREALLOC(p, n, h, t) realloc((p), (n)) #define XREALLOC(p, n, h, t) realloc((p), (n))
#else #else
#define XREALLOC(p, n, h, t) pvPortRealloc((p), (n)) #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
@ -2884,6 +2883,10 @@ extern void uITRON4_free(void *p) ;
#define HAVE_HPKE #define HAVE_HPKE
#endif #endif
/* Provide way to forcefully disable use of XREALLOC */
#ifdef WOLFSSL_NO_REALLOC
#undef XREALLOC
#endif
/* --------------------------------------------------------------------------- /* ---------------------------------------------------------------------------