Implementation of hardware RNGs on MCUs #16420
-
Hi guys, I needed to generate random numbers several weeks ago and so I pulled out my RP2040 to do this. And then you know what it is, from thread to needle, I jumped on my esp32 and so on. In fact I realized that the hardware RNG part wasn't there, so I started working on it. I have been rummaging through the docs and I have coded the calls to the correct registers. Question, I had fun on the PyBoard with 'pyb.rng()'. Does it call on the STM32 hardware RNG ? I didn't go to check. ESP32 Note: For the Tensy, I am not able to implement the TRNG ... I used several ADC to generate values instead. Cheers. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 26 replies
-
All three ports you mention support already a hardware TRNG with the |
Beta Was this translation helpful? Give feedback.
-
Hi Robert, Pseudo RNG ... sorry but If I have read the ESP32 docs correctly, they are hardware RNG, not pseudo-random. Now for |
Beta Was this translation helpful? Give feedback.
-
As said, the MicroPython module uses a Pseudo RNG in all ports.
Maybe more. In order to tell, whether a certain MCU uses a TRNG, look whether |
Beta Was this translation helpful? Give feedback.
-
You're sure about that ? |
Beta Was this translation helpful? Give feedback.
-
And right you are !Raspberry Pi Pico Datasheet - Build-date: 2024-10-15 / Build-version: eec2b0c-clean Chapter 2.17. Ring Oscillator (ROSC) - Page 222.My datasheet was stamped Build-date 2023-06-14 Build-version a6fe703-clean ... My bad !:-( The ROSC is the internal oscillator that can be used to generate random numbers indeed. In initial method (with ADC), it reached a 3.437 bits per byte entropy. |
Beta Was this translation helpful? Give feedback.
-
I have prepared a paper on RNGs and their application. Well, it's in French at the moment... I still haven't finished translating it completely. I will publish it later this week on my page. I am also working on a small high entropy TRNG project (MCU + amp. + capacitors + resistors). |
Beta Was this translation helpful? Give feedback.
-
Guten Morgen Robert, I'm not going to open a new thread because the topic is related to RNGs. I am implementing my RNG code on ESP32-S3-DevKitC-1 v 1.1. By reading the Technical Reference Manual version 1.6 for ESP32-S3, page 921, the memory address of the register 'RNG_DATA_REG' is indicated as being: 0x6003_3110 I have tried everything possible, but the result was always nill. So I have decided to go fishing for information on the Espressif website, in their source code. I finally found what I was looking for here (within the wdev_reg.h include file) : I have tried this address and now it works perfectly. So, question: Can anyone here confirm or deny that the address
|
Beta Was this translation helpful? Give feedback.
As said, the MicroPython module uses a Pseudo RNG in all ports.
os.urandom()
is based on a True RNG (hardware), but not supported by all ports and MCUs.Ports that uses a TRNG with os.urandom():
Maybe more. In order to tell, whether a certain MCU uses a TRNG, look whether
os.urandom()
exists.