mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
NT version compiles
This commit is contained in:
parent
b7bdef0834
commit
e1117ae4a1
14 changed files with 380 additions and 138 deletions
|
@ -40,7 +40,6 @@ static struct cache cache[3];
|
|||
#define MASK_LEVEL(a) do {if( a > 2 ) a = 2; else if( a < 0 ) a = 0; } while(0)
|
||||
|
||||
|
||||
static int open_device( const char *name, int minor );
|
||||
static void fill_buffer( byte *buffer, size_t length, int level );
|
||||
|
||||
/****************
|
||||
|
@ -70,6 +69,7 @@ get_random_byte( int level )
|
|||
|
||||
|
||||
|
||||
#ifdef HAVE_DEV_RANDOM
|
||||
|
||||
static int
|
||||
open_device( const char *name, int minor )
|
||||
|
@ -149,3 +149,26 @@ the OS a chance to collect more entropy! (Need %d more bytes)\n", length );
|
|||
} while( length );
|
||||
}
|
||||
|
||||
#else /* not HAVE_DEV_RANDOM */
|
||||
|
||||
|
||||
static void
|
||||
fill_buffer( byte *buffer, size_t length, int level )
|
||||
{
|
||||
static int initialized=0;
|
||||
|
||||
if( !initialized ) {
|
||||
log_info("warning: using insecure random number generator!!\n");
|
||||
tty_printf("The random number generator is only a kludge to let\n"
|
||||
"it compile - it is in no way a strong RNG!\n\n"
|
||||
"DON'T USE ANY DATA GENERATED BY THIS PROGRAM!!\n\n");
|
||||
initialized=1;
|
||||
srand(make_timestamp()*getpid());
|
||||
}
|
||||
|
||||
while( length-- )
|
||||
*buffer++ = ((unsigned)(1 + (int) (256.0*rand()/(RAND_MAX+1.0)))-1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue