8.3.1 Crypto_Rng_Generate
crypto_Rng_Status_E Crypto_Rng_Generate(
crypto_HandlerType_E rngHandlerType_en,
uint8_t *ptr_rngData,
uint32_t rngLen,
uint8_t *ptr_nonce,
uint32_t nonceLen,
uint32_t sessionID);
Description
This API is used to generate random numbers in blocks of bytes.
The provided PRNG entropy source is declared by the following function:
__attribute__((weak)) int Crypto_Rng_Wc_Prng_EntropySource(void);
This function is generic to all boards. As a result, the entropy can be
significantly improved by overriding the __attribute__((weak))
definition
with a custom function that better suits the board being developed for.
Parameters
No. | Argument Type | Argument Name | Type | Description |
---|---|---|---|---|
1 | crypto_HandlerType_E | rngHandlerType_en | Input | Enum for crypto operation handler i.e., SW, HW. |
2 | uint8_t* | ptr_rngData | Output | Pointer which holds generated random numbers in bytes. |
3 | uint32_t | rngLen | Input | Length of the random numbers in bytes. |
4 | uint8_t* | ptr_nonce | Input | Pointer Holds of nonce in bytes; It is optional. Pass it NULL when not required. |
5 | uint32_t | nonceLen | Input | Length of nonce length in bytes . It is optional pass it 0 when not required. |
6 | uint32_t | sessionID | Input | It defines the session ID, must be more than zero. |
Returns
Return Type | Description |
---|---|
crypto_Rng_Status_E | Function returns the status of the API. |
Example
#define sessionID 1
crypto_Kas_Status_E status;
crypto_HandlerType_E handlerType_en = CRYPTO_HANDLER_HW_INTERNAL;
uint8_t rngData[32];
uint32_t dataLen = sizeof(inputData);
uint8_t nonce[32] = {/*data*/};
uint32_t nonceLen = sizeof(nonce);
status = Crypto_Rng_Generate(
handlerType_en,
rngData,
dataLen,
nonce,
nonceLen,
sessionID
);