File syn_random.c¶
FileList > src > syntropic > util > syn_random.c
Go to the source code of this file
Random number utility implementation.
#include "syn_random.h"#include "../port/syn_port_system.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| SYN_WEAK SYN_Status | syn_port_random_fill (void * buf, size_t len) Porting hook: must be implemented by the platform to provide entropy. |
| SYN_Status | syn_random_fallback_fill (void * buf, size_t len) Internal: XOR-shift fallback for when no hardware entropy is available. |
| SYN_Status | syn_random_fill (void * buf, size_t len) Fill a buffer with cryptographically secure random bytes. |
| uint32_t | syn_random_range (uint32_t min, uint32_t max) Generate a random integer within a range [min, max]. |
| uint32_t | syn_random_u32 (void) Generate a random 32-bit integer. |
Public Functions Documentation¶
function syn_port_random_fill¶
Porting hook: must be implemented by the platform to provide entropy.
Parameters:
bufOutput buffer.lenNumber of bytes.
Returns:
SYN_OK on success.
function syn_random_fallback_fill¶
Internal: XOR-shift fallback for when no hardware entropy is available.
Internal XOR-shift fallback for random data.
Parameters:
bufOutput buffer.lenLength in bytes.
Returns:
SYN_OK.
function syn_random_fill¶
Fill a buffer with cryptographically secure random bytes.
This function relies on a platform-specific hardware RNG or secure OS source (via syn_port_random_fill).
Parameters:
bufOutput buffer.lenNumber of bytes to generate.
Returns:
SYN_OK on success, SYN_ERROR if the RNG is unavailable.
function syn_random_range¶
Generate a random integer within a range [min, max].
Parameters:
minMinimum value (inclusive).maxMaximum value (inclusive).
Returns:
Random value.
function syn_random_u32¶
Generate a random 32-bit integer.
Returns:
Random value, or 0 on failure (RNG check is recommended for sensitive use).
The documentation for this class was generated from the following file src/syntropic/util/syn_random.c