10.10. Other cryptographic services
10.10.1. Random number generation
psa_generate_random (function)
Generate random bytes.
psa_status_t psa_generate_random(uint8_t * output, size_t output_size);
Parameters
-
output - Output buffer for the generated data.
-
output_size - Number of bytes to generate and output.
Returns: psa_status_t
-
PSA_SUCCESS - Success.
outputcontainsoutput_sizebytes of generated random data. -
PSA_ERROR_BAD_STATE - The library requires initializing by a call to
psa_crypto_init(). -
PSA_ERROR_NOT_SUPPORTED -
PSA_ERROR_INSUFFICIENT_ENTROPY -
PSA_ERROR_INSUFFICIENT_MEMORY -
PSA_ERROR_COMMUNICATION_FAILURE -
PSA_ERROR_CORRUPTION_DETECTED
Description
Warning
This function can fail! Callers MUST check the return status and MUST NOT use the content of the output buffer if the return status is not PSA_SUCCESS.
Note
To generate a key, use psa_generate_key() instead.