summaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorrobert-hh <robert@hammelrath.com>2021-03-17 07:57:27 +0100
committerDamien George <damien@micropython.org>2021-04-09 18:24:38 +1000
commit6f06dcaee57cc6f36a4121b4797942200b2d7281 (patch)
tree40232133adb469942f145d3fd5bdb8a8ca6eecd5 /py/runtime.c
parent2c9af1c1d7398bb340f7c78601be6ed2d79ee0b8 (diff)
rp2/moduos: Implement uos.urandom().
The implementation samples rosc.randombits at a frequency lower than the oscillator frequency. This gives better random values. In addition, for an 8-bit value 8 samples are taken and fed through a 8-bit CRC, distributing the sampling over the byte. The resulting sampling rate is about 120k/sec. The RNG does not include testing of error conditions, like the ROSC being in sync with the sampling or completely failing. Making the interim value static causes it to perform a little bit better in short sync or drop-out situations. The output of uos.urandom() performs well with the NIST800-22 test suite. In my trial it passed all tests of the sts 2.1.2 test suite. I also ran a test of the random data with the Common Criteria test suite AIS 31, and it passed all tests too.
Diffstat (limited to 'py/runtime.c')
0 files changed, 0 insertions, 0 deletions