Improved entropy gathering.
[u/mdw/putty] / sshrand.c
index 84c3e91..3e0a0a8 100644 (file)
--- a/sshrand.c
+++ b/sshrand.c
@@ -39,6 +39,7 @@ struct RandPool {
 };
 
 static struct RandPool pool;
+static int random_active = 0;
 
 void random_stir(void) {
     word32 block[HASHINPUT/sizeof(word32)];
@@ -114,6 +115,9 @@ void random_add_noise(void *noise, int length) {
     unsigned char *p = noise;
     int i;
 
+    if (!random_active)
+        return;
+
     /*
      * This function processes HASHINPUT bytes into only HASHSIZE
      * bytes, so _if_ we were getting incredibly high entropy
@@ -176,6 +180,8 @@ static void random_add_heavynoise_bitbybit(void *noise, int length) {
 void random_init(void) {
     memset(&pool, 0, sizeof(pool));    /* just to start with */
 
+    random_active = 1;
+
     noise_get_heavy(random_add_heavynoise_bitbybit);
 }