Repository navigation
settings.h, random.c: warn when MICRIUM seeds from Math_Rand - #11922
yosuke-wolfssl wants to merge 1 commit into
Conversation
- settings.h no longer defaults CUSTOM_RAND_GENERATE to Math_Rand for MICRIUM. - random.c gains a MICRIUM wc_GenerateSeed arm that fills the seed from Math_Rand() and emits a #warning (#pragma message on MSVC and TASKING) naming CUSTOM_RAND_GENERATE_SEED. - The Micrium sample user_settings.h and README show how to supply a hardware seed source. Issue: F-16887
|
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11922
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): IDE/ECLIPSE/MICRIUM/README.md, IDE/ECLIPSE/MICRIUM/user_settings.h
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11922
Fenrir already completed a review of this PR at commit 8189deaa8b2c (run 3546); its findings are the review threads on the PR. Push a new commit to request another review.
Problem
When
MICRIUMis defined and no RNG override is set,settings.hmapsCUSTOM_RAND_GENERATEto uC/LIBMath_Rand().wc_GenerateSeed()then fills the whole DRBG seed from it, without any warning.Micrium has no entropy API, so
Math_Rand()stays as the fallback, which keeps existing builds compiling. The change makes the fallback visible.Fix (
wolfcrypt/src/random.c)settings.hno longer sets theMath_Randdefault forMICRIUM.random.cgains aMICRIUM && !CUSTOM_RAND_GENERATE_BLOCKarm ofwc_GenerateSeed(), next to the Deos arm and following the same pattern. It seeds fromMath_Rand()and emits a#warning(#pragma messageon MSVC/TASKING) namingCUSTOM_RAND_GENERATE_SEED.user_settings.handREADME.mddocument how to supply a hardware seed.Seed source per configuration:
MICRIUMonlyMath_Rand()+ build warningCUSTOM_RAND_GENERATE_SEED/_SEED_OS/CUSTOM_RAND_GENERATEWOLFSSL_SILABS_SE_ACCEL,STM32_RNGUSE_WINDOWS_APIsimulator, PIC32, Freescale RNGA/RNGB)Math_Rand()Closes f-16887.
Verification
random.cagainst the open-source Micrium headers (uC-OS3/CPU/LIB/Clk, POSIX port) for each override case: the warning fires only in the default case.lib_math.c:wc_GenerateSeed()output (19 bytes, odd tail) matches the LCG sequence from seed 1.testwolfcryptpass (MICRIUM not set).MICRIUM.