ARC4RANDOM_EXPORT int arc4random_stir(void) { int val; ARC4_LOCK_(); val = arc4_stir(); ARC4_UNLOCK_(); return val; }
int evutil_secure_rng_set_urandom_device_file(char *fname) { #ifdef TRY_SEED_URANDOM ARC4_LOCK_(); arc4random_urandom_filename = fname; ARC4_UNLOCK_(); #endif return 0; }
ARC4RANDOM_EXPORT ARC4RANDOM_UINT32 arc4random(void) { ARC4RANDOM_UINT32 val; ARC4_LOCK_(); arc4_count -= 4; arc4_stir_if_needed(); val = arc4_getword(); ARC4_UNLOCK_(); return val; }
int evutil_secure_rng_init(void) { int val; ARC4_LOCK_(); if (!arc4_seeded_ok) arc4_stir(); val = arc4_seeded_ok ? 0 : -1; ARC4_UNLOCK_(); return val; }
ARC4RANDOM_EXPORT void arc4random_buf(void *buf_, size_t n) { unsigned char *buf = buf_; ARC4_LOCK_(); arc4_stir_if_needed(); while (n--) { if (--arc4_count <= 0) arc4_stir(); buf[n] = arc4_getbyte(); } ARC4_UNLOCK_(); }
ARC4RANDOM_EXPORT void arc4random_addrandom(const unsigned char *dat, int datlen) { int j; ARC4_LOCK_(); if (!rs_initialized) arc4_stir(); for (j = 0; j < datlen; j += 256) { /* arc4_addrandom() ignores all but the first 256 bytes of * its input. We want to make sure to look at ALL the * data in 'dat', just in case the user is doing something * crazy like passing us all the files in /var/log. */ arc4_addrandom(dat + j, datlen - j); } ARC4_UNLOCK_(); }