RdRand Library
|
Public header for rdrand API. More...
Go to the source code of this file.
Defines | |
#define | RDRAND_SUCCESS 1 |
#define | RDRAND_NOT_READY -1 |
#define | RDRAND_SUPPORTED -2 |
#define | RDRAND_UNSUPPORTED -3 |
#define | RDRAND_SUPPORT_UNKNOWN -4 |
Typedefs | |
typedef unsigned __int16 | uint16_t |
typedef unsigned __int32 | uint32_t |
typedef unsigned __int64 | uint64_t |
Functions | |
int | rdrand_16 (uint16_t *x, int retry) |
Calls rdrand for a 16-bit result. | |
int | rdrand_32 (uint32_t *x, int retry) |
Calls rdrand for a 32-byte result. | |
int | rdrand_64 (uint64_t *x, int retry) |
Calls rdrand for a 64-byte result. | |
int | rdrand_get_n_64 (unsigned int n, uint64_t *x) |
Calls rdrand to obtain multiple 64-byte results. | |
int | rdrand_get_n_32 (unsigned int n, uint32_t *x) |
Calls rdrand to obtain multiple 32-byte results. | |
int | rdrand_get_bytes (unsigned int n, unsigned char *buffer) |
Calls rdrand to fill a buffer of arbitrary size with random bytes. |
Public header for rdrand API.
This is the public header for the rdrand API. It exposes the three public APIs, which access the rdrand instruction for various data sizes.
#define RDRAND_NOT_READY -1 |
The rdrand call was unsuccessful, the hardware was not ready, and a random number was not returned.
#define RDRAND_SUCCESS 1 |
The rdrand call was successful, the hardware was ready, and a random number was returned.
#define RDRAND_SUPPORT_UNKNOWN -4 |
Whether or not the hardware supports the rdrand instruction is unknown
#define RDRAND_SUPPORTED -2 |
The rdrand instruction is supported by the host hardware.
#define RDRAND_UNSUPPORTED -3 |
The rdrand instruction is unsupported by the host hardware.
typedef unsigned __int16 uint16_t |
typedef unsigned __int32 uint32_t |
typedef unsigned __int64 uint64_t |
Calls rdrand for a 16-bit result.
This function calls rdrand requesting a 16-bit result. By default, it will perform only a single call to rdrand, returning success or failure. On success, the data is written to memory pointed to by x. If the int retry is true (non-zero), the function will enter a loop with count=10 until rdrand succeeds, at which point it write the random data and return success, or fails This function also ensures that rdrand is supported by the cpu or fails gracefully.
x | pointer to memory to store the random result |
retry | int to determine whether or not to loop until rdrand succeeds or until 10 failed attempts |
Calls rdrand for a 32-byte result.
This function calls rdrand requesting a 32-bit result. By default, it will perform only a single call to rdrand, returning success or failure. On success, the data is written to memory pointed to by x. If the int retry is true (non-zero), the function will enter a loop with count=10 until rdrand succeeds, at which point it write the random data and return success, or fails This function also ensures that rdrand is supported by the cpu or fails gracefully.
x | pointer to memory to store the random result |
retry | int to determine whether or not to loop until rdrand succeeds or until 10 failed attempts |
Calls rdrand for a 64-byte result.
This function calls rdrand requesting a 64-byte result. By default, it will perform only a single call to rdrand, returning success or failure. On success, the data is written to memory pointed to by x. If the int retry is true (non-zero), the function will enter a loop with count=10 until rdrand succeeds, at which point it write the random data and return success, or fails This function also ensures that rdrand is supported by the cpu or fails gracefully.
x | pointer to memory to store the random result |
retry | int to determine whether or not to loop until rdrand succeeds or until 10 failed attempts |
int rdrand_get_bytes | ( | unsigned int | n, |
unsigned char * | buffer | ||
) |
Calls rdrand to fill a buffer of arbitrary size with random bytes.
This function calls rdrand requesting multiple 64- or 32-bit results to fill a buffer of arbitrary size.
n | size of the buffer to fill with random bytes |
buffer | pointer to memory to store the random result |
int rdrand_get_n_32 | ( | unsigned int | n, |
uint32_t * | x | ||
) |
Calls rdrand to obtain multiple 32-byte results.
This function calls rdrand requesting multiple 32-byte results. On success, the data is written to memory pointed to by x. This function calls rdrand_32 and if any of those invocations fail, this function fails. It returns the same values as rdrand_32.
int rdrand_get_n_64 | ( | unsigned int | n, |
uint64_t * | x | ||
) |
Calls rdrand to obtain multiple 64-byte results.
This function calls rdrand requesting multiple 64-byte results. On success, the data is written to memory pointed to by x. This function calls rdrand_64 and if any of those invocations fail, this function fails. It returns the same values as rdrand_64.