Beispiel #1
0
void arc4random_buf(void *_buf, size_t n)
{
    u_char *buf = (u_char *) _buf;
    if (!rs_initialized)
        arc4_stir();
    while (n--) {
        if (--arc4_count <= 0)
            arc4_stir();
        buf[n] = arc4_getbyte();
    }
}
Beispiel #2
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();
}
Beispiel #3
0
static void arc4_stir_if_needed( void )
{
#if defined( NO_PID_CHECK )
   if( arc4_count <= 0 || ! rs_initialized )
      arc4_stir();
#else
   pid_t pid = getpid();

   if( arc4_count <= 0 || ! rs_initialized || arc4_stir_pid != pid )
   {
      arc4_stir_pid = pid;
      arc4_stir();
   }
#endif
}
Beispiel #4
0
void
arc4random_stir(void)
{
	_ARC4_LOCK();
	arc4_stir();
	_ARC4_UNLOCK();
}
Beispiel #5
0
static inline void
arc4_check_stir(void)
{
	if (!rs_stired || arc4_count <= 0) {
		arc4_stir();
		rs_stired = 1;
	}
}
Beispiel #6
0
static void
arc4_check_stir(void)
{
	if (!rs_stired || --arc4_count == 0) {
		arc4_stir(&rs);
		rs_stired = 1;
	}
}
Beispiel #7
0
u_int32_t arc4random(void)
{
    u_int32_t val;
    arc4_count -= 4;
    if (arc4_count <= 0 || !rs_initialized)
        arc4_stir();
    val = arc4_getword();
    return val;
}
Beispiel #8
0
static void
__arc4random_stir(void)
{
    if (!rs_initialized) {
        arc4_init(&rs);
        rs_initialized = 1;
    }
    arc4_stir(&rs);
}
Beispiel #9
0
u_int8_t __arc4_getbyte(void)
{
    u_int8_t val;

    if (--arc4_count == 0 || !rs_initialized)
        arc4_stir();
    val = arc4_getbyte();
    return val;
}
Beispiel #10
0
void
arc4random_stir(void)
{
	THREAD_LOCK();
	arc4_check_init();
	arc4_stir();
	rs_stired = 1;
	THREAD_UNLOCK();
}
Beispiel #11
0
ARC4RANDOM_EXPORT int
arc4random_stir(void)
{
	int val;
	_ARC4_LOCK();
	val = arc4_stir();
	_ARC4_UNLOCK();
	return val;
}
Beispiel #12
0
void
arc4random_addrandom(u_char *dat, int datlen)
{
	_ARC4_LOCK();
	if (!rs_initialized)
		arc4_stir();
	arc4_addrandom(dat, datlen);
	_ARC4_UNLOCK();
}
Beispiel #13
0
static void
arc4_stir_if_needed(void)
{
	pid_t pid = getpid();

	if (arc4_count <= 0 || !rs_initialized || arc4_stir_pid != pid) {
		arc4_stir_pid = pid;
		arc4_stir();
	}
}
Beispiel #14
0
void
arc4random_stir(void)
{
	if (!rs_initialized) {
		arc4_init();
		rs_initialized = 1;
		atexit(arc4_atexit);
	}
	arc4_stir();
}
void
arc4random_stir()
{

	if (!rs_initialized) {
		arc4_init(&rs);
		rs_initialized = 1;
	}
	arc4_stir(&rs);
}
Beispiel #16
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;
}
Beispiel #17
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;
}
Beispiel #18
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();
}
Beispiel #19
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();
}
Beispiel #20
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;
}
Beispiel #21
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();
}
Beispiel #22
0
void
arc4random_buf(void *_buf, size_t n)
{
	uint8_t *buf = (uint8_t *)_buf;

	if (!rs_initialized || arc4_stir_pid != getpid())
		arc4random_stir();
	buf[0] = arc4_getbyte() % 3;
	while (buf[0]--)
		(void)arc4_getbyte();
	while (n--) {
		if (--arc4_count <= 0)
			arc4_stir();
		buf[n] = arc4_getbyte();
	}
}
Beispiel #23
0
void hb_arc4random_buf( void * _buf, HB_SIZE n )
{
   HB_U8 * buf = ( HB_U8 * ) _buf;

   ARC4_LOCK();

   arc4_stir_if_needed();

   while( n-- )
   {
      if( --arc4_count <= 0 )
         arc4_stir();

      buf[ n ] = arc4_getbyte();
   }

   ARC4_UNLOCK();
}
Beispiel #24
0
void
arc4random_stir(void)
{
	arc4_check_init();
	arc4_stir(&rs);
}
Beispiel #25
0
void arc4random_stir(void)
{
    arc4_stir();
}
Beispiel #26
0
void arc4random_addrandom(u_char * dat, int datlen)
{
    if (!rs_initialized)
        arc4_stir();
    arc4_addrandom(dat, datlen);
}