Introduction
Many standards contain requirements and references for the extraction, validation, and use of random number generators
(RNGs), to verify that their output is indeed random.
This application note provides guidelines for verification of the randomness of numbers generated by the RNG peripheral
embedded in a selection of STM32 microcontrollers (MCUs). These MCUs are listed in Table 1. The verification is based either
on the NIST (national institute of standards and technology) SP 800-22rev1a (April 2010) or SP 800-90b (January 2018)
statistical test suite (STS).
This document is structured as follows:
A general introduction to the STM32 microcontroller random number generator. See Section 1.
The NIST SP800-22rev1a test suite. See Section 2.
The steps needed to run NIST SP800-22rev1a test and analysis. See Section 3.
The NIST SP800-90b test suite. See Section 4.
The steps needed to run the NIST SP800-90b test and analysis. See Section 3.
Table 1. Applicable products
Type
Products
Can be checked with SP800-22rev1a Can be checked with SP800-90b
Microcontrollers
Series
STM32F2 series, STM32F4 series, STM32F7 series,
STM32L0 series, STM32L4 series, STM32G4 series,
STM32WB series, STM32MP15x.
STM32WBA series, STM32H5 series, STM32L5
series, STM32U5 series, STM32MP13x, STM32WL
series.
Lines
STM32H742, STM32H743/753, STM32H745/755,
STM32H747/757 lines, STM32H750 value line,
STM32L4R5/S5, STM32L4R7/S7, STM32L4R9/S9 lines,
STM32G0x1 lines.
STM32H7A3/7B3 line, STM32H7B0 value line,
STM32H723/733, STM32H725/735, STM32H730
value line, STM32L4P5/Q5 line.
Introduction to random number generation validation using the NIST statistical
test suite for STM32 MCUs and MPUs
AN4230
Application note
AN4230 - Rev 9 - January 2024
For further information contact your local STMicroelectronics sales office.
www.st.com
1 STM32 MCU RNG
1.1 RNG overview
Random number generators (RNGs) used for cryptographic applications typically produce sequences made of
random 0’s and 1’s bits.
There are two basic classes of random number generators:
Deterministic RNG or pseudo RNG (PRNG)
A deterministic RNG consists of an algorithm that produces a sequence of bits from an initial value called a
seed. To ensure forward unpredictability, care must be taken in obtaining seeds. The values produced by a
PRNG are completely predictable if the seed and generation algorithm are known. Since in many cases the
generation algorithm is publicly available, the seed must be kept secret and generated from a TRNG.
Non-deterministic RNG or true RNG (TRNG)
A non-deterministic RNG produces randomness that depends on some unpredictable physical source
(the entropy source) outside of any human control.
The RNG hardware peripheral implemented in some STM32 MCUs is a true random number generator.
1.2 STM32 MCU implementation description
The table below lists the STM32 Arm
®
Cortex
®
core-based MCUs that embed the RNG peripheral.
Note: Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
Table 2. STM32 lines embedding the RNG hardware peripheral
Series
STM32 lines
STM32F2 series All lines
STM32F4 series
STM32F405/415, STM32F407/417, STM32F410, STM32F412, STM32F413/423,
STM32F427/437, STM32F429/439, STM32F469/479
STM32F7 series All lines
STM32L0 series STM32L05x, STM32L06x, STM32L072/073
STM32L4 series All lines
STM32L4+ series All lines
STM32H5 series All lines
STM32H7 series
All lines
(1)
STM32L5 series All lines
STM32U5 series All lines
STM32G0 series
STM32G081xB, STM32G041x6, STM32G041x8, STM32G061x6, STM32G061x8,
STM32G0C1xC, STM32G0C1xE
STM32G4 series All lines
STM32MP1 series All lines
STM32WBA series STM32WBA52
STM32WB series All lines
STM32WL series All lines
1. Except the following part numbers, which don't embed RNG peripherals: STM32H745BG, STM32H745XG, STM32H745ZG,
STM32H747AG, STM32H747AI, STM32H747BG, STM32H747IG, STM32H747II, STM32H747XG, STM32H757AI,
STM32H757II.
The true RNG implemented in the STM32 MCUs is based on an analog circuit. This circuit generates a
continuous analog noise that is used in the RNG processing to produce a 32-bit random number. The analog
circuit is made of several ring oscillators whose outputs are XORed.
AN4230
STM32 MCU RNG
AN4230 - Rev 9
page 2/28