HRNG#


Introduction#

The Hardware Random Number Generator (HRNG) module provides a mechanism for generating random numbers that are crucial for cryptographic operations, secure communications, and simulations. HRNG supports both true random number generation and pseudo-random number generation modes.

Common use cases include:

  • Cryptographic Key Generation: Generating keys for encryption algorithms.

  • Secure Communication: Providing random numbers for session keys and data encryption.

  • Simulations and Randomization: Generating random inputs for simulations and randomized algorithms.

Configuration#

The HRNG module can be configured using the following parameters:

Modes:

  • Pseudo-random number: Pseudo-random number rely on mathematical algorithms to generate sequences of numbers that resemble randomness. These algorithms are deterministic, meaning they always produce the same sequence of numbers when initialized with the same starting value, referred to as a seed.

  • True Random Number : True Random Number create random numbers using physical processes like electronic noise, radioactive decay, or other unpredictable natural events.

The random number generator can be initialized, started, and stopped using the following functions:

Usage#

To use the HRNG module:

  1. Enable the HRNG peripheral clocks using sl_si91x_hrng_init.

  2. Start the HRNG using sl_si91x_hrng_start.

  3. Retrieve the random numbers using sl_si91x_hrng_get_bytes.

  4. Stop the HRNG using sl_si91x_hrng_stop.

  5. Disable the HRNG peripheral clocks using sl_si91x_hrng_deinit.

Enumerations#

enum
SL_SI91X_HRNG_TRUE_RANDOM = RSI_RNG_TRUE_RANDOM
SL_SI91X_HRNG_PSEUDO_RANDOM = RSI_RNG_PSEUDO_RANDOM
}

Enumeration for HRNG modes.

Typedefs#

typedef enum sl_si91x_hrng_mode

Enumeration for HRNG modes.

Functions#

sl_status_t

Initialize the HRNG peripheral.

sl_status_t
sl_si91x_hrng_start(sl_si91x_hrng_mode_t hrng_mode)

Start the Hardware Random Number Generator (HRNG).

sl_status_t
sl_si91x_hrng_get_bytes(uint32_t *random_bytes, uint8_t number_of_bytes)

Retrieve random bytes generated by the HRNG.

sl_status_t
sl_si91x_hrng_read_lfsr_input(uint8_t number_of_bytes, uint32_t *random_bytes)

Reads random data from the HRNG using the LFSR (Linear-Feedback Shift Register) input latch.

sl_status_t

Stop the Hardware Random Number Generator (HRNG).

sl_status_t

Disable the HRNG peripheral clocks.

Macros#

#define
SL_SI91X_HWRNG_CLK_ENABLE HWRNG_CLK_ENABLE

Enable clock for HWRNG.

#define

Maximum number of bytes that can be generated by the HWRNG.

#define

Minimum number of bytes that can be generated by the HWRNG.

Enumeration Documentation#

sl_si91x_hrng_mode#

sl_si91x_hrng_mode

Enumeration for HRNG modes.

This enumeration defines the modes in which the Hardware Random Number Generator (HRNG) can operate.

Enumerator
SL_SI91X_HRNG_TRUE_RANDOM

True random number generation mode.

SL_SI91X_HRNG_PSEUDO_RANDOM

Pseudo-random number generation mode.


Definition at line 54 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_hrng.h

Typedef Documentation#

sl_si91x_hrng_mode_t#

typedef enum sl_si91x_hrng_mode sl_si91x_hrng_mode_t

Enumeration for HRNG modes.

This enumeration defines the modes in which the Hardware Random Number Generator (HRNG) can operate.


Definition at line 57 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_hrng.h

Function Documentation#

sl_si91x_hrng_init#

sl_status_t sl_si91x_hrng_init (void )

Initialize the HRNG peripheral.

Parameters
N/A

This function initializes the HRNG peripheral, setting up the necessary configurations for random number generation. It must be called before any HRNG functionality can be utilized.

Returns

    • SL_STATUS_OK - if the initialization was successful.

    • SL_STATUS_FAIL - if the initialization failed due to an error.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 76 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_hrng.h

sl_si91x_hrng_start#

