Changeset View
Changeset View
Standalone View
Standalone View
head/sys/sys/random.h
Show All 31 Lines | |||||
#define _SYS_RANDOM_H_ | #define _SYS_RANDOM_H_ | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
struct uio; | struct uio; | ||||
#if defined(DEV_RANDOM) | |||||
void read_random(void *, u_int); | void read_random(void *, u_int); | ||||
int read_random_uio(struct uio *, bool); | int read_random_uio(struct uio *, bool); | ||||
bool is_random_seeded(void); | bool is_random_seeded(void); | ||||
#else | |||||
static __inline int | |||||
read_random_uio(void *a __unused, u_int b __unused) | |||||
{ | |||||
return (0); | |||||
} | |||||
static __inline void | |||||
read_random(void *a __unused, u_int b __unused) | |||||
{ | |||||
} | |||||
static __inline bool | |||||
is_random_seeded(void) | |||||
{ | |||||
return (false); | |||||
} | |||||
#endif | |||||
/* | /* | ||||
* Note: if you add or remove members of random_entropy_source, remember to | * Note: if you add or remove members of random_entropy_source, remember to | ||||
* also update the strings in the static array random_source_descr[] in | * also update the strings in the static array random_source_descr[] in | ||||
* random_harvestq.c. | * random_harvestq.c. | ||||
*/ | */ | ||||
enum random_entropy_source { | enum random_entropy_source { | ||||
RANDOM_START = 0, | RANDOM_START = 0, | ||||
Show All 28 Lines | enum random_entropy_source { | ||||
ENTROPYSOURCE | ENTROPYSOURCE | ||||
}; | }; | ||||
_Static_assert(ENTROPYSOURCE <= 32, | _Static_assert(ENTROPYSOURCE <= 32, | ||||
"hardcoded assumption that values fit in a typical word-sized bitset"); | "hardcoded assumption that values fit in a typical word-sized bitset"); | ||||
#define RANDOM_LEGACY_BOOT_ENTROPY_MODULE "/boot/entropy" | #define RANDOM_LEGACY_BOOT_ENTROPY_MODULE "/boot/entropy" | ||||
#define RANDOM_CACHED_BOOT_ENTROPY_MODULE "boot_entropy_cache" | #define RANDOM_CACHED_BOOT_ENTROPY_MODULE "boot_entropy_cache" | ||||
#if defined(DEV_RANDOM) | |||||
extern u_int hc_source_mask; | extern u_int hc_source_mask; | ||||
void random_harvest_queue_(const void *, u_int, enum random_entropy_source); | void random_harvest_queue_(const void *, u_int, enum random_entropy_source); | ||||
void random_harvest_fast_(const void *, u_int); | void random_harvest_fast_(const void *, u_int); | ||||
void random_harvest_direct_(const void *, u_int, enum random_entropy_source); | void random_harvest_direct_(const void *, u_int, enum random_entropy_source); | ||||
static __inline void | static __inline void | ||||
random_harvest_queue(const void *entropy, u_int size, enum random_entropy_source origin) | random_harvest_queue(const void *entropy, u_int size, enum random_entropy_source origin) | ||||
{ | { | ||||
Show All 15 Lines | |||||
{ | { | ||||
if (hc_source_mask & (1 << origin)) | if (hc_source_mask & (1 << origin)) | ||||
random_harvest_direct_(entropy, size, origin); | random_harvest_direct_(entropy, size, origin); | ||||
} | } | ||||
void random_harvest_register_source(enum random_entropy_source); | void random_harvest_register_source(enum random_entropy_source); | ||||
void random_harvest_deregister_source(enum random_entropy_source); | void random_harvest_deregister_source(enum random_entropy_source); | ||||
#else | |||||
#define random_harvest_queue(a, b, c) do {} while (0) | |||||
#define random_harvest_fast(a, b, c) do {} while (0) | |||||
#define random_harvest_direct(a, b, c) do {} while (0) | |||||
#define random_harvest_register_source(a) do {} while (0) | |||||
#define random_harvest_deregister_source(a) do {} while (0) | |||||
#endif | |||||
#if defined(RANDOM_ENABLE_UMA) | #if defined(RANDOM_ENABLE_UMA) | ||||
#define random_harvest_fast_uma(a, b, c) random_harvest_fast(a, b, c) | #define random_harvest_fast_uma(a, b, c) random_harvest_fast(a, b, c) | ||||
#else /* !defined(RANDOM_ENABLE_UMA) */ | #else /* !defined(RANDOM_ENABLE_UMA) */ | ||||
#define random_harvest_fast_uma(a, b, c) do {} while (0) | #define random_harvest_fast_uma(a, b, c) do {} while (0) | ||||
#endif /* defined(RANDOM_ENABLE_UMA) */ | #endif /* defined(RANDOM_ENABLE_UMA) */ | ||||
#if defined(RANDOM_ENABLE_ETHER) | #if defined(RANDOM_ENABLE_ETHER) | ||||
Show All 16 Lines |