Radio (RAIL) Entropy Source PluginRandom number generator (RNG) module

Detailed Description

Collect entropy from Radio Abstraction and Interface Layer (RAIL) on Silicon Labs EFR32 devices.

This RAIL entropy module implements an entropy source plugin module for mbedTLS that can be used in applications needing random numbers or indirectly using mbedTLS modules that depend on the random number generation interfaces of mbed TLS.

The configuration #define MBEDTLS_ENTROPY_RAIL_C will compile the this module.

The configuration #defines MBEDTLS_ENTROPY_RAIL_C, MBEDTLS_ENTROPY_HARDWARE_ALT and MBEDTLS_ENTROPY_HARDWARE_ALT_RAIL will compile the mbedtls_hardware_poll() function implemented in this module. This will automatically register the rail entropy module as the default hardware entropy source during runtime initialization.

Note
The user is responsible for initializing the radio properly before calling into mbedtls API functions that will use the RAIL entropy module. Normally the radio initialization is performed by calling the RAIL API. The wireless stacks from Silicon Labs perform radio initialization internally, in which case the user should just make sure the wireless stacks initializes before user code can call into mbedtls API functions that will use the RAIL entropy module.

Data Structures

struct  mbedtls_entropy_rail_context
 RAIL entropy context structure.
 

Functions

void mbedtls_entropy_rail_init (mbedtls_entropy_rail_context *ctx)
 Initialize a RAIL entropy context.
 
void mbedtls_entropy_rail_free (mbedtls_entropy_rail_context *ctx)
 Free RAIL entropy context.
 
int mbedtls_entropy_rail_poll (mbedtls_entropy_rail_context *ctx, unsigned char *output, size_t len, size_t *olen)
 Poll for entropy data.
 

Function Documentation

void mbedtls_entropy_rail_free ( mbedtls_entropy_rail_context ctx)

Free RAIL entropy context.

This function will clear the RAIL entropy context.

Parameters
ctxRAIL entropy context to be clear.
void mbedtls_entropy_rail_init ( mbedtls_entropy_rail_context ctx)

Initialize a RAIL entropy context.

This function will initialize a RAIL entropy context.

Parameters
ctxRAIL entropy context to be initialized
int mbedtls_entropy_rail_poll ( mbedtls_entropy_rail_context ctx,
unsigned char *  output,
size_t  len,
size_t *  olen 
)

Poll for entropy data.

This function will request entropy data from the RAIL API and place it into the output buffer. The len parameter tells this function the maximum number of bytes to read.

Note that the number of bytes read might differ from the number of bytes requested.

The return value should be used to see if the operation was successful of if an error was encountered. The content of the olen parameter can be used to check how many bytes were actually read.

Parameters
ctxRAIL entropy context
outputBuffer to fill with entropy data from RAIL
lenMaximum number of bytes to fill in output buffer.
olenThe actual amount of bytes put into the buffer (Can be 0)
Returns
0 for success, or MBEDTLS_ERR_ENTROPY_SOURCE_FAILED if len is higher than the max RAIL entropy buffer size.