Skip to content

Commit 1ddbf71

Browse files
committed
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.
1 parent fd25881 commit 1ddbf71

File tree

5 files changed

+38
-26
lines changed

5 files changed

+38
-26
lines changed

IDE/STM32Cube/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ Note: The Benchmark example uses float. To enable go to "Project Properties" ->
196196
197197
## STM32 Printf
198198
199-
In main.c make the following changes:
199+
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`.
200+
201+
If setting the printf support manually make the following changes in `main.c`.
200202
201203
This section needs to go below the `UART_HandleTypeDef` line, otherwise `wolfssl/wolfcrypt/settings.h` will error.
202204

IDE/STM32Cube/default_conf.ftl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ extern ${variable.value} ${variable.name};
299299
/* ------------------------------------------------------------------------- */
300300
#if defined(WOLF_CONF_RTOS) && WOLF_CONF_RTOS == 2
301301
#define FREERTOS
302+
#define WOLFSSL_NO_REALLOC
302303
#else
303304
#define SINGLE_THREADED
304305
#endif
@@ -789,12 +790,6 @@ extern ${variable.value} ${variable.name};
789790
/* Base16 / Base64 encoding */
790791
//#define NO_CODING
791792

792-
/* bypass certificate date checking, due to lack of properly configured RTC source */
793-
#ifndef HAL_RTC_MODULE_ENABLED
794-
#define NO_ASN_TIME
795-
#endif
796-
797-
798793
#ifdef __cplusplus
799794
}
800795
#endif

src/ssl_misc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,18 @@ static int wolfssl_read_bio_file(WOLFSSL_BIO* bio, char** data)
8181
}
8282
else {
8383
/* No space left for more data to be read - add a chunk. */
84+
#ifdef WOLFSSL_NO_REALLOC
85+
p = (char*)XMALLOC(ret + READ_BIO_FILE_CHUNK, NULL,
86+
DYNAMIC_TYPE_TMP_BUFFER);
87+
if (p != NULL) {
88+
XMEMCPY(p, mem, ret);
89+
XFREE(mem, NULL, DYNAMIC_TYPE_TMP_BUFFER);
90+
mem = NULL;
91+
}
92+
#else
8493
p = (char*)XREALLOC(mem, ret + READ_BIO_FILE_CHUNK, NULL,
8594
DYNAMIC_TYPE_TMP_BUFFER);
95+
#endif
8696
if (p == NULL) {
8797
sz = MEMORY_E;
8898
break;

wolfssl/wolfcrypt/port/st/stm32.h

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,18 @@
3535
#ifdef HASH_DIGEST
3636
/* The HASH_DIGEST register indicates SHA224/SHA256 support */
3737
#define STM32_HASH_SHA2
38-
#if defined(WOLFSSL_STM32H5) || defined(WOLFSSL_STM32MP13) || \
39-
defined(WOLFSSL_STM32N6)
38+
#if defined(WOLFSSL_STM32MP13) || defined(WOLFSSL_STM32H7S) || \
39+
defined(WOLFSSL_STM32N6) || defined(WOLFSSL_STM32H5)
4040
#define HASH_CR_SIZE 103
4141
#define HASH_MAX_DIGEST 64 /* Up to SHA512 */
42-
#else
43-
#define HASH_CR_SIZE 54
44-
#define HASH_MAX_DIGEST 32
45-
#endif
46-
#if defined(WOLFSSL_STM32MP13) || defined(WOLFSSL_STM32H7S) || \
47-
defined(WOLFSSL_STM32N6)
42+
4843
#define STM32_HASH_SHA512
4944
#define STM32_HASH_SHA512_224
5045
#define STM32_HASH_SHA512_256
5146
#define STM32_HASH_SHA384
47+
#else
48+
#define HASH_CR_SIZE 54
49+
#define HASH_MAX_DIGEST 32
5250
#endif
5351
#if defined(WOLFSSL_STM32MP13)
5452
#define STM32_HASH_SHA3
@@ -58,6 +56,20 @@
5856
#define HASH_MAX_DIGEST 20
5957
#endif
6058

59+
#ifdef WOLFSSL_STM32MP13
60+
/* From stm32_hal_legacy.h, but that MP13 header has a bug in it */
61+
#define HASH_AlgoSelection_MD5 HASH_ALGOSELECTION_MD5
62+
#define HASH_AlgoSelection_SHA1 HASH_ALGOSELECTION_SHA1
63+
#define HASH_AlgoSelection_SHA224 HASH_ALGOSELECTION_SHA224
64+
#define HASH_AlgoSelection_SHA256 HASH_ALGOSELECTION_SHA256
65+
#endif
66+
67+
/* These HASH HAL's have no MD5 implementation */
68+
#if defined(WOLFSSL_STM32MP13) || defined(WOLFSSL_STM32H7S) || \
69+
defined(WOLFSSL_STM32N6) || defined(WOLFSSL_STM32H5)
70+
#define STM32_NOMD5
71+
#endif
72+
6173
/* Handle hash differences between CubeMX and StdPeriLib */
6274
#if !defined(HASH_ALGOMODE_HASH) && defined(HASH_AlgoMode_HASH)
6375
#define HASH_ALGOMODE_HASH HASH_AlgoMode_HASH
@@ -130,17 +142,6 @@ int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo,
130142
#define __HAL_RCC_RNG_CLK_ENABLE __HAL_RCC_RNG1_CLK_ENABLE
131143
#define __HAL_RCC_HASH_CLK_ENABLE __HAL_RCC_HASH1_CLK_ENABLE
132144
#define __HAL_RCC_HASH_CLK_DISABLE __HAL_RCC_HASH1_CLK_DISABLE
133-
/* From stm32_hal_legacy.h, but that header has a bug in it */
134-
#define HASH_AlgoSelection_MD5 HASH_ALGOSELECTION_MD5
135-
#define HASH_AlgoSelection_SHA1 HASH_ALGOSELECTION_SHA1
136-
#define HASH_AlgoSelection_SHA224 HASH_ALGOSELECTION_SHA224
137-
#define HASH_AlgoSelection_SHA256 HASH_ALGOSELECTION_SHA256
138-
139-
#define STM32_NOMD5 /* The HASH HAL has no MD5 implementation */
140-
#endif
141-
142-
#if defined(WOLFSSL_STM32N6)
143-
#define STM32_NOMD5 /* The HASH HAL has no MD5 implementation */
144145
#endif
145146

146147
#ifndef NO_AES

wolfssl/wolfcrypt/settings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,6 +2226,10 @@ extern void uITRON4_free(void *p) ;
22262226
#ifndef STM32_HAL_TIMEOUT
22272227
#define STM32_HAL_TIMEOUT 0xFF
22282228
#endif
2229+
/* bypass certificate date checking, due to lack of properly configured RTC source */
2230+
#ifndef HAL_RTC_MODULE_ENABLED
2231+
#define NO_ASN_TIME
2232+
#endif
22292233

22302234
#if defined(WOLFSSL_STM32_PKA) && !defined(WOLFSSL_SP_INT_NEGATIVE)
22312235
/* enable the negative support for abs(a) |a| */

0 commit comments

Comments
 (0)