From 081b34919c4de42a4d10a305add816894e3e83ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Frauenschl=C3=A4ger?= Date: Mon, 30 Oct 2023 16:24:41 +0100 Subject: [PATCH] Zephyr: improve order of random seed sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using Zephyr, we also want to use the proper wc_GenerateSeed method. However, if one of the defines is set (e.g., NO_STM32_RNG), the Zephyr option is ignored, although it would work. Hence, we have to change the order in which these settings for the source of a random seed are evaluated. Signed-off-by: Tobias Frauenschläger --- wolfcrypt/src/random.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index f20b50737..0d67d4726 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -3506,20 +3506,6 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) * extern int myRngFunc(byte* output, word32 sz); */ -#elif defined(WOLFSSL_SAFERTOS) || defined(WOLFSSL_LEANPSK) || \ - defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_MDK_ARM) || \ - defined(WOLFSSL_uITRON4) || defined(WOLFSSL_uTKERNEL2) || \ - defined(WOLFSSL_LPC43xx) || defined(NO_STM32_RNG) || \ - defined(MBED) || defined(WOLFSSL_EMBOS) || \ - defined(WOLFSSL_GENSEED_FORTEST) || defined(WOLFSSL_CHIBIOS) || \ - defined(WOLFSSL_CONTIKI) || defined(WOLFSSL_AZSPHERE) - - /* these platforms do not have a default random seed and - you'll need to implement your own wc_GenerateSeed or define via - CUSTOM_RAND_GENERATE_BLOCK */ - - #define USE_TEST_GENSEED - #elif defined(WOLFSSL_ZEPHYR) #include @@ -3630,6 +3616,20 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) return ret; } +#elif defined(WOLFSSL_SAFERTOS) || defined(WOLFSSL_LEANPSK) || \ + defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_MDK_ARM) || \ + defined(WOLFSSL_uITRON4) || defined(WOLFSSL_uTKERNEL2) || \ + defined(WOLFSSL_LPC43xx) || defined(NO_STM32_RNG) || \ + defined(MBED) || defined(WOLFSSL_EMBOS) || \ + defined(WOLFSSL_GENSEED_FORTEST) || defined(WOLFSSL_CHIBIOS) || \ + defined(WOLFSSL_CONTIKI) || defined(WOLFSSL_AZSPHERE) + + /* these platforms do not have a default random seed and + you'll need to implement your own wc_GenerateSeed or define via + CUSTOM_RAND_GENERATE_BLOCK */ + + #define USE_TEST_GENSEED + #elif defined(NO_DEV_RANDOM) #error "you need to write an os specific wc_GenerateSeed() here"