MCUXpresso SDK API Reference Manual  Rev 2.16.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
RNG: Random Number Generator

Overview

The MCUXpresso SDK provides a peripheral driver for the Random Number Generator module of MCUXpresso SDK devices.

The Random Number Generator is a hardware module that generates 32-bit random numbers. Internally it is accessed by calling ROM API. A typical consumer is a pseudo random number generator (PRNG) which can be implemented to achieve both true randomness and cryptographic strength random numbers using the RNG output as its entropy seed. The data generated by a RNG is intended for direct use by functions that generate secret keys, per-message secrets, random challenges, and other similar quantities used in cryptographic algorithms.

Get random data from RNG

  1. RNG_GetRandomData() function gets random data from the RNG module.

This example code shows how to get 128-bit random data from the RNG driver.

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/rng

Functions

status_t RNG_GetRandomData (void *data, size_t dataSize)
 Gets random data. More...
 
static uint32_t RNG_GetRandomDataWord (void)
 Gets random data. More...
 

Driver version

#define FSL_RNG_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))
 RNG driver version 2.1.0. More...
 

Macro Definition Documentation

#define FSL_RNG_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))

Current version: 2.1.0

Change log:

  • Version 2.0.0
    • Initial version.
  • Version 2.1.0
    • Renamed function RNG_GetRandomData() to RNG_GetRandomDataWord(). Added function RNG_GetRandomData() which discarding next 32 words after reading RNG register which results into better entropy, as is recommended in UM.
    • API is aligned with other RNG driver, having similar functionality as other RNG/TRNG drivers.

Function Documentation

status_t RNG_GetRandomData ( void *  data,
size_t  dataSize 
)

This function gets random data from the RNG.

Parameters
dataPointer address used to store random data.
dataSizeSize of the buffer pointed by the data parameter.
Returns
Status from operation
static uint32_t RNG_GetRandomDataWord ( void  )
inlinestatic

This function returns single 32 bit random number. For each read word next 32 words should be discarded to achieve better entropy.

Returns
random data