summaryrefslogtreecommitdiffstats
path: root/cipher
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1998-12-10 20:20:47 +0100
committerWerner Koch <wk@gnupg.org>1998-12-10 20:20:47 +0100
commitaf6e96e4f918169508acd8a710309cf617eff3c1 (patch)
treebe313d86fcf1e63ae95686216e149e3aac770749 /cipher
parentSee ChangeLog: Wed Dec 9 13:41:06 CET 1998 Werner Koch (diff)
downloadgnupg2-af6e96e4f918169508acd8a710309cf617eff3c1.tar.xz
gnupg2-af6e96e4f918169508acd8a710309cf617eff3c1.zip
See ChangeLog: Thu Dec 10 20:15:36 CET 1998 Werner Koch
Diffstat (limited to 'cipher')
-rw-r--r--cipher/ChangeLog12
-rw-r--r--cipher/dynload.c4
-rw-r--r--cipher/random.c57
-rw-r--r--cipher/rndlinux.c39
-rw-r--r--cipher/rndunix.c33
5 files changed, 58 insertions, 87 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 415f58b2e..1df5a1500 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,15 @@
+Thu Dec 10 20:15:36 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * dynload.c (load_extension): increased needed verbosity level.
+
+ * random.c (fast_random_poll): Fallback to a default fast random
+ poll function.
+ (read_random_source): Always use the faked entroy gatherer if no
+ gather module is available.
+ * rndlinux.c (fast_poll): Removed.
+ * rndunix.c (fast_poll): Removed.
+
+
Wed Nov 25 12:33:41 1998 Werner Koch (wk@isil.d.shuttle.de)
* rand-*.c: Removed.
diff --git a/cipher/dynload.c b/cipher/dynload.c
index 7278928f1..204f186b0 100644
--- a/cipher/dynload.c
+++ b/cipher/dynload.c
@@ -231,7 +231,7 @@ load_extension( EXTLIST el )
name = (char**)addr;
#endif
- if( g10_opt_verbose )
+ if( g10_opt_verbose > 1 )
log_info("%s: %s%s%s%s\n", el->name, *name,
el->hintstr? " (":"",
el->hintstr? el->hintstr:"",
@@ -262,7 +262,7 @@ load_extension( EXTLIST el )
#endif
#ifdef HAVE_DL_DLOPEN
- if( g10_opt_verbose > 1 ) {
+ if( g10_opt_verbose > 2 ) {
/* list the contents of the module */
while( (sym = (*el->enumfunc)(0, &seq, &class, &vers)) ) {
if( vers != 1 ) {
diff --git a/cipher/random.c b/cipher/random.c
index e173a5279..32415bd0b 100644
--- a/cipher/random.c
+++ b/cipher/random.c
@@ -32,6 +32,18 @@
#include <assert.h>
#include <errno.h>
#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_GETHRTIME
+ #include <sys/times.h>
+#endif
+#ifdef HAVE_GETTIMEOFDAY
+ #include <sys/times.h>
+#endif
+#ifdef HAVE_GETRUSAGE
+ #include <sys/resource.h>
+#endif
#include "util.h"
#include "rmd.h"
#include "ttyio.h"
@@ -83,9 +95,7 @@ static void read_pool( byte *buffer, size_t length, int level );
static void add_randomness( const void *buffer, size_t length, int source );
static void random_poll(void);
static void read_random_source( byte *buffer, size_t length, int level );
-#ifndef HAVE_DEV_RANDOM
static int gather_faked( byte *buffer, size_t *r_length, int level );
-#endif
static void
@@ -329,11 +339,39 @@ fast_random_poll()
initialize();
initialized = 1;
fnc = dynload_getfnc_fast_random_poll();
- if( !fnc )
- log_info("Ooops: No fast random poll function\n");
}
- if( fnc )
+ if( fnc ) {
(*fnc)( add_randomness );
+ return;
+ }
+
+ /* fall back to the generic function */
+ #if HAVE_GETHRTIME
+ { hrtime_t tv;
+ tv = gethrtime();
+ add_randomness( &tv, sizeof(tv), 1 );
+ }
+ #elif HAVE_GETTIMEOFDAY
+ { struct timeval tv;
+ if( gettimeofday( &tv, NULL ) )
+ BUG();
+ add_randomness( &tv.tv_sec, sizeof(tv.tv_sec), 1 );
+ add_randomness( &tv.tv_usec, sizeof(tv.tv_usec), 1 );
+ }
+ #else /* use times */
+ { struct tms buf;
+ times( &buf );
+ add_randomness( &buf, sizeof buf, 1 );
+ }
+ #endif
+ #ifdef HAVE_GETRUSAGE
+ { struct rusage buf;
+ if( getrusage( RUSAGE_SELF, &buf ) )
+ BUG();
+ add_randomness( &buf, sizeof buf, 1 );
+ memset( &buf, 0, sizeof buf );
+ }
+ #endif
}
@@ -351,11 +389,7 @@ read_random_source( byte *buffer, size_t length, int level )
fnc = dynload_getfnc_gather_random();
if( !fnc ) {
faked_rng = 1;
- #ifndef HAVE_DEV_RANDOM
fnc = gather_faked;
- #else
- BUG();
- #endif
}
}
while( length ) {
@@ -368,7 +402,6 @@ read_random_source( byte *buffer, size_t length, int level )
}
-#ifndef HAVE_DEV_RANDOM
static int
gather_faked( byte *buffer, size_t *r_length, int level )
{
@@ -378,7 +411,7 @@ gather_faked( byte *buffer, size_t *r_length, int level )
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"
+ "it run - it is in no way a strong RNG!\n\n"
"DON'T USE ANY DATA GENERATED BY THIS PROGRAM!!\n\n"));
initialized=1;
#ifdef HAVE_RAND
@@ -398,5 +431,3 @@ gather_faked( byte *buffer, size_t *r_length, int level )
return 100; /* We really fake it ;-) */
}
-#endif /* ! HAVE_DEV_RANDOM */
-
diff --git a/cipher/rndlinux.c b/cipher/rndlinux.c
index 69af64f5d..3d0ac1b58 100644
--- a/cipher/rndlinux.c
+++ b/cipher/rndlinux.c
@@ -27,15 +27,9 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef HAVE_GETHRTIME
- #include <sys/times.h>
-#endif
#ifdef HAVE_GETTIMEOFDAY
#include <sys/times.h>
#endif
-#ifdef HAVE_GETRUSAGE
- #include <sys/resource.h>
-#endif
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
@@ -61,38 +55,6 @@ static void tty_printf(const char *fmt, ... )
#endif
-static void
-fast_poll( void (*add)(const void*, size_t, int) )
-{
- #if HAVE_GETHRTIME
- { hrtime_t tv;
- tv = gethrtime();
- (*add)( &tv, sizeof(tv), 1 );
- }
- #elif HAVE_GETTIMEOFDAY
- { struct timeval tv;
- if( gettimeofday( &tv, NULL ) )
- BUG();
- (*add)( &tv.tv_sec, sizeof(tv.tv_sec), 1 );
- (*add)( &tv.tv_usec, sizeof(tv.tv_usec), 1 );
- }
- #else /* use times */
- { struct tms buf;
- times( &buf );
- (*add)( &buf, sizeof buf, 1 );
- }
- #endif
- #ifdef HAVE_GETRUSAGE
- { struct rusage buf;
- if( getrusage( RUSAGE_SELF, &buf ) )
- BUG();
- (*add)( &buf, sizeof buf, 1 );
- memset( &buf, 0, sizeof buf );
- }
- #endif
-}
-
-
/****************
* Used to open the Linux and xBSD /dev/random devices
@@ -192,7 +154,6 @@ static struct {
void *func;
} func_table[] = {
{ 40, 1, gather_random },
- { 41, 1, fast_poll },
};
diff --git a/cipher/rndunix.c b/cipher/rndunix.c
index 530971723..3eca9df81 100644
--- a/cipher/rndunix.c
+++ b/cipher/rndunix.c
@@ -617,38 +617,6 @@ slowPoll(void)
}
-static void
-fast_poll( void (*add)(const void*, size_t, int) )
-{
- #if HAVE_GETHRTIME
- { hrtime_t tv;
- tv = gethrtime();
- (*add)( &tv, sizeof(tv), 1 );
- }
- #elif HAVE_GETTIMEOFDAY
- { struct timeval tv;
- if( gettimeofday( &tv, NULL ) )
- BUG();
- (*add)( &tv.tv_sec, sizeof(tv.tv_sec), 1 );
- (*add)( &tv.tv_usec, sizeof(tv.tv_usec), 1 );
- }
- #else /* use times */
- { struct tms buf;
- times( &buf );
- (*add)( &buf, sizeof buf, 1 );
- }
- #endif
- #ifdef HAVE_GETRUSAGE
- { struct rusage buf;
- if( getrusage( RUSAGE_SELF, &buf ) )
- BUG();
- (*add)( &buf, sizeof buf, 1 );
- memset( &buf, 0, sizeof buf );
- }
- #endif
-}
-
-
static int
gather_random( byte *buffer, size_t *r_length, int level )
@@ -698,7 +666,6 @@ static struct {
void *func;
} func_table[] = {
{ 40, 1, gather_random },
- { 41, 1, fast_poll },
};
/****************