Repository navigation
Random: stricter weak entropy source checks. Remove from default options on all builds. - #12065
danielinux wants to merge 7 commits into
Conversation
Zero-entropy (USE_TEST_GENSEED) and clock-seeded wc_GenerateSeed platform paths now #error at build time unless WOLFSSL_ACCEPT_WEAK_ENTROPY is defined. Adds --enable-weak-entropy to configure; in-tree sample configs that select a weak seed opt in explicitly. Related: F-7303, F-7425, F-8310.
Enable hardware entropy where supported and require an explicit seed source otherwise. Remove weak entropy opt-ins from the 12 affected configurations and STM32 templates, and reject timer-seeded PIC32MZ EC RNG by default.
|
There was a problem hiding this comment.
🟡 Changes recommended
RNG configuration regressions reject valid custom-block and disabled-RNG builds, select incompatible STM32 HAL APIs, and introduce unintended hardware crypto dependencies.
4 open issues
What changed in this PR
This PR hardens wolfCrypt entropy selection by requiring explicit acceptance of weak seed sources and updating embedded integrations to use hardware or application-provided entropy.
Changes:
- Adds compile-time weak-entropy guards and a
--enable-weak-entropyconfigure option. - Removes automatic test-seed selections from integration settings and preserves hardware RNG use where available.
- Fixes Cypress TRNG initialization failure handling and adds focused regression tests.
| File | Description |
|---|---|
wolfcrypt/src/random.c |
Adds entropy guards and reports Cypress TRNG initialization failures. |
tests/weak_entropy_defaults.py |
Checks integration defaults and weak-source opt-ins. |
tests/cypress_trng_failure.py |
Tests Cypress TRNG failure and success paths. |
tests/arduino_entropy_guard.py |
Tests Arduino entropy guards and custom-seed precedence. |
RTOS/nuttx/wolfssl/user_settings.h |
Requires STM32 hardware RNG or explicit seed configuration. |
RTOS/nuttx/wolfssl/README.md |
Documents seed requirements and version constraints. |
mcapi/user_settings.h |
Adds guidance for targets without a hardware TRNG. |
IDE/VS-AZURE-SPHERE/user_settings.h |
Adds custom-seed guidance. |
IDE/STM32Cube/README.md |
Documents hardware RNG retention and external seed requirements. |
IDE/STM32Cube/MX2/README.md |
Clarifies RNG independence from hardware acceleration. |
IDE/STM32Cube/MX2/mx_wolfSSL_parameters.json |
Updates the hardware-crypto option description. |
IDE/STM32Cube/MX2/mx_wolfSSL_conf_template.h.hbs |
Removes test defaults and retains hardware RNG in software-crypto mode. |
IDE/STM32Cube/default_conf.ftl |
Replaces test defaults with explicit seed requirements. |
IDE/STARCORE/user_settings.h |
Gates the example seed and preserves application overrides. |
IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h |
Requires opt-in for the predictable example seed. |
IDE/Renesas/e2studio/SK-S7G2/common/user_settings.h |
Requires an explicit source when SCE TRNG is disabled. |
IDE/Renesas/e2studio/RX72N/EnvisionKit/wolfssl_demo/user_settings.h |
Removes automatic test seeding without TSIP. |
IDE/Renesas/e2studio/RX65N/RSK/wolfssl_demo/user_settings.h |
Requires explicit seed configuration without TSIP. |
IDE/Renesas/e2studio/RX65N/GR-ROSE/common/user_settings.h |
Requires explicit seed configuration without TSIP. |
IDE/Renesas/e2studio/RA6M3/common/user_settings.h |
Requires an integrated SCE or custom entropy source. |
IDE/Renesas/e2studio/Projects/common/user_settings.h |
Removes automatic test seeding without TSIP. |
IDE/Renesas/e2studio/DK-S7G2/user_settings.h |
Requires an explicit source when SCE TRNG is disabled. |
IDE/Renesas/cs+/Projects/common/user_settings.h |
Replaces the test seed with custom-source guidance. |
IDE/qemu-falcon-neon/user_settings.h |
Makes deterministic RNG use explicitly opt-in. |
IDE/MSVS-2019-AZSPHERE/user_settings.h |
Adds custom-seed guidance. |
IDE/MPLABX16/user_settings.h |
Removes the PIC24 test-seed default. |
IDE/MDK5-ARM/Conf/user_settings.h |
Defaults to hardware RNG and gates test seeds. |
IDE/m33mu-falcon-verify/user_settings.h |
Makes deterministic RNG use explicitly opt-in. |
IDE/INTIME-RTOS/user_settings.h |
Documents entropy requirements for older INtime releases. |
IDE/IAR-MSP430/user_settings.h |
Gates timer-based seeding and preserves custom sources. |
IDE/IAR-EWARM/Projects/user_settings.h |
Removes the test-seed default and documents explicit opt-in. |
IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_SAMV71_XULT_user_settings/user_settings.h |
Adds custom-seed guidance. |
IDE/IAR-EWARM/embOS/custom_port/custom_port_user_settings/user_settings.h |
Adds custom-seed guidance. |
IDE/GCC-ARM/Header/user_settings.h |
Gates predictable example RNG hooks. |
IDE/ECLIPSE/RTTHREAD/user_settings.h |
Replaces test seeding with hardware-source guidance. |
IDE/C2000/user_settings.h |
Selects the oscillator-noise entropy source. |
IDE/C2000/compile.sh |
Includes noise-source code in the regular compile sweep. |
IDE/AURIX/user_settings.h |
Gates the predictable seed and preserves custom sources. |
examples/configs/user_settings_stm32.h |
Requires explicit entropy on devices without an RNG. |
examples/configs/user_settings_arduino.h |
Documents hardware entropy and weak-source opt-in. |
configure.ac |
Adds and reports the weak-entropy acceptance option. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Active moderate and critical findings show that the weak-entropy opt-in contract is blocked in generated configurations and bypassed by ungated VxWorks simulator and NetBurner fallback paths, while the added regression tests are not run in CI.
6 open issues
NetBurner weak-seed branch lacks opt-in guard · New VxWorks simulator weak-seed fallback bypasses opt-in · New STM32CubeMX2 template blocks weak-entropy opt-in · New Default STM32Cube config rejects weak-entropy opt-in · New STM32 seed guard rejects weak-entropy-only configuration · New Entropy regression tests are not run in CI · New
4 resolved since last review
Review effort: Lite
| #elif defined(CUSTOM_RAND_GENERATE_BLOCK) | ||
| /* The application supplies complete random blocks. No DRBG seed is used. */ |
| #ifndef WOLFSSL_ACCEPT_WEAK_ENTROPY | ||
| # error "WOLFSSL_VXWORKS 6.x tick-seeded rand_r is weak: provide a real entropy source; test only: define WOLFSSL_ACCEPT_WEAK_ENTROPY" | ||
| #endif |
| !defined(CUSTOM_RAND_GENERATE_BLOCK) && \ | ||
| !defined(CUSTOM_RAND_GENERATE) && !defined(WOLFSSL_GENSEED_FORTEST) |
| !defined(CUSTOM_RAND_GENERATE_BLOCK) && \ | ||
| !defined(CUSTOM_RAND_GENERATE) && !defined(WOLFSSL_GENSEED_FORTEST) |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12065
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): .github/configs/os-check-linux.json, .github/membrowse-targets.json, .github/workflows/arduino.yml, .github/workflows/pic32mz-sim.yml, .github/workflows/sbom.yml, .github/workflows/zephyr.yml, IDE/AURIX/user_settings.h, IDE/C2000/compile.sh, IDE/C2000/user_settings.h, IDE/ECLIPSE/RTTHREAD/user_settings.h, IDE/GCC-ARM/Header/user_settings.h, IDE/IAR-EWARM/Projects/user_settings.h, IDE/IAR-EWARM/embOS/SAMV71_XULT/embOS_SAMV71_XULT_user_settings/user_settings.h, IDE/IAR-EWARM/embOS/custom_port/custom_port_user_settings/user_settings.h, IDE/IAR-MSP430/user_settings.h, IDE/INTIME-RTOS/user_settings.h, IDE/MDK5-ARM/Conf/user_settings.h, IDE/MPLABX16/user_settings.h, IDE/MSVS-2019-AZSPHERE/user_settings.h, IDE/RISCV/SIFIVE-HIFIVE1/user_settings.h and 30 more
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Max
my_rng_generate_seed() funneled each pool byte through srand()/rand(), so every seed byte was a fixed function of exactly one pool byte: the libc stage added no entropy, its low 8 bits are not guaranteed one-to-one, and it used process-global non-reentrant state. Fill the output directly from the pool and add a source-level regression check alongside the PR 12065 entropy review tests.


Description
WOLFSSL_ACCEPT_WEAK_ENTROPYoption is enabled.WOLFSSL_ACCEPT_WEAK_ENTROPYor passing--enable-weak-entropyviaconfigureAddresses F-5990, F7303, F-7425, part of zd22758
Testing
Might require furter updates to examples / testing