AOCL-SecureRNG API Guide#
AOCL-SecureRNG Version API#
get_secrngversion()#
-
const char *get_secrngversion(void)#
Returns AOCL-SecureRNG version string.
This function return pointer to a version string.
- Returns:
const char pointer to version string.
RDRAND Instruction#
is_RDRAND_supported()#
-
int is_RDRAND_supported(void)#
Checks support for RDRAND instruction.
This function checks if the target architecture supports RDRAND instruction.
- Returns:
Value indicating whether RDRAND is suuported or not. 1 - Success
get_rdrand16u()#
-
int get_rdrand16u(uint16_t *rng_val, unsigned int retry_count)#
Returns a single 16-bit value using RDRAND.
This function invokes RDRAND instruction to fetch a single 16-bit value.
On success, the value returned by RDRAND is written to rng_val.
On failure, the function retries invoking RDRAND retry_count times. Any failure after this, the function will return error.- Parameters:
rng_val – [out] Pointer to memory to store the value returned by RDRAND
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED
get_rdrand32u()#
-
int get_rdrand32u(uint32_t *rng_val, unsigned int retry_count)#
Returns a single 32-bit value using RDRAND.
This function invokes RDRAND instruction to fetch a single 32-bit value.
On success, the value returned by RDRAND is written to rng_val.
On failure, the function retries invoking RDRAND retry_count times. Any failure after this, the function will return error.- Parameters:
rng_val – [out] Pointer to memory to store the value returned by RDRAND
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED
get_rdrand64u()#
-
int get_rdrand64u(uint64_t *rng_val, unsigned int retry_count)#
Returns a single 64-bit value using RDRAND.
This function invokes RDRAND instruction to fetch a single 64-bit value.
On success, the value returned by RDRAND is written to rng_val.
On failure, the function retries invoking RDRAND retry_count times. Any failure after this, the function will return error.- Parameters:
rng_val – [out] Pointer to memory to store the value returned by RDRAND
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED
get_rdrand32u_arr()#
-
int get_rdrand32u_arr(uint32_t *rng_arr, unsigned int N, unsigned int retry_count)#
Returns an array of 32-bit values using RDRAND.
This function invokes RDRAND instruction N times to fetch an array of 32-bit values.
On success, the values are written to rng_arr.
On each failure, the function retries invoking RDRAND retry_count times. Any failure after this, the function will return error.- Parameters:
rng_arr – [out] Pointer to memory to store the values returned by RDRAND
N – [in] Number of random values to return
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED
get_rdrand64u_arr()#
-
int get_rdrand64u_arr(uint64_t *rng_arr, unsigned int N, unsigned int retry_count)#
Returns an array of 64-bit values using RDRAND.
This function invokes RDRAND instruction N times to fetch an array of 64-bit values.
On success, the values are written to rng_arr.
On each failure, the function retries invoking RDRAND retry_count times. Any failure after this, the function will return error.- Parameters:
rng_arr – [out] Pointer to memory to store the values returned by RDRAND
N – [in] Number of random values to return
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED
get_rdrand_bytes_arr()#
-
int get_rdrand_bytes_arr(unsigned char *rng_arr, unsigned int N, unsigned int retry_count)#
Returns an array of random bytes of the given size using RDRAND.
This function invokes RDRAND instruction multiple times to fetch an array of random bytes of given size.
On success, the values are written to rng_arr.
On failure, it returns error.- Parameters:
rng_arr – [out] Pointer to memory to store the random bytes
N – [in] Number of random bytes to return
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED
RDSEED Instruction#
is_RDSEED_supported()#
-
int is_RDSEED_supported(void)#
Checks support for RDSEED instruction.
This function checks if the target architecture supports RDSEED instruction.
- Returns:
Value indicating whether RDSEED is suuported or not. 1 - Success
get_rdseed16u()#
-
int get_rdseed16u(uint16_t *rng_val, unsigned int retry_count)#
Returns a single 16-bit value using RDSEED.
This function invokes RDSEED instruction to fetch a single 16-bit value.
On success, the value returned by RDSEED is written to rng_val.
On failure, the function retries invoking RDSEED retry_count times. Any failure after this, the function will return error.- Parameters:
rng_val – [out] Pointer to memory to store the value returned by RDSEED
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED
get_rdseed32u()#
-
int get_rdseed32u(uint32_t *rng_val, unsigned int retry_count)#
Returns a single 32-bit value using RDSEED.
This function invokes RDSEED instruction to fetch a single 32-bit value.
On success, the value returned by RDSEED is written to rng_val.
On failure, the function retries invoking RDSEED retry_count times. Any failure after this, the function will return error.- Parameters:
rng_val – [out] Pointer to memory to store the value returned by RDSEED
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED
get_rdseed64u()#
-
int get_rdseed64u(uint64_t *rng_val, unsigned int retry_count)#
Returns a single 64-bit value using RDSEED.
This function invokes RDSEED instruction to fetch a single 64-bit value.
On success, the value returned by RDSEED is written to rng_val.
On failure, the function retries invoking RDSEED retry_count times. Any failure after this, the function will return error.- Parameters:
rng_val – [out] Pointer to memory to store the value returned by RDSEED
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED
get_rdseed32u_arr()#
-
int get_rdseed32u_arr(uint32_t *rng_arr, unsigned int N, unsigned int retry_count)#
Returns an array of 32-bit values using RDSEED.
This function invokes RDSEED instruction N times to fetch an array of 32-bit values.
On success, the values are written to rng_arr.
On each failure, the function retries invoking RDSEED retry_count times. Any failure after this, the function will return error.- Parameters:
rng_arr – [out] Pointer to memory to store the values returned by RDSEED
N – [in] Number of random values to return
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED
get_rdseed64u_arr()#
-
int get_rdseed64u_arr(uint64_t *rng_arr, unsigned int N, unsigned int retry_count)#
Returns an array of 64-bit values using RDSEED.
This function invokes RDSEED instruction N times to fetch an array of 64-bit values.
On success, the values are written to rng_arr.
On each failure, the function retries invoking RDSEED retry_count times. Any failure after this, the function will return error.- Parameters:
rng_arr – [out] Pointer to memory to store the values returned by RDSEED
N – [in] Number of random values to return
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED
get_rdseed_bytes_arr()#
-
int get_rdseed_bytes_arr(unsigned char *rng_arr, unsigned int N, unsigned int retry_count)#
Returns an array of random bytes of the given size using RDSEED.
This function invokes RDSEED instruction multiple times to fetch an array of random bytes of given size.
On success, the values are written to rng_arr.
On failure, it returns error.- Parameters:
rng_arr – [out] Pointer to memory to store the random bytes
N – [in] Number of random bytes to return
retry_count – [in] Number of retry attempts
- Returns:
success or failure status of function call: SECRNG_SUCCESS, SECRNG_FAILURE, SECRNG_NOTSUPPORTED