10.12 Other cryptographic services¶
10.12.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.
output
containsoutput_size
bytes 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_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 random key, use psa_generate_key()
or psa_generate_key_custom()
instead.