summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1999-03-20 10:53:34 +0000
committerWerner Koch <wk@gnupg.org>1999-03-20 10:53:34 +0000
commitdae29a8b871dcbb5441eb2fc6de87ab32d5c25bd (patch)
tree7c740991a88b4fa5e8aff4b8f782420082652d19
parent98f4d26ffe97e99d9f9bd5dc58d9f511d9e64514 (diff)
downloadlibgcrypt-dae29a8b871dcbb5441eb2fc6de87ab32d5c25bd.tar.gz
See ChangeLog: Sat Mar 20 11:53:40 CET 1999 Werner Koch
-rw-r--r--cipher/ChangeLog6
-rw-r--r--cipher/rndegd.c23
-rw-r--r--cipher/rndlinux.c23
3 files changed, 28 insertions, 24 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 3ac7d31c..bfb5860f 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,9 @@
+Sat Mar 20 11:44:21 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * rndlinux.c (tty_printf) [IS_MODULE]: Removed.
+
+ * rndegd.c (gather_random): Some fixes.
+
Wed Mar 17 13:09:03 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndegd.c (do_read): New.
diff --git a/cipher/rndegd.c b/cipher/rndegd.c
index 0777ff85..7fc1f494 100644
--- a/cipher/rndegd.c
+++ b/cipher/rndegd.c
@@ -82,6 +82,7 @@ do_read( int fd, void *buf, size_t nbytes )
}
+
/* fixme: level 1 is not yet handled */
static int
gather_random( void (*add)(const void*, size_t, int), int requester,
@@ -138,14 +139,15 @@ gather_random( void (*add)(const void*, size_t, int), int requester,
do_restart = 1;
goto restart;
}
- if( !n ) {
- g10_log_error("bad EGD reply: too short\n");
- do_restart = 1;
- goto restart;
- }
- if( n > 1 ) {
- n--;
- (*add)( buffer+1, n, requester );
+ n = buffer[0];
+ if( n ) {
+ n = do_read( fd, buffer, n );
+ if( n == -1 ) {
+ g10_log_error("read error on EGD: %s\n", strerror(errno));
+ do_restart = 1;
+ goto restart;
+ }
+ (*add)( buffer, n, requester );
length -= n;
}
@@ -172,11 +174,6 @@ gather_random( void (*add)(const void*, size_t, int), int requester,
do_restart = 1;
goto restart;
}
- if( n != nbytes ) {
- g10_log_error("bad EGD reply: too short %d/%d\n", nbytes, n );
- do_restart = 1;
- goto restart;
- }
(*add)( buffer, n, requester );
length -= n;
}
diff --git a/cipher/rndlinux.c b/cipher/rndlinux.c
index 365233bf..8c591fbe 100644
--- a/cipher/rndlinux.c
+++ b/cipher/rndlinux.c
@@ -48,14 +48,6 @@ static int open_device( const char *name, int minor );
static int gather_random( void (*add)(const void*, size_t, int), int requester,
size_t length, int level );
-#ifdef IS_MODULE
-static void tty_printf(const char *fmt, ... )
-{
- g10_log_info("tty_printf not available (%s)\n", fmt );
-}
-#endif
-
-
/****************
* Used to open the Linux and xBSD /dev/random devices
@@ -110,15 +102,24 @@ gather_random( void (*add)(const void*, size_t, int), int requester,
tv.tv_usec = 0;
if( !(rc=select(fd+1, &rfds, NULL, NULL, &tv)) ) {
if( !warn )
- tty_printf( _(
-"\n"
+ #ifdef IS_MODULE
+ fprintf(stderr,
+ #else
+ tty_printf(
+ #endif
+_("\n"
"Not enough random bytes available. Please do some other work to give\n"
"the OS a chance to collect more entropy! (Need %d more bytes)\n"), length );
warn = 1;
continue;
}
else if( rc == -1 ) {
- tty_printf("select() error: %s\n", strerror(errno));
+ #ifdef IS_MODULE
+ fprintf(stderr,
+ #else
+ tty_printf(
+ #endif
+ "select() error: %s\n", strerror(errno));
continue;
}