Day 13: Infineon’s Embedded Systems Summer Course (2024)
06/07/24: Today is the last day of the Infineon's embedded systems training program, next week there will be a hackathon to test our understanding of concepts done throughout the program.
What is True Random Number Generator?
A True Random Number Generator (TRNG) is a hardware component used in computing devices to generate random numbers. Unlike pseudo-random number generators, which use algorithms to produce sequences of numbers that only appear random, TRNGs rely on physical processes to generate truly random values.
In the PSoC 4100S Plus microcontroller, the TRNG utilizes up to six ring oscillators as its physical noise sources. A ring oscillator is a circuit composed of an odd number of inverters in a feedback loop, causing it to oscillate. Due to the inherent sensitivity of these inverters to temperature variations and other environmental factors, the oscillation includes a degree of jitter. This jitter introduces randomness into the system.
The TRNG process involves the following steps:
- Digitized Analog Signal (DAS) Generation: The oscillating signals from the ring oscillators are sampled to produce digitized analog signals. These DAS bits form the raw, initial source of entropy.
- Entropy Enhancement and Bias Reduction: The raw DAS bits are post-processed to enhance entropy and reduce bias. This involves two optional steps:
- Reduction Step: Combines multiple DAS bits to increase entropy.
- Von Neumann Correction: Reduces bias by processing pairs of bits (only producing output bits when there is a transition from 0 to 1 or from 1 to 0).
3. Bit Sample Collection: The post-processed bits are collected and shifted into a register to form random values of up to 32 bits.
Additionally, the TRNG supports different modes of operation using various types of ring oscillators:
- Fixed Ring Oscillators (RO11, RO15): These use a fixed number of inverters.
- Galois-based Ring Oscillators (GARO15, GARO31): These use a polynomial feedback mechanism, providing flexibility in the number of inverters and the structure of the oscillator.
- Fibonacci-based Ring Oscillators (FIRO15, FIRO31): Similar to Galois-based oscillators but with a different feedback mechanism.
When the TRNG functionality is disabled, the ring is “broken” to prevent unnecessary power consumption due to high switching activity. When enabled, the initial behavior of the ring oscillators is predictable, but as environmental factors affect them over time, they become reliable sources of physical noise.
This combination of physical noise sources and sophisticated post-processing techniques ensures that the TRNG provides high-quality random numbers suitable for cryptographic applications and other uses requiring true randomness
- The TRNG block is initialized with
Crypto_TRNG_Enable(CRYPTO)
. In the main loop, when theGEN
command is received via UART, random numbers are generated usingCrypto_Trng_Get_Random(CRYPTO, &rand_num_array[index], &TRNG_config)
and transmitted back to the terminal.
Simplified Explanation
- Ring Oscillators:
- The TRNG uses six types of ring oscillators (RO11, RO15, GARO15, GARO31, FIRO15, FIRO31).
- Each oscillator consists of a series of inverters connected in a loop, creating an oscillating signal.
- When started, these oscillators produce a signal that is inherently noisy due to environmental variations.
2. Sampling:
- The oscillating signals from the ring oscillators are sampled to create “Digitized Analog Samples” (DAS).
- This step converts the noisy analog oscillations into digital bits.
3. Post-Processing:
- Initial Delay: Ensures that only stable, reliable samples are processed.
- Clock: Synchronizes the sampling process.
- Von Neumann Corrector: A two-step process to:
- Increase Entropy: Combine multiple DAS bits to make them more random.
- Reduce Bias: Use pairs of bits to produce unbiased random bits (only transitions from 0 to 1 or 1 to 0 are considered).
4. Output:
- The processed random bits are collected into a shift register, producing a 32-bit true random number.
- The system checks if the generated random data meets the required bit size and stores the result.
Interesting Observations
- Diversity of Oscillators:
- Using different types of ring oscillators (fixed and Galois-based) increases the robustness and randomness of the TRNG.
2. Environmental Sensitivity:
- The reliance on environmental factors (like temperature) to introduce noise makes the TRNG unpredictable and thus truly random.
3. Entropy and Bias Correction:
- The two-step post-processing (entropy increase and bias reduction) ensures high-quality randomness, which is critical for cryptographic applications.
4 . Power Efficiency:
- When not in use, the ring oscillators are stopped to prevent unnecessary power consumption. This is achieved by “breaking” the ring to stop the oscillation.
5. Initial Delay for Stability:
- The initial delay allows the oscillators to stabilize, ensuring that only reliable random samples are used. This avoids the use of predictable initial behavior.
Modes of Operation and Ring Oscillators:
The TRNG relies on six ring oscillators, each with unique characteristics:
- Fixed Ring Oscillators:
- RO11: 11 inverters.
- RO15: 15 inverters.
2. Fixed Galois-Based Ring Oscillators:
- GAR015: 15 inverters.
3. Flexible Galois-Based Ring Oscillators:
- GAR031: Up to 31 inverters, with a programmable polynomial for feedback.
- FIRO31: Similar to GAR031 but based on a different configuration.
Differences and Need:
- Fixed vs. Flexible: Fixed oscillators have a set number of inverters, while flexible ones can be programmed for different lengths and feedback mechanisms.
- Galois-Based: These provide flexibility and programmability, useful for varied applications requiring different levels of randomness.
Imagine you need to generate random numbers for secure encryption. You could use a flexible Galois-based oscillator like GAR031, program it for the desired feedback polynomial, and get highly random output suitable for cryptographic keys.
Figure 19–4 illustrates the behavior of the Galois-based Ring Oscillator (GARO31) when it is stopped. In the stopped state, the programmable polynomial is set to ‘0’, effectively breaking the feedback loop that normally sustains oscillation. The figure shows two representations of the stopped state. On the left side, the inverters and XOR gates contributing to the feedback are marked with ‘X’, indicating that they are inactive and the feedback path is broken. This results in the output being a constant ‘0’, with no oscillation occurring. The right side further emphasizes this broken feedback loop, making it clear that the absence of feedback due to the polynomial being ‘0’ halts any oscillatory activity within the ring.
Figure 19–7 provides detailed examples of how different programmable polynomials affect the configuration and feedback mechanism of the Galois-based Ring Oscillator (GARO31). The top part of the figure shows a 7-bit polynomial, with the corresponding polynomial value 0x00000041 shifted left by 24 bits. This configuration uses a specific set of inverters and XOR gates to create the feedback path, resulting in a particular oscillation pattern. The bottom part of the figure illustrates a more complex 31-bit polynomial, with the polynomial value 0x04C11DB7. This configuration involves a larger number of inverters and XOR gates, showing a detailed and intricate feedback loop that dictates the oscillation behavior. These examples highlight the flexibility and programmability of Galois-based ring oscillators, demonstrating how varying the polynomial allows for the generation of diverse oscillation frequencies and patterns.
- Fixed Ring Oscillators: Best for simple, fixed-frequency applications.
- Galois Ring Oscillators: Offer high flexibility with programmable feedback, suitable for applications requiring variable oscillation frequencies and patterns.
- Fibonacci Ring Oscillators: Provide a fixed but different oscillation pattern compared to fixed ring oscillators, based on the Fibonacci sequence.
The difference table compares Fixed Ring Oscillators, Galois Ring Oscillators, and Fibonacci Ring Oscillators, highlighting their distinct features. Fixed Ring Oscillators have a simple design with a fixed number of inverters in a loop, leading to a fixed oscillation frequency. In contrast, Galois Ring Oscillators are highly flexible, using programmable polynomials to configure the feedback mechanism, allowing for various oscillation patterns and frequencies. Fibonacci Ring Oscillators also utilize a polynomial-based feedback system but follow a fixed polynomial related to the Fibonacci sequence, offering a different but less flexible oscillation pattern compared to Galois oscillators. The table underscores that fixed ring oscillators are best for simple, specific-frequency applications, while Galois oscillators are suitable for applications needing variable frequencies and patterns, and Fibonacci oscillators offer a middle ground with distinct fixed patterns.
That concludes the 14-week embedded systems training summer camp by infineon. Hope you all found these summaries useful if you did please leave a clap!. Thank you