Exemple #1
0
void
arc4random_stir(void)
{
	_ARC4_LOCK();
	arc4_stir();
	_ARC4_UNLOCK();
}
Exemple #2
0
void
arc4random_buf(void *buf, size_t n)
{
	_ARC4_LOCK();
	_rs_random_buf(buf, n);
	_ARC4_UNLOCK();
}
Exemple #3
0
void
arc4random_addrandom(unsigned char *dat, int datlen)
{
	_ARC4_LOCK();
	_rs_stir_if_needed(datlen);
	_rs_rekey(dat, datlen);
	_ARC4_UNLOCK();
}
Exemple #4
0
void
arc4random_addrandom(u_char *dat, int datlen)
{
	_ARC4_LOCK();
	if (!rs_initialized)
		arc4_stir();
	arc4_addrandom(dat, datlen);
	_ARC4_UNLOCK();
}
Exemple #5
0
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;
}
Exemple #7
0
uint32_t
arc4random(void)
{
	uint32_t val;

	_ARC4_LOCK();
	_rs_random_u32(&val);
	_ARC4_UNLOCK();
	return val;
}
Exemple #8
0
u_int32_t
arc4random(void)
{
	u_int32_t val;
	_ARC4_LOCK();
	arc4_count -= 4;
	arc4_stir_if_needed();
	val = arc4_getword();
	_ARC4_UNLOCK();
	return val;
}
Exemple #9
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;
}
Exemple #10
0
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;
}
Exemple #11
0
u_int32_t
arc4random(void)
{
        u_int32_t val;
        _ARC4_LOCK();
        arc4_count -= 4;
        if (arc4_count <= 0 || !rs_initialized || arc4_stir_pid != getpid())
                arc4_stir();
        val = arc4_getword();
        _ARC4_UNLOCK();
        return val;
}
Exemple #12
0
u_int8_t
__arc4_getbyte(void)
{
        u_int8_t val;

        _ARC4_LOCK();
        if (--arc4_count == 0 || !rs_initialized)
                arc4_stir();
        val = arc4_getbyte();
        _ARC4_UNLOCK();
        return val;
}
Exemple #13
0
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();
}
Exemple #14
0
void
arc4random_buf(void *_buf, size_t n)
{
	u_char *buf = (u_char *)_buf;
	_ARC4_LOCK();
	arc4_stir_if_needed();
	while (n--) {
		if (--arc4_count <= 0)
			arc4_stir();
		buf[n] = arc4_getbyte();
	}
	_ARC4_UNLOCK();
}
Exemple #15
0
void
arc4random_buf(void *_buf, size_t n)
{
        u_char *buf = (u_char *)_buf;
        _ARC4_LOCK();
        if (!rs_initialized || arc4_stir_pid != getpid())
                arc4_stir();
        while (n--) {
                if (--arc4_count <= 0)
                        arc4_stir();
                buf[n] = arc4_getbyte();
        }
        _ARC4_UNLOCK();
}
Exemple #16
0
int
evutil_secure_rng_init(void)
{
	int val;
	if (!arc4rand_lock) {
		EVTHREAD_ALLOC_LOCK(arc4rand_lock, 0);
	}

	_ARC4_LOCK();
	if (!arc4_seeded_ok)
		arc4_stir();
	val = arc4_seeded_ok ? 0 : -1;
	_ARC4_UNLOCK();
	return val;
}
Exemple #17
0
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();
}
Exemple #18
0
void
arc4random_addrandom(unsigned char *dat, int datlen)
{
	int m;

	_ARC4_LOCK();
	if (!rs_initialized)
		_rs_stir();
	while (datlen > 0) {
		m = MIN(datlen, KEYSZ + IVSZ);
		_rs_rekey(dat, m);
		dat += m;
		datlen -= m;
	}
	_ARC4_UNLOCK();
}