]> andersk Git - openssh.git/blobdiff - rsa.c
Update version
[openssh.git] / rsa.c
diff --git a/rsa.c b/rsa.c
index 54039b385e00ab830abe92bd211b011ed1580051..8db61a9be39f876229f339cefb40bd1900cca3fc 100644 (file)
--- a/rsa.c
+++ b/rsa.c
@@ -40,14 +40,29 @@ RCSID("$Id$");
 #include "rsa.h"
 #include "ssh.h"
 #include "xmalloc.h"
+#include "random.h"
 
 int rsa_verbose = 1;
 
+/*
+ * Seed OpenSSL's random number generator
+ */
+void
+seed_rng()
+{
+       char buf[64];
+
+       get_random_bytes(buf, sizeof(buf));
+       RAND_seed(buf, sizeof(buf));
+       memset(buf, 0, sizeof(buf));
+}
+
 int
 rsa_alive()
 {
        RSA *key;
 
+       seed_rng();
        key = RSA_generate_key(32, 3, NULL, NULL);
        if (key == NULL)
                return (0);
@@ -64,9 +79,9 @@ keygen_progress(int p, int n, void *arg)
        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);
 }
 
@@ -81,6 +96,8 @@ rsa_generate_key(RSA *prv, RSA *pub, unsigned int bits)
 {
        RSA *key;
 
+       seed_rng();
+       
        if (rsa_verbose) {
                printf("Generating RSA keys:  ");
                fflush(stdout);
This page took 0.036863 seconds and 4 git commands to generate.