ricardgb opened a new pull request, #19557:
URL: https://github.com/apache/nuttx/pull/19557
## Summary
Follow-up to the rp23xx hardware TRNG driver added in 52e84e0c0a. Two
robustness gaps in the entropy path:
1. **Health-test failures were served as entropy.** The read waited for
`EHR_VALID` and copied the block out without checking `RNG_ISR`, so a
sample that failed the CryptoCell von-Neumann / CRNGT / autocorrelation
test was returned regardless. Now a failed block is discarded and the
source re-armed; only a block that passed is returned.
2. **No startup check.** A small self-test draws a few conditioned blocks at
registration; if the source is stuck (identical blocks) it latches
`/dev/random` and `/dev/urandom` to fail with `-EIO` instead of emitting
predictable output that would silently weaken every derived key.
The read path is factored through a small `rp23xx_rng_collect()` helper
shared by the self-test.
## Impact
- rp23xx only. No API or config change (same `CONFIG_RP23XX_RNG`).
- Healthy hardware is unaffected: passing blocks are returned as before.
- A broken/stuck TRNG now fails closed (`-EIO`) rather than returning weak
entropy.
## Testing
- Built `raspberrypi-pico-2:nsh` with `CONFIG_RP23XX_RNG=y`,
`CONFIG_DEV_RANDOM=y`, `CONFIG_DEV_URANDOM_ARCH=y` (arm-none-eabi-gcc
13.2);
`tools/checkpatch.sh -c -u -m -g` passes.
- On healthy silicon the read path is unchanged from 52e84e0c0a (passing
blocks only); the failure paths (`RNG_ISR` error, stuck source) cannot be
forced on real hardware but are exercised by the discard/re-arm and
self-test logic on every read/registration.
---
*Changes made with an AI agent, human-reviewed.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]