diff options
Diffstat (limited to 'rsa.c')
-rw-r--r-- | rsa.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -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 @@ 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); } /* + * 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_generate_key(RSA *prv, RSA *pub, unsigned int bits) { RSA *key; + seed_rng(); + if (rsa_verbose) { printf("Generating RSA keys: "); fflush(stdout); |