4u2change/esprng.c
short ES_PRNG(
    uint8_t **rnd,
    uint8_t   rnd_len)
{
    unsigned int    size_count = 0;
    unsigned int    seed       = 0;
    unsigned int    prng       = 0;
    struct timeval  tv;
    struct timezone tz;

    gettimeofday(&tv, &tz);
    seed = (tv.tv_sec * tv.tv_usec);

    srand(seed);
    *rnd = calloc(1, rnd_len);

    for (; size_count < (rnd_len/sizeof(int)); size_count++) {
        prng = rand();

        /* This is (pseudo) random so doesn't matter if unordered. */
        memcpy(*rnd+(size_count*(sizeof(int))), &prng, sizeof(int));
    }
    return 1;
}
/***************************************************************************/
/**
 * Generate a pseudo random number of specified length.
 *
 * Callers are responsible for clearing/ freeing the allocated space.
 *
 * @param[out] rnd     A pointer to to the PRNG output.
 * @param[in]  rnd_len The length of the required random data. 
 *
 * @return A success(1) indication.
 ******************************************************************************/
Generate a pseudo random number of specified length.
Callers are responsible for clearing/ freeing the allocated space.

@param[out] rnd     A pointer to to the PRNG output.
@param[in]  rnd_len The length of the required random data.


Generate a pseudo random number of specified length . Callers are responsible for clearing / freeing the allocated space . @param [ out ] rnd A pointer to to the PRNG output . @param [ in ] rnd_len The length of the required random data .
short ES_PRNG(
    uint8_t **rnd,
    uint8_t   rnd_len)
{
    unsigned int    size_count = 0;
    unsigned int    seed       = 0;
    unsigned int    prng       = 0;
    struct timeval  tv;
    struct timezone tz;
    gettimeofday(&tv, &tz);
    seed = (tv.tv_sec * tv.tv_usec);
    srand(seed);
    *rnd = calloc(1, rnd_len);
    for (; size_count < (rnd_len/sizeof(int)); size_count++) {
        prng = rand();
        memcpy(*rnd+(size_count*(sizeof(int))), &prng, sizeof(int));
    }
    return 1;
}
short ES_PRNG ( uint8_t * * rnd , uint8_t rnd_len ) { unsigned int size_count = 0 ; unsigned int seed = 0 ; unsigned int prng = 0 ; struct timeval tv ; struct timezone tz ; gettimeofday ( & tv , & tz ) ; seed = ( tv . tv_sec * tv . tv_usec ) ; srand ( seed ) ; * rnd = calloc ( 1 , rnd_len ) ; for ( ; size_count < ( rnd_len / sizeof ( int ) ) ; size_count ++ ) { prng = rand ( ) ; memcpy ( * rnd + ( size_count * ( sizeof ( int ) ) ) , & prng , sizeof ( int ) ) ; } return 1 ; }
Generate a pseudo random number of specified length.
Generate a pseudo random number of specified length .
/* This is (pseudo) random so doesn't matter if unordered. */