MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides a peripheral driver for the True Random Number Generator (TRNG) module of MCUXpresso SDK devices.
The True Random Number Generator is a hardware accelerator module that generates a 512-bit entropy as needed by an entropy consuming module or by other post processing functions. A typical entropy consumer is a pseudo random number generator (PRNG) which can be implemented to achieve both true randomness and cryptographic strength random numbers using the TRNG output as its entropy seed. The entropy generated by a TRNG is intended for direct use by functions that generate secret keys, per-message secrets, random challenges, and other similar quantities used in cryptographic algorithms.
This example code shows how to initialize and get random data from the TRNG driver.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/trng
Data Structures | |
struct | trng_statistical_check_limit_t |
Data structure for definition of statistical check limits. More... | |
struct | trng_config_t |
Data structure for the TRNG initialization. More... | |
Enumerations | |
enum | trng_sample_mode_t { kTRNG_SampleModeVonNeumann = 0U, kTRNG_SampleModeRaw = 1U, kTRNG_SampleModeVonNeumannRaw } |
TRNG sample mode. More... | |
enum | trng_clock_mode_t { kTRNG_ClockModeRingOscillator = 0U, kTRNG_ClockModeSystem = 1U } |
TRNG clock mode. More... | |
enum | trng_ring_osc_div_t { kTRNG_RingOscDiv0 = 0U, kTRNG_RingOscDiv2 = 1U, kTRNG_RingOscDiv4 = 2U, kTRNG_RingOscDiv8 = 3U } |
TRNG ring oscillator divide. More... | |
Functions | |
status_t | TRNG_GetDefaultConfig (trng_config_t *userConfig) |
Initializes the user configuration structure to default values. More... | |
status_t | TRNG_Init (TRNG_Type *base, const trng_config_t *userConfig) |
Initializes the TRNG. More... | |
void | TRNG_Deinit (TRNG_Type *base) |
Shuts down the TRNG. More... | |
status_t | TRNG_GetRandomData (TRNG_Type *base, void *data, size_t dataSize) |
Gets random data. More... | |
Driver version | |
#define | FSL_TRNG_DRIVER_VERSION (MAKE_VERSION(2, 0, 8)) |
TRNG driver version 2.0.8. More... | |
struct trng_statistical_check_limit_t |
Used by trng_config_t.
Data Fields | |
uint32_t | maximum |
Maximum limit. More... | |
uint32_t | minimum |
Minimum limit. More... | |
uint32_t trng_statistical_check_limit_t::maximum |
uint32_t trng_statistical_check_limit_t::minimum |
struct trng_config_t |
This structure initializes the TRNG by calling the TRNG_Init() function. It contains all TRNG configurations.
Data Fields | |
bool | lock |
Disable programmability of TRNG registers. More... | |
trng_clock_mode_t | clockMode |
Clock mode used to operate TRNG. More... | |
trng_ring_osc_div_t | ringOscDiv |
Ring oscillator divide used by TRNG. More... | |
trng_sample_mode_t | sampleMode |
Sample mode of the TRNG ring oscillator. More... | |
uint16_t | entropyDelay |
Entropy Delay. More... | |
uint16_t | sampleSize |
Sample Size. More... | |
uint16_t | sparseBitLimit |
Sparse Bit Limit which defines the maximum number of consecutive samples that may be discarded before an error is generated. More... | |
uint8_t | retryCount |
Retry count. More... | |
uint8_t | longRunMaxLimit |
Largest allowable number of consecutive samples of all 1, or all 0, that is allowed during the Entropy generation. More... | |
trng_statistical_check_limit_t | monobitLimit |
Maximum and minimum limits for statistical check of number of ones/zero detected during entropy generation. More... | |
trng_statistical_check_limit_t | runBit1Limit |
Maximum and minimum limits for statistical check of number of runs of length 1 detected during entropy generation. More... | |
trng_statistical_check_limit_t | runBit2Limit |
Maximum and minimum limits for statistical check of number of runs of length 2 detected during entropy generation. More... | |
trng_statistical_check_limit_t | runBit3Limit |
Maximum and minimum limits for statistical check of number of runs of length 3 detected during entropy generation. More... | |
trng_statistical_check_limit_t | runBit4Limit |
Maximum and minimum limits for statistical check of number of runs of length 4 detected during entropy generation. More... | |
trng_statistical_check_limit_t | runBit5Limit |
Maximum and minimum limits for statistical check of number of runs of length 5 detected during entropy generation. More... | |
trng_statistical_check_limit_t | runBit6PlusLimit |
Maximum and minimum limits for statistical check of number of runs of length 6 or more detected during entropy generation. More... | |
trng_statistical_check_limit_t | pokerLimit |
Maximum and minimum limits for statistical check of "Poker Test". More... | |
trng_statistical_check_limit_t | frequencyCountLimit |
Maximum and minimum limits for statistical check of entropy sample frequency count. More... | |
bool trng_config_t::lock |
trng_clock_mode_t trng_config_t::clockMode |
trng_ring_osc_div_t trng_config_t::ringOscDiv |
trng_sample_mode_t trng_config_t::sampleMode |
uint16_t trng_config_t::entropyDelay |
Defines the length (in system clocks) of each Entropy sample taken.
uint16_t trng_config_t::sampleSize |
Defines the total number of Entropy samples that will be taken during Entropy generation.
uint16_t trng_config_t::sparseBitLimit |
This limit is used only for during von Neumann sampling (enabled by TRNG_HAL_SetSampleMode()). Samples are discarded if two consecutive raw samples are both 0 or both 1. If this discarding occurs for a long period of time, it indicates that there is insufficient Entropy.
uint8_t trng_config_t::retryCount |
It defines the number of times a statistical check may fails during the TRNG Entropy Generation before generating an error.
uint8_t trng_config_t::longRunMaxLimit |
trng_statistical_check_limit_t trng_config_t::monobitLimit |
trng_statistical_check_limit_t trng_config_t::runBit1Limit |
trng_statistical_check_limit_t trng_config_t::runBit2Limit |
trng_statistical_check_limit_t trng_config_t::runBit3Limit |
trng_statistical_check_limit_t trng_config_t::runBit4Limit |
trng_statistical_check_limit_t trng_config_t::runBit5Limit |
trng_statistical_check_limit_t trng_config_t::runBit6PlusLimit |
trng_statistical_check_limit_t trng_config_t::pokerLimit |
trng_statistical_check_limit_t trng_config_t::frequencyCountLimit |
#define FSL_TRNG_DRIVER_VERSION (MAKE_VERSION(2, 0, 8)) |
Current version: 2.0.8
Change log:
enum trng_sample_mode_t |
Used by trng_config_t.
enum trng_clock_mode_t |
Used by trng_config_t.
enum trng_ring_osc_div_t |
Used by trng_config_t.
status_t TRNG_GetDefaultConfig | ( | trng_config_t * | userConfig | ) |
This function initializes the configuration structure to default values. The default values are as follows.
user_config | User configuration structure. |
status_t TRNG_Init | ( | TRNG_Type * | base, |
const trng_config_t * | userConfig | ||
) |
This function initializes the TRNG. When called, the TRNG entropy generation starts immediately.
base | TRNG base address |
userConfig | Pointer to the initialization configuration structure. |
void TRNG_Deinit | ( | TRNG_Type * | base | ) |
This function shuts down the TRNG.
base | TRNG base address. |
status_t TRNG_GetRandomData | ( | TRNG_Type * | base, |
void * | data, | ||
size_t | dataSize | ||
) |
This function gets random data from the TRNG.
base | TRNG base address. |
data | Pointer address used to store random data. |
dataSize | Size of the buffer pointed by the data parameter. |