aboutsummaryrefslogtreecommitdiffstats
path: root/cipher/random.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2002-08-30 16:33:55 +0000
committerWerner Koch <[email protected]>2002-08-30 16:33:55 +0000
commit0073d6865d5940cd3ee71d0158059bd5b22112a8 (patch)
tree7d2f54a5e51e01f0a7bc039eef6fa861e0068452 /cipher/random.c
parent* gpgkeys_hkp.c: (parse_hkp_index): Use same types on all platforms. (diff)
downloadgnupg-0073d6865d5940cd3ee71d0158059bd5b22112a8.tar.gz
gnupg-0073d6865d5940cd3ee71d0158059bd5b22112a8.zip
* random.c: Automagically detect the entrop gatherer when
configure so. * rndegd.c (rndegd_connect_socket): New. Factored out from .. (rndegd_gather_random): here and call it. (do_read): Update the counter variables correctly. This was not a problem due to the way EGD works. Bug found by Christian Biere.
Diffstat (limited to 'cipher/random.c')
-rw-r--r--cipher/random.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/cipher/random.c b/cipher/random.c
index d7ebf5787..c2dea9c28 100644
--- a/cipher/random.c
+++ b/cipher/random.c
@@ -129,20 +129,49 @@ static int (*
getfnc_gather_random (void))(void (*)(const void*, size_t, int), int,
size_t, int)
{
-#ifdef USE_RNDLINUX
+#ifdef USE_ALL_RANDOM_MODULES
+ static int (*fnc)(void (*)(const void*, size_t, int), int, size_t, int);
+
+ if (fnc)
+ return fnc;
+# ifdef USE_RNDLINUX
+ if ( !access (NAME_OF_DEV_RANDOM, R_OK)
+ && !access (NAME_OF_DEV_RANDOM, R_OK))
+ {
+ fnc = rndlinux_gather_random;
+ return fnc;
+ }
+# endif
+# ifdef USE_RNDEGD
+ if ( rndegd_connect_socket (1) != -1 )
+ {
+ fnc = rndegd_gather_random;
+ return fnc;
+ }
+# endif
+# ifdef USE_RNDUNIX
+ fnc = rndunix_gather_random;
+ return fnc;
+# endif
+
+ log_fatal (_("no entropy gathering module detected\n"));
+
+#else
+# ifdef USE_RNDLINUX
return rndlinux_gather_random;
-#endif
-#ifdef USE_RNDUNIX
+# endif
+# ifdef USE_RNDUNIX
return rndunix_gather_random;
-#endif
-#ifdef USE_RNDEGD
+# endif
+# ifdef USE_RNDEGD
return rndegd_gather_random;
-#endif
-#ifdef USE_RNDW32
+# endif
+# ifdef USE_RNDW32
return rndw32_gather_random;
-#endif
-#ifdef USE_RNDRISCOS
+# endif
+# ifdef USE_RNDRISCOS
return rndriscos_gather_random;
+# endif
#endif
return NULL;
}