TRNG driver implementation for the CC26XX family.
============================================================================
This file should only be included in the board file to fill the TRNG_config struct.
The CC26XX family has a dedicated hardware TRNG based on sampling multiple free running oscillators. With all FROs enabled, the TRNG hardware generates 64 bits of entropy approximately every 5ms. The driver implementation chains multiple 64-bit entropy generation operations together to generate an arbitrary amount of entropy.
The driver implementation does not perform runtime checks for most input parameters. Only values that are likely to have a stochastic element to them are checked (such as whether a driver is already open). Higher input paramter validation coverage is achieved by turning on assertions when compiling the driver.
#include <stdint.h>
#include <stdbool.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/TRNG.h>
#include <ti/drivers/cryptoutils/cryptokey/CryptoKey.h>
#include <ti/drivers/dpl/HwiP.h>
#include <ti/drivers/dpl/SwiP.h>
#include <ti/drivers/dpl/SemaphoreP.h>
Go to the source code of this file.
Data Structures | |
struct | TRNGCC26XX_HWAttrs |
TRNGCC26XX Hardware Attributes. More... | |
struct | TRNGCC26XX_Object |
TRNGCC26XX Object. More... | |
Macros | |
#define | TRNGCC26XX_SAMPLES_PER_CYCLE_MIN 256 |
Minimum random samples for each entropy generation call. More... | |
#define | TRNGCC26XX_SAMPLES_PER_CYCLE_DEFAULT 240000 |
Default random samples for each entropy generation call. More... | |
#define | TRNGCC26XX_SAMPLES_PER_CYCLE_MAX 16777216 |
Maximum random samples for each entropy generation call. More... | |
#define | TRNGCC26XX_MIN_BYTES_PER_ITERATION 8 |
Minimum number of bytes provided by the TRNG hardware in one go. Smaller amounts can by requested in driver calls but the full number will always be generated. Part of the generated entropy will simply not be copied back to the target buffer if the requested length is not a multiple of TRNGCC26XX_MIN_BYTES_PER_ISR. More... | |
Typedefs | |
typedef struct TRNGCC26XX_HWAttrs | TRNGCC26XX_HWAttrs |
TRNGCC26XX Hardware Attributes. More... | |
typedef struct TRNGCC26XX_Object | TRNGCC26XX_Object |
TRNGCC26XX Object. More... | |
Functions | |
int_fast16_t | TRNGCC26XX_setSamplesPerCycle (TRNG_Handle handle, uint32_t samplesPerCycle) |
Sets the number of entropy generation cycles before the results are returned. More... | |
TRNG_Handle | TRNGCC26XX_construct (TRNG_Config *config, const TRNG_Params *params) |
#define TRNGCC26XX_SAMPLES_PER_CYCLE_MIN 256 |
Minimum random samples for each entropy generation call.
#define TRNGCC26XX_SAMPLES_PER_CYCLE_DEFAULT 240000 |
Default random samples for each entropy generation call.
Set to generate 64 bits of randomness in 5ms with all FROs active.
#define TRNGCC26XX_SAMPLES_PER_CYCLE_MAX 16777216 |
Maximum random samples for each entropy generation call.
#define TRNGCC26XX_MIN_BYTES_PER_ITERATION 8 |
Minimum number of bytes provided by the TRNG hardware in one go. Smaller amounts can by requested in driver calls but the full number will always be generated. Part of the generated entropy will simply not be copied back to the target buffer if the requested length is not a multiple of TRNGCC26XX_MIN_BYTES_PER_ISR.
typedef struct TRNGCC26XX_HWAttrs TRNGCC26XX_HWAttrs |
TRNGCC26XX Hardware Attributes.
TRNG26X0 hardware attributes should be included in the board file and pointed to by the TRNG_config struct.
typedef struct TRNGCC26XX_Object TRNGCC26XX_Object |
TRNGCC26XX Object.
The application must not access any member variables of this structure!
int_fast16_t TRNGCC26XX_setSamplesPerCycle | ( | TRNG_Handle | handle, |
uint32_t | samplesPerCycle | ||
) |
Sets the number of entropy generation cycles before the results are returned.
The default value is set to generate 64 bits of entropy.
handle | A TRNGCC26XX handle returned from TRNGCC26XX_open |
samplesPerCycle | Number of 48MHz clock cycles to sample. Must be between 2^8 and 2^24. |
TRNG_Handle TRNGCC26XX_construct | ( | TRNG_Config * | config, |
const TRNG_Params * | params | ||
) |