Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Random Number Generation functions

Utility functions for generating random data. More...

Collaboration diagram for Random Number Generation functions:

Functions

void RAND_GetBytes (uint16_t aNumBytes, void *aBytesOut)
 Get random data for non-cryptographic purposes. More...
 
void RAND_Seed (uint64_t aSeed)
 Seed the non-cryptographic Pseudo Random Number Generator. More...
 
void RAND_SeedFromDev (struct ca821x_dev *pDeviceRef)
 Seed the non-cryptographic Pseudo Random Number Generator using entropy from the ca821x. More...
 
ca_error RAND_GetCryptoBytes (uint16_t aNumBytes, void *aBytesOut)
 Get random data for cryptographic purposes. More...
 
void RAND_AddRadioEntropySource (void)
 Add the radio-based RNG as an entropy source used by mbedTLS. More...
 

Detailed Description

Utility functions for generating random data.

Function Documentation

◆ RAND_AddRadioEntropySource()

void RAND_AddRadioEntropySource ( void  )

Add the radio-based RNG as an entropy source used by mbedTLS.

◆ RAND_GetBytes()

void RAND_GetBytes ( uint16_t  aNumBytes,
void *  aBytesOut 
)

Get random data for non-cryptographic purposes.

This function will never fail.

Depending on the platform this may be from a PRNG. Will fill memory starting from address aBytesOut with aNumBytes of pseudorandom random data. This data will be uniformly distributed, but not suitable for cryptographic purposes as the sequence can be predicted.

Parameters
aNumBytesThe number of bytes to fill with random data
[out]aBytesOutThe start address to fill with random data

◆ RAND_GetCryptoBytes()

ca_error RAND_GetCryptoBytes ( uint16_t  aNumBytes,
void *  aBytesOut 
)

Get random data for cryptographic purposes.

This function will use a CPRNG, and be suitable for cryptographic purposes. Will fill memory starting from address aBytesOut with aNumBytes of random data. Upon an error, the output memory will be left in an indeterminate state and should not be relied upon to be random data, or be in its previous state.

Parameters
aNumBytesThe number of bytes to fill with random data
[out]aBytesOutThe start address to fill with random data
Returns
Cascoda Error code
Return values
CA_ERROR_SUCCESSSuccess, aBytesOut is filled with aNumBytes of random data.
CA_ERROR_FAILRequest failed, aBytesOut is indeterminate

◆ RAND_Seed()

void RAND_Seed ( uint64_t  aSeed)

Seed the non-cryptographic Pseudo Random Number Generator.

It is required to call either this or RAND_SeedFromDev before using RAND_GetBytes or the sequence will be the same for different devices. This is handled within the initialisation functions for each platform.

Parameters
aSeedA seed for the PRNG. Should be unique, such as a random number or Unix time.

◆ RAND_SeedFromDev()

void RAND_SeedFromDev ( struct ca821x_dev pDeviceRef)

Seed the non-cryptographic Pseudo Random Number Generator using entropy from the ca821x.

It is required to call either this or RAND_Seed before using RAND_GetBytes or the sequence will be the same for different devices. This is handled within the initialisation functions for each platform.

Parameters
pDeviceRefThe CA821x device to use to source the entropy