[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Once an hour (not just on startup) give OpenSSL some more e...



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv32100/src/or

Modified Files:
	main.c 
Log Message:
Once an hour (not just on startup) give OpenSSL some more entropy.
Add entropy in 512-bit chunks, not 160-bit chunks.  (This latter
change is voodoo.)



Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.574
retrieving revision 1.575
diff -u -d -r1.574 -r1.575
--- main.c	5 Oct 2005 23:20:45 -0000	1.574
+++ main.c	6 Oct 2005 22:22:22 -0000	1.575
@@ -98,6 +98,7 @@
 #define DESCRIPTOR_RETRY_INTERVAL 10
 #define DESCRIPTOR_FAILURE_RESET_INTERVAL 60*60
 #define TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT (20*60) /* 20 minutes */
+#define ENTROPY_INTERVAL 60*60
 
 /********* END VARIABLES ************/
 
@@ -639,6 +640,7 @@
   static time_t time_to_shrink_buffers = 0;
   static time_t time_to_try_getting_descriptors = 0;
   static time_t time_to_reset_descriptor_failures = 0;
+  static time_t time_to_add_entropy = 0;
   or_options_t *options = get_options();
   int i;
 
@@ -689,6 +691,14 @@
      *      them at all. */
   }
 
+  if (time_to_add_entropy == 0)
+    time_to_add_entropy = now + ENTROPY_INTERVAL;
+  if (time_to_add_entropy < now) {
+    /* We already seeded once, so don't die on failure. */
+    crypto_seed_rng();
+    time_to_add_entropy = now + ENTROPY_INTERVAL;
+  }
+
   /** 1c. If we have to change the accounting interval or record
    * bandwidth used in this accounting interval, do so. */
   if (accounting_is_enabled(options))