Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raspberrypi: implement os.urandom #4213

Merged
merged 1 commit into from
Feb 18, 2021
Merged

Conversation

jepler
Copy link
Member

@jepler jepler commented Feb 17, 2021

Since the datasheet cast some doubt on the strength of the "rosc_hw->randombit", I use the SHA256 hash function to create a high quality random seed from random values of uncertain entropy, as well as to generate a sequence of random values from that seed using SHA256 as a cryptographically-secure random number generator.

image

In practice, it produces over 100kB/s of random data which does not have any gross problems according to PractRand (analyzing limited amounts of data, about 16 megabytes). Most uses for urandom in CircuitPython (across the Adafruit bundle, Community bundle and the Learn system) are not security-critical; however, it is used in an implementation of RSA which is crypto-strength.

Closes #4196.

Since the datasheet cast some doubt on the strength of the "rosc_hw->randombit",
I use the SHA256 hash function to create a high quality random seed
from random values of uncertain entropy, as well as to generate a sequence
of random values from that seed using SHA256 as a cryptographically-secure
random number generator.

In practice, it produces over 100kB/s of random data which does not
have any gross problems according to _PractRand_.
@jepler jepler force-pushed the raspberrypi-urandom2 branch from df8dcc5 to ab5eb86 Compare February 17, 2021 23:49
@jepler
Copy link
Member Author

jepler commented Feb 18, 2021

@joelburton please check this out. You should be able to download a uf2 with this feature enabled here: https://github.com/adafruit/circuitpython/suites/2064177672/artifacts/41696731 -- if you get a chance to test with it, let us know the result.

@tannewt tannewt self-requested a review February 18, 2021 18:35
@tannewt tannewt added enhancement rp2040 Raspberry Pi RP2040 labels Feb 18, 2021
@tannewt tannewt added this to the 6.2.0 milestone Feb 18, 2021
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt tannewt merged commit e29178c into adafruit:main Feb 18, 2021
@joelburton
Copy link

@jepler : works great for me; thanks for your help here, everyone! <3

@jepler jepler deleted the raspberrypi-urandom2 branch November 3, 2021 21:10
kattni pushed a commit to kattni/circuitpython that referenced this pull request Mar 10, 2022
The new ADC methods are: init(), read_uv() and block().

The new ADCBlock class has methods: init() and connect().

See related discussions in adafruit#3943, adafruit#4213.

Signed-off-by: Damien George <damien@micropython.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement rp2040 Raspberry Pi RP2040
Projects
None yet
Development

Successfully merging this pull request may close these issues.

os.urandom for Pico/RP2040 not supported
3 participants