- Seed OpenSSL's random number generator before generating RSA keypairs
- Split random collector into seperate file
diff --git a/rsa.c b/rsa.c
index 5e7297b..597d20f 100644
--- a/rsa.c
+++ b/rsa.c
@@ -35,11 +35,12 @@
*/
#include "includes.h"
-RCSID("$Id: rsa.c,v 1.6 1999/12/17 03:02:47 damien Exp $");
+RCSID("$Id: rsa.c,v 1.7 2000/01/29 09:40:22 damien Exp $");
#include "rsa.h"
#include "ssh.h"
#include "xmalloc.h"
+#include "random.h"
int rsa_verbose = 1;
@@ -64,13 +65,26 @@
const char progress_chars[] = ".o+O?";
if ((p < 0) || (p > (sizeof(progress_chars) - 2)))
- p = 4;
+ p = sizeof(progress_chars) - 2;
- printf("%c", progress_chars[p]);
+ putchar(progress_chars[p]);
fflush(stdout);
}
/*
+ * Seed OpenSSL's random number generator
+ */
+void
+seed_rng()
+{
+ char buf[32];
+
+ get_random_bytes(buf, sizeof(buf));
+ RAND_seed(buf, sizeof(buf));
+ memset(buf, 0, sizeof(buf));
+}
+
+/*
* Generates RSA public and private keys. This initializes the data
* structures; they should be freed with rsa_clear_private_key and
* rsa_clear_public_key.
@@ -81,6 +95,8 @@
{
RSA *key;
+ seed_rng();
+
if (rsa_verbose) {
printf("Generating RSA keys: ");
fflush(stdout);