]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - sshrand.c
Add pscp to .cvsignore
[PuTTY.git] / sshrand.c
index 3014da4f800f602a669ba3386aa56f0e4cd51403..524bbd43e57072584f9f9c2b7466a7cb2e474100 100644 (file)
--- a/sshrand.c
+++ b/sshrand.c
@@ -2,6 +2,7 @@
  * cryptographic random number generator for PuTTY's ssh client
  */
 
+#include "putty.h"
 #include "ssh.h"
 
 void noise_get_heavy(void (*func) (void *, int));
@@ -39,9 +40,9 @@ struct RandPool {
 };
 
 static struct RandPool pool;
-static int random_active = 0;
+int random_active = 0;
 
-void random_stir(void)
+static void random_stir(void)
 {
     word32 block[HASHINPUT / sizeof(word32)];
     word32 digest[HASHSIZE / sizeof(word32)];
@@ -201,7 +202,10 @@ int random_byte(void)
 
 void random_get_savedata(void **data, int *len)
 {
+    void *buf = snewn(POOLSIZE / 2, char);
     random_stir();
-    *data = pool.pool + pool.poolpos;
+    memcpy(buf, pool.pool + pool.poolpos, POOLSIZE / 2);
     *len = POOLSIZE / 2;
+    *data = buf;
+    random_stir();
 }