Cryptographic System Entropy Provider Header. More...
#include "common.h"
Go to the source code of this file.
Macros | |
#define | QSC_CSP_SEED_MAX 1024000ULL |
The maximum number of seed bytes that can be extracted from a single generate call. | |
Functions | |
QSC_EXPORT_API bool | qsc_csp_generate (uint8_t *output, size_t length) |
Retrieve pseudo-random bytes from the system entropy provider. | |
QSC_EXPORT_API uint16_t | qsc_csp_uint16 (void) |
Generate a random 16-bit unsigned integer. | |
QSC_EXPORT_API uint32_t | qsc_csp_uint32 (void) |
Generate a random 32-bit unsigned integer. | |
QSC_EXPORT_API uint64_t | qsc_csp_uint64 (void) |
Generate a random 64-bit unsigned integer. | |
Cryptographic System Entropy Provider Header.
This header provides the interface for the Cryptographic System Entropy Provider. It offers access to pseudo-random data generated by the system's entropy source. On Windows systems, the provider uses the CryptGenRandom API; on POSIX systems, it reads from the /dev/urandom device. In environments where arc4random_buf is available, that function is used directly.
Example Usage:
This provider is recommended to be combined with additional entropy sources to ensure robust randomness.
QSC_EXPORT_API bool qsc_csp_generate | ( | uint8_t * | output, |
size_t | length ) |
Retrieve pseudo-random bytes from the system entropy provider.
This function fills the provided output array with pseudo-random bytes sourced from the operating system's entropy mechanism. On Windows systems, it utilizes the CryptGenRandom function from the Windows API, whereas on Posix systems it reads from the /dev/urandom device. In environments supporting arc4random_buf, that function is used directly.
output | [uint8_t*] Pointer to the byte array where the random data will be stored. |
length | [size_t] The number of random bytes to generate. Must not exceed QSC_CSP_SEED_MAX. |
QSC_EXPORT_API uint16_t qsc_csp_uint16 | ( | void | ) |
Generate a random 16-bit unsigned integer.
This function generates a pseudo-random 16-bit unsigned integer by retrieving the appropriate number of bytes from the system entropy provider.
QSC_EXPORT_API uint32_t qsc_csp_uint32 | ( | void | ) |
Generate a random 32-bit unsigned integer.
This function generates a pseudo-random 32-bit unsigned integer by retrieving the appropriate number of bytes from the system entropy provider.
QSC_EXPORT_API uint64_t qsc_csp_uint64 | ( | void | ) |
Generate a random 64-bit unsigned integer.
This function generates a pseudo-random 64-bit unsigned integer by retrieving the appropriate number of bytes from the system entropy provider.