sl_status_t sl_si91x_hrng_start (sl_si91x_hrng_mode_t hrng_mode)

Start the Hardware Random Number Generator (HRNG).

Parameters
[in]hrng_mode

Mode for random number generation:

  • SL_SI91X_HRNG_TRUE_RANDOM: True random number generation.

  • SL_SI91X_HRNG_PSEUDO_RANDOM: Pseudo-random number generation.

This function starts the HRNG in the specified mode, allowing either true random or pseudo-random number generation based on the selected mode. It prepares the HRNG hardware to generate random numbers.

Returns

    • SL_STATUS_OK: Successfully started the HRNG.

    • SL_STATUS_INVALID_PARAMETER: Invalid mode or pointer.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 100 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_hrng.h

sl_si91x_hrng_get_bytes#

sl_status_t sl_si91x_hrng_get_bytes (uint32_t * random_bytes, uint8_t number_of_bytes)

Retrieve random bytes generated by the HRNG.

Parameters
[out]random_bytes

Buffer where the generated random bytes will be stored.

[in]number_of_bytes

The number of random bytes to read from the HRNG. The number of bytes must be within the range of 1 to 254.

This function reads a specified number of random bytes from the HRNG hardware and stores them in the provided buffer. It ensures that the requested number of bytes is fetched from the HRNG peripheral.

Returns

    • SL_STATUS_OK: Successfully retrieved the random bytes.

    • SL_STATUS_INVALID_PARAMETER: Invalid pointer or number of bytes.

    • SL_STATUS_FAIL: Failed to retrieve random bytes.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 129 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_hrng.h

sl_si91x_hrng_read_lfsr_input#

sl_status_t sl_si91x_hrng_read_lfsr_input (uint8_t number_of_bytes, uint32_t * random_bytes)

Reads random data from the HRNG using the LFSR (Linear-Feedback Shift Register) input latch.

Parameters
[in]number_of_bytes

The number of random bytes to read from the HRNG. The number of bytes must be within the range of 1 to 254.

[out]random_bytes

Pointer to an array where the random data will be stored.

This function reads random data from the HRNG using the LFSR input latch register. It first enables the LFSR, reads the specified number of bytes, and then disables the LFSR. Note

  • Data is valid only when the LFSR_32_BIT_INPUT_VALID bit is set.

Returns

    • SL_STATUS_OK: If the random data was read successfully.

    • SL_STATUS_FAIL: If there was an error reading the random data.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 157 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_hrng.h

sl_si91x_hrng_stop#

sl_status_t sl_si91x_hrng_stop (void )

Stop the Hardware Random Number Generator (HRNG).

Parameters
N/A

This function disables the HRNG by stopping the random number generation process and halting any ongoing operations within the HRNG peripheral.

Returns

    • SL_STATUS_OK: If the HRNG stopped successfully. For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 175 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_hrng.h

sl_si91x_hrng_deinit#

sl_status_t sl_si91x_hrng_deinit (void )

Disable the HRNG peripheral clocks.

Parameters
N/A

This function disables the HRNG clocks, effectively shutting down the HRNG peripheral to conserve power or halt its operations when not in use.

Returns

  • SL_STATUS_OK if the operation was successful. SL_STATUS_FAIL indicates that the operation failed due to an error.

For more information on status codes, see SL STATUS DOCUMENTATION.


Definition at line 194 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_hrng.h

Macro Definition Documentation#

SL_SI91X_HWRNG_CLK_ENABLE#

#define SL_SI91X_HWRNG_CLK_ENABLE
Value:
HWRNG_CLK_ENABLE

Enable clock for HWRNG.


Definition at line 44 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_hrng.h

SL_SI91X_HWRNG_MAX_BYTES#

#define SL_SI91X_HWRNG_MAX_BYTES
Value:
254

Maximum number of bytes that can be generated by the HWRNG.


Definition at line 46 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_hrng.h

SL_SI91X_HWRNG_MIN_BYTES#

#define SL_SI91X_HWRNG_MIN_BYTES
Value:
1

Minimum number of bytes that can be generated by the HWRNG.


Definition at line 47 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_hrng.h