(trunk libT) add some extra tests to tr_cryptoWeakRandInt()

This commit is contained in:
Charles Kerr 2009-05-19 20:52:24 +00:00
parent 8f3660c334
commit 979eddf61d
1 changed files with 10 additions and 3 deletions

View File

@ -311,6 +311,8 @@ tr_cryptoRandInt( int upperBound )
int noise;
int val;
assert( upperBound > 0 );
if( RAND_pseudo_bytes ( (unsigned char *) &noise, sizeof noise ) >= 0 )
{
val = abs( noise ) % upperBound;
@ -328,17 +330,22 @@ tr_cryptoRandInt( int upperBound )
int
tr_cryptoWeakRandInt( int upperBound )
{
static int init = 0;
int val;
static tr_bool init = FALSE;
assert( upperBound > 0 );
if( !init )
{
srand( tr_date( ) );
init = 1;
init = TRUE;
}
return rand( ) % upperBound;
val = rand( ) % upperBound;
assert( val >= 0 );
assert( val < upperBound );
return val;
}
void