diff options
author | Damien Miller <djm@mindrot.org> | 2000-01-29 20:40:22 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2000-01-29 20:40:22 +1100 |
commit | f07390e90da683fecbf55849a3cee6dc9b79a3e3 (patch) | |
tree | c9c7ad28557e08ff024da1e9a5302fc78d4de4f7 /rsa.c | |
parent | 4e61b79d5bcb3c5ac3014fe55be55214e23b2927 (diff) | |
download | openssh-git-f07390e90da683fecbf55849a3cee6dc9b79a3e3.tar.gz |
- Seed OpenSSL's random number generator before generating RSA keypairs
- Split random collector into seperate file
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); |