Move the STM32 hash options into STM32_HASH. Fix for realloc. Improve docs for hcom_uart. Fix issue with detecting RTC and incorrectly setting NO_ASN_TIME.

This commit is contained in:
David Garske
2025-10-02 15:24:03 -07:00
committed by Daniele Lacamera
parent ee77094dd6
commit c349001d94
5 changed files with 38 additions and 26 deletions

View File

@@ -196,7 +196,9 @@ Note: The Benchmark example uses float. To enable go to "Project Properties" ->
## STM32 Printf
In main.c make the following changes:
Generation of code for a NUCLEO board provides a BSP option for generating printf support for the virtual com port. To use this set `#define HAL_CONSOLE_UART hcom_uart`.
If setting the printf support manually make the following changes in `main.c`.
This section needs to go below the `UART_HandleTypeDef` line, otherwise `wolfssl/wolfcrypt/settings.h` will error.

View File

@@ -299,6 +299,7 @@ extern ${variable.value} ${variable.name};
/* ------------------------------------------------------------------------- */
#if defined(WOLF_CONF_RTOS) && WOLF_CONF_RTOS == 2
#define FREERTOS
#define WOLFSSL_NO_REALLOC
#else
#define SINGLE_THREADED
#endif
@@ -789,12 +790,6 @@ extern ${variable.value} ${variable.name};
/* Base16 / Base64 encoding */
//#define NO_CODING
/* bypass certificate date checking, due to lack of properly configured RTC source */
#ifndef HAL_RTC_MODULE_ENABLED
#define NO_ASN_TIME
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -81,8 +81,18 @@ static int wolfssl_read_bio_file(WOLFSSL_BIO* bio, char** data)
}
else {
/* No space left for more data to be read - add a chunk. */
#ifdef WOLFSSL_NO_REALLOC
p = (char*)XMALLOC(ret + READ_BIO_FILE_CHUNK, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (p != NULL) {
XMEMCPY(p, mem, ret);
XFREE(mem, NULL, DYNAMIC_TYPE_TMP_BUFFER);
mem = NULL;
}
#else
p = (char*)XREALLOC(mem, ret + READ_BIO_FILE_CHUNK, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
#endif
if (p == NULL) {
sz = MEMORY_E;
break;

View File

@@ -35,20 +35,18 @@
#ifdef HASH_DIGEST
/* The HASH_DIGEST register indicates SHA224/SHA256 support */
#define STM32_HASH_SHA2
#if defined(WOLFSSL_STM32H5) || defined(WOLFSSL_STM32MP13) || \
defined(WOLFSSL_STM32N6)
#if defined(WOLFSSL_STM32MP13) || defined(WOLFSSL_STM32H7S) || \
defined(WOLFSSL_STM32N6) || defined(WOLFSSL_STM32H5)
#define HASH_CR_SIZE 103
#define HASH_MAX_DIGEST 64 /* Up to SHA512 */
#else
#define HASH_CR_SIZE 54
#define HASH_MAX_DIGEST 32
#endif
#if defined(WOLFSSL_STM32MP13) || defined(WOLFSSL_STM32H7S) || \
defined(WOLFSSL_STM32N6)
#define STM32_HASH_SHA512
#define STM32_HASH_SHA512_224
#define STM32_HASH_SHA512_256
#define STM32_HASH_SHA384
#else
#define HASH_CR_SIZE 54
#define HASH_MAX_DIGEST 32
#endif
#if defined(WOLFSSL_STM32MP13)
#define STM32_HASH_SHA3
@@ -58,6 +56,20 @@
#define HASH_MAX_DIGEST 20
#endif
#ifdef WOLFSSL_STM32MP13
/* From stm32_hal_legacy.h, but that MP13 header has a bug in it */
#define HASH_AlgoSelection_MD5 HASH_ALGOSELECTION_MD5
#define HASH_AlgoSelection_SHA1 HASH_ALGOSELECTION_SHA1
#define HASH_AlgoSelection_SHA224 HASH_ALGOSELECTION_SHA224
#define HASH_AlgoSelection_SHA256 HASH_ALGOSELECTION_SHA256
#endif
/* These HASH HAL's have no MD5 implementation */
#if defined(WOLFSSL_STM32MP13) || defined(WOLFSSL_STM32H7S) || \
defined(WOLFSSL_STM32N6) || defined(WOLFSSL_STM32H5)
#define STM32_NOMD5
#endif
/* Handle hash differences between CubeMX and StdPeriLib */
#if !defined(HASH_ALGOMODE_HASH) && defined(HASH_AlgoMode_HASH)
#define HASH_ALGOMODE_HASH HASH_AlgoMode_HASH
@@ -130,17 +142,6 @@ int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo,
#define __HAL_RCC_RNG_CLK_ENABLE __HAL_RCC_RNG1_CLK_ENABLE
#define __HAL_RCC_HASH_CLK_ENABLE __HAL_RCC_HASH1_CLK_ENABLE
#define __HAL_RCC_HASH_CLK_DISABLE __HAL_RCC_HASH1_CLK_DISABLE
/* From stm32_hal_legacy.h, but that header has a bug in it */
#define HASH_AlgoSelection_MD5 HASH_ALGOSELECTION_MD5
#define HASH_AlgoSelection_SHA1 HASH_ALGOSELECTION_SHA1
#define HASH_AlgoSelection_SHA224 HASH_ALGOSELECTION_SHA224
#define HASH_AlgoSelection_SHA256 HASH_ALGOSELECTION_SHA256
#define STM32_NOMD5 /* The HASH HAL has no MD5 implementation */
#endif
#if defined(WOLFSSL_STM32N6)
#define STM32_NOMD5 /* The HASH HAL has no MD5 implementation */
#endif
#ifndef NO_AES

View File

@@ -2226,6 +2226,10 @@ extern void uITRON4_free(void *p) ;
#ifndef STM32_HAL_TIMEOUT
#define STM32_HAL_TIMEOUT 0xFF
#endif
/* bypass certificate date checking, due to lack of properly configured RTC source */
#ifndef HAL_RTC_MODULE_ENABLED
#define NO_ASN_TIME
#endif
#if defined(WOLFSSL_STM32_PKA) && !defined(WOLFSSL_SP_INT_NEGATIVE)
/* enable the negative support for abs(a) |a| */