Posts

Showing posts with the label RNG

Building a Software RNG v1.0 with Timers, LFSR, XOR Shift, and FNV Hash algorithms

Image
Why a Software Random Number Generator? The STM32F401 microcontroller lacks a hardware Random Number Generator (RNG), making a Software RNG necessary for generating random numbers. While hardware RNGs provide higher-quality randomness, a Software RNG can still achieve essential functionality by generating unique cryptographic keys, mimicking real-world randomness, and introducing system unpredictability. How the Software RNG Generates Random Numbers The execution of the Software RNG begins by Generating a Hardware seed using the STM32 timers , providing a source of entropy based on system behavior. Then, a Linear Feedback Shift Register (LFSR) is applied to the seed to add a bit of randomness by shifting and modifying the seed value. The result of the LFSR operation is then combined with the hardware seed using the XOR (Exclusive OR) operation . Finally, the combined result is processed using the FNV Hash function, which generates a 32-bit random number. Extracting Hardware-based See...

Generating True Random Numbers | STM32L4 | RNG | CMSIS

Image
True Random Number Generator Randomness is necessary for cryptography operations to be unpredictable and to fend off attacks. We need randomization for everything from key generation to data encryption. We use True Random Number Generators, which create random numbers from an entropy source, to get around this predictability. The STM32L4's RNG peripheral is a true RNG that produces high-quality random numbers. The application is guaranteed to receive all entropy from its 32-bit samples via its built-in conditioning component and analog entropy generator. Read this blog on Random Number generators and their limitations  for more information. The RNG runs on two different clocks: the AHB bus clock and a dedicated RNG clock . The AHB clock is used to clock the AHB banked registers and conditioning components. The RNG clock is used for noise source sampling RNG Registers The RNG peripheral on the STM32L4S5xxx has few registers compared to that of STM32L4P5xxx and STM32L4Q5xxx mic...