diff options
Diffstat (limited to 'src/systemd/src/basic/random-util.h')
-rw-r--r-- | src/systemd/src/basic/random-util.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/systemd/src/basic/random-util.h b/src/systemd/src/basic/random-util.h index affcc9ac1d..3e8c288d3d 100644 --- a/src/systemd/src/basic/random-util.h +++ b/src/systemd/src/basic/random-util.h @@ -5,9 +5,17 @@ #include <stddef.h> #include <stdint.h> -int acquire_random_bytes(void *p, size_t n, bool high_quality_required); -void pseudorandom_bytes(void *p, size_t n); -void random_bytes(void *p, size_t n); +typedef enum RandomFlags { + RANDOM_EXTEND_WITH_PSEUDO = 1 << 0, /* If we can't get enough genuine randomness, but some, fill up the rest with pseudo-randomness */ + RANDOM_BLOCK = 1 << 1, /* Rather block than return crap randomness (only if the kernel supports that) */ + RANDOM_DONT_DRAIN = 1 << 2, /* If we can't get any randomness at all, return early with -EAGAIN */ + RANDOM_ALLOW_RDRAND = 1 << 3, /* Allow usage of the CPU RNG */ +} RandomFlags; + +int genuine_random_bytes(void *p, size_t n, RandomFlags flags); /* returns "genuine" randomness, optionally filled upwith pseudo random, if not enough is available */ +void pseudo_random_bytes(void *p, size_t n); /* returns only pseudo-randommess (but possibly seeded from something better) */ +void random_bytes(void *p, size_t n); /* returns genuine randomness if cheaply available, and pseudo randomness if not. */ + void initialize_srand(void); static inline uint64_t random_u64(void) { @@ -22,4 +30,4 @@ static inline uint32_t random_u32(void) { return u; } -int rdrand64(uint64_t *ret); +int rdrand(unsigned long *ret); |