diff options
author | Werner Koch <[email protected]> | 1998-06-09 15:14:06 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 1998-06-09 15:14:06 +0000 |
commit | 1ece02aa54afb9a0e51e916098373beda317f070 (patch) | |
tree | 72d56d5bd9feae8540d8bf1d2510ea08fdd58c97 /cipher/rand-unix.c | |
parent | add a challenge (diff) | |
download | gnupg-1ece02aa54afb9a0e51e916098373beda317f070.tar.gz gnupg-1ece02aa54afb9a0e51e916098373beda317f070.zip |
Sicherung
Diffstat (limited to '')
-rw-r--r-- | cipher/rand-unix.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/cipher/rand-unix.c b/cipher/rand-unix.c index c0b7bc702..93afba13a 100644 --- a/cipher/rand-unix.c +++ b/cipher/rand-unix.c @@ -124,15 +124,22 @@ read_random_source( byte *buffer, size_t length, int level ) int n; int warn=0; - if( level == 2 ) { + if( level >= 2 ) { if( fd_random == -1 ) fd_random = open_device( "/dev/random", 8 ); fd = fd_random; } + else if( level == 1 ) { + if( fd_urandom == -1 ) + fd_urandom = open_device( "/dev/urandom", 9 ); + fd = fd_urandom; + } else { - /* fixme: we should use a simpler one for level 0, - * because reading from /dev/urandom removes entropy - * and the next read on /dev/random may have to wait */ + /* This is level 0, which only yields simple random bytes. + * We do not use /dev/urandom as this would remove entropy + * from the kernel entropy pool */ + /* FIXME !!!! */ + if( fd_urandom == -1 ) fd_urandom = open_device( "/dev/urandom", 9 ); fd = fd_urandom; |