void
alt_arc4random_buf(void *_buf, size_t n)
{
    _alt_arc4_LOCK();
    _rs_random_buf(_buf, n);
    _alt_arc4_UNLOCK();
}
void
alt_arc4random_stir(void)
{
    _alt_arc4_LOCK();
    _rs_stir();
    _alt_arc4_UNLOCK();
}
crypto_uint4
alt_arc4random(void)
{
    crypto_uint4 val;

    _alt_arc4_LOCK();
    _rs_random_u32(&val);
    _alt_arc4_UNLOCK();
    return val;
}
void
alt_arc4random_addrandom(unsigned char *dat, int datlen)
{
    _alt_arc4_LOCK();
    if (!rs_initialized) {
        alt_arc4_stir();
    }
    alt_arc4_addrandom(dat, datlen);
    _alt_arc4_UNLOCK();
}
crypto_uint4
alt_arc4random(void)
{
    crypto_uint4 val;
    _alt_arc4_LOCK();
    alt_arc4_count -= 4;
    alt_arc4_stir_if_needed();
    val = alt_arc4_getword();
    _alt_arc4_UNLOCK();

    return val;
}
Esempio n. 6
0
unsigned int
alt_arc4random(void)
{
    unsigned int val;
    _alt_arc4_LOCK();
    alt_arc4_count -= 4;
    alt_arc4_stir_if_needed();
    val = alt_arc4_getword();
    _alt_arc4_UNLOCK();

    return (unsigned int) val;
}
int
alt_arc4random_close(void)
{
    int ret = -1;

    _alt_arc4_LOCK();
    if (random_data_source_fd != -1 && close(random_data_source_fd) == 0) {
        random_data_source_fd = -1;
        ret = 0;
    }
    _alt_arc4_UNLOCK();

    return ret;
}
void
alt_arc4random_buf(void *_buf, size_t n)
{
    unsigned char *buf = (unsigned char *)_buf;
    _alt_arc4_LOCK();
    alt_arc4_stir_if_needed();
    while (n--) {
        if (--alt_arc4_count <= 0) {
            alt_arc4_stir();
        }
        buf[n] = alt_arc4_getbyte();
    }
    _alt_arc4_UNLOCK();
}