Minor STM32F1 fixes

* Not all STM32 RTCs support subseconds in the time struct, so this is
  now ifdef'd using the only obvious define which exists when subseconds
  exist.
* Let wc_GenerateSeed detect STM32's without RNG correctly.
* wolfCrypt test was attempting to use variables that don't exist when
  both WOLFSSL_SMALL_STACK and WC_NO_RNG is defined.
This commit is contained in:
Andrew Hutchings
2021-10-12 14:46:27 +01:00
parent 6fbc9be71a
commit 97883d78ac
3 changed files with 6 additions and 3 deletions

View File

@@ -1496,12 +1496,15 @@ double current_time(void)
{ {
RTC_TimeTypeDef time; RTC_TimeTypeDef time;
RTC_DateTypeDef date; RTC_DateTypeDef date;
uint32_t subsec; uint32_t subsec = 0;
/* must get time and date here due to STM32 HW bug */ /* must get time and date here due to STM32 HW bug */
HAL_RTC_GetTime(&hrtc, &time, FORMAT_BIN); HAL_RTC_GetTime(&hrtc, &time, FORMAT_BIN);
HAL_RTC_GetDate(&hrtc, &date, FORMAT_BIN); HAL_RTC_GetDate(&hrtc, &date, FORMAT_BIN);
/* Not all STM32 RTCs have subseconds in the struct */
#ifdef RTC_ALARMSUBSECONDMASK_ALL
subsec = (255 - time.SubSeconds) * 1000 / 255; subsec = (255 - time.SubSeconds) * 1000 / 255;
#endif
(void) date; (void) date;

View File

@@ -2522,7 +2522,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
#elif defined(WOLFSSL_SAFERTOS) || defined(WOLFSSL_LEANPSK) || \ #elif defined(WOLFSSL_SAFERTOS) || defined(WOLFSSL_LEANPSK) || \
defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_MDK_ARM) || \ defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_MDK_ARM) || \
defined(WOLFSSL_uITRON4) || defined(WOLFSSL_uTKERNEL2) || \ defined(WOLFSSL_uITRON4) || defined(WOLFSSL_uTKERNEL2) || \
defined(WOLFSSL_LPC43xx) || defined(WOLFSSL_STM32F2xx) || \ defined(WOLFSSL_LPC43xx) || defined(NO_STM32_RNG) || \
defined(MBED) || defined(WOLFSSL_EMBOS) || \ defined(MBED) || defined(WOLFSSL_EMBOS) || \
defined(WOLFSSL_GENSEED_FORTEST) || defined(WOLFSSL_CHIBIOS) || \ defined(WOLFSSL_GENSEED_FORTEST) || defined(WOLFSSL_CHIBIOS) || \
defined(WOLFSSL_CONTIKI) || defined(WOLFSSL_AZSPHERE) defined(WOLFSSL_CONTIKI) || defined(WOLFSSL_AZSPHERE)

View File

@@ -16343,7 +16343,7 @@ static int dh_ffdhe_test(WC_RNG *rng, const DhParams* params)
done: done:
#ifdef WOLFSSL_SMALL_STACK #if defined(WOLFSSL_SMALL_STACK) && !defined(WC_NO_RNG)
if (priv) if (priv)
XFREE(priv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); XFREE(priv, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
if (pub) if (pub)