Modify os.urandom() to return false for no entropy - #11185
Closed
ladyada wants to merge 1 commit into
Closed
Conversation
Update os.urandom() to fail closed when no secure entropy is available.
Collaborator
|
I would rather close this in favor of #11184 |
There was a problem hiding this comment.
Pull request overview
This PR changes the CXD56 port’s common_hal_os_urandom() implementation to fail closed when no secure entropy source is available, ensuring os.urandom() raises NotImplementedError instead of returning deterministic bytes.
Changes:
- Replaced the previous
rand()-based buffer fill with an unconditionalfalsereturn to indicate no secure RNG is available. - Added rationale in comments explaining the security implications and intended behavior.
Suppressed comments (1)
ports/cxd56/common-hal/os/init.c:22
- The statement "broadcom, silabs and litex ports, which also lack a hardware RNG" is potentially misleading: those ports currently return false from common_hal_os_urandom(), but that doesn’t necessarily imply the underlying silicon has no RNG. Rewording this to describe the implementation behavior (returning false) avoids over-claiming about hardware capabilities.
// rather than silently returning non-random data. This matches the broadcom,
// silabs and litex ports, which also lack a hardware RNG.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+15
to
+17
| // source. That is the same class of defect behind the 2026 Coldcard wallet | ||
| // key-recovery incident, where a silent PRNG fallback stood in for hardware | ||
| // entropy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update os.urandom() to fail closed when no secure entropy is available.