3.6.2. Functions - 5.2 English - 68552

AOCL API Guide (68552)

Document ID
68552
Release Date
2025-12-29
Version
5.2 English
alc_error_t alcp_rng_supported(const alc_rng_info_p pRngInfo)#

Query Library if the given configuration is supported.

This API needs to be called before any other API is called to know if RNG that is being request is supported or not

Parameters:

pRngInfo[in] Pointer to alc_rng_info_t structure

Returns:

Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE, an error has occurred and handle will be invalid for future operations

Uint64 alcp_rng_context_size(const alc_rng_info_p pRngInfo)#

Get the context/session size.

This API should be called before alcp_rng_request to identify the memory to be allocated for context

Note

User is expected to allocate for the session this function returns size to be allocated

Parameters:

pRngInfo[in] Pointer to RNG configuration

Returns:

Uint64 Size of RNG context in bytes

alc_error_t alcp_rng_request(const alc_rng_info_p pRngInfo, alc_rng_handle_p pRngHandle)#

Request an handle for given RNG configuration.

This API can be called after alcp_rng_supported and before alcp_rng_finish

Note

Requested algorithm may be first checked using alcp_rng_context_size and pHandle as allocated by user.

Parameters:
  • pRngInfo[in] Pointer to RNG configuration

  • pRngHandle[out] Library populated session handle for future rng operations.

Returns:

Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE, an error has occurred and handle will be invalid for future operations

alc_error_t alcp_rng_gen_random(alc_rng_handle_p pRngHandle, Uint8 *pBuf, Uint64 size)#

Generate and fill buffer with random numbers.

This API can be called after alcp_rng_request and alcp_rng_init if hardware RNG requires it and before alcp_rng_finish

Parameters:
  • pRngHandle[in] Pointer to handle

  • pBuf[out] Output buffer to be filled with random numbers

  • size[in] Size of pBuf in bytes

Returns:

Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE, an error has occurred and handle will be invalid for future operations

alc_error_t alcp_rng_init(alc_rng_handle_p pRngHandle)#

Initialize a random number generator.

This API can be called after alcp_rng_request and before alcp_rng_finish

Note

Some hardware RNGs require initialization

Parameters:

pRngHandle[in] Pointer to handle returned by alcp_rng_request()

Returns:

Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE, an error has occurred and handle will be invalid for future operations

alc_error_t alcp_rng_seed(alc_rng_handle_p pRngHandle, const Uint8 *seed, Uint64 size)#

Seed a PRNG (or other RNG if supported)

This API can be called after alcp_rng_request and alcp_rng_init if hardware RNG requires it. This API is called to reset data so should be called after alcp_rng_request and before alcp_rng_finish

Parameters:
  • pRngHandle[in] Pointer to user allocated handle

  • seed[in] Pointer to seed

  • size[in] Length of seed in bytes

Returns:

Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE, an error has occurred and handle will be invalid for future operations

alc_error_t alcp_rng_finish(alc_rng_handle_p pRngHandle)#

Complete a session.

This API is called to free resources so should be called to free the session

Note

Completes the session which was previously requested using alcp_rng_request

Parameters:

pRngHandle[in] Pointer to handle

Returns:

Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE, an error has occurred and handle will be invalid for future operations