diff random.c @ 305:1876c6bb084b ucc-axis-hack

A few changes for the 0.48 merge
author matt-ucc@ucc.asn.au
date Sat, 25 Mar 2006 17:10:27 +0000
parents 7dad470ad4aa
children
line wrap: on
line diff
--- a/random.c	Sat Mar 25 16:26:29 2006 +0000
+++ b/random.c	Sat Mar 25 17:10:27 2006 +0000
@@ -36,7 +36,8 @@
 
 static unsigned char hashpool[SHA1_HASH_SIZE];
 
-#define INIT_SEED_SIZE 32 /* 256 bits */
+/* 256 bits */
+#define INIT_SEED_SIZE 32
 
 static void readrand(unsigned char* buf, unsigned int buflen);
 
@@ -129,12 +130,11 @@
 /* initialise the prng from /dev/(u)random or prngd */
 void seedrandom() {
 		
+	hash_state hs;
 	unsigned char readbuf[INIT_SEED_SIZE];
 
-	hash_state hs;
-
 	/* initialise so that things won't warn about
-     * hashing an undefined buffer */
+	 * hashing an undefined buffer */
 	if (!donerandinit) {
 		m_burn(hashpool, sizeof(hashpool));
 	}
@@ -157,17 +157,17 @@
  * the random pools for fork()ed processes. */
 void reseedrandom() {
 
-    pid_t pid;
-    struct timeval tv;
+	pid_t pid;
+	hash_state hs;
+	struct timeval tv;
 
 	if (!donerandinit) {
 		dropbear_exit("seedrandom not done");
 	}
 
-    pid = getpid();
-    gettimeofday(&tv, NULL);
+	pid = getpid();
+	gettimeofday(&tv, NULL);
 
-	hash_state hs;
 	sha1_init(&hs);
 	sha1_process(&hs, (void*)hashpool, sizeof(hashpool));
 	sha1_process(&hs, (void*)&pid, sizeof(pid));
@@ -233,7 +233,7 @@
 		bytes_to_mp(rand, randbuf, len);
 
 		/* keep regenerating until we get one satisfying
-		 * 0 < rand < max    */
+		 * 0 < rand < max	 */
 	} while ( ( (max != NULL) && (mp_cmp(rand, max) != MP_LT) )
 			|| (mp_cmp_d(rand, 0) != MP_GT) );
 	m_burn(randbuf, len);