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
PSA_ERROR_NOT_SUPPORTED
PSA_ERROR_INSUFFICIENT_ENTROPY
PSA_ERROR_INSUFFICIENT_MEMORY
PSA_ERROR_COMMUNICATION_FAILURE
PSA_ERROR_HARDWARE_FAILURE
PSA_ERROR_CORRUPTION_DETECTED
PSA_ERROR_BAD_STATE

The library has not been previously initialized by psa_crypto_init(). It is implementation-dependent whether a failure to initialize results in this error code.

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.