Other cryptographic services
============================

.. _rng:

Random number generation
------------------------

.. function:: psa_generate_random

    .. summary::
        Generate random bytes.

    .. param:: uint8_t * output
        Output buffer for the generated data.
    .. param:: size_t output_size
        Number of bytes to generate and output.

    .. return:: psa_status_t
    .. retval:: PSA_SUCCESS
    .. retval:: PSA_ERROR_NOT_SUPPORTED
    .. retval:: PSA_ERROR_INSUFFICIENT_ENTROPY
    .. retval:: PSA_ERROR_INSUFFICIENT_MEMORY
    .. retval:: PSA_ERROR_COMMUNICATION_FAILURE
    .. retval:: PSA_ERROR_HARDWARE_FAILURE
    .. retval:: PSA_ERROR_CORRUPTION_DETECTED
    .. retval:: 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.

    .. 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.
