diff options
Diffstat (limited to 'rsa.c')
-rw-r--r-- | rsa.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -35,11 +35,12 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include "includes.h" | 37 | #include "includes.h" |
38 | RCSID("$Id: rsa.c,v 1.6 1999/12/17 03:02:47 damien Exp $"); | 38 | RCSID("$Id: rsa.c,v 1.7 2000/01/29 09:40:22 damien Exp $"); |
39 | 39 | ||
40 | #include "rsa.h" | 40 | #include "rsa.h" |
41 | #include "ssh.h" | 41 | #include "ssh.h" |
42 | #include "xmalloc.h" | 42 | #include "xmalloc.h" |
43 | #include "random.h" | ||
43 | 44 | ||
44 | int rsa_verbose = 1; | 45 | int rsa_verbose = 1; |
45 | 46 | ||
@@ -64,13 +65,26 @@ keygen_progress(int p, int n, void *arg) | |||
64 | const char progress_chars[] = ".o+O?"; | 65 | const char progress_chars[] = ".o+O?"; |
65 | 66 | ||
66 | if ((p < 0) || (p > (sizeof(progress_chars) - 2))) | 67 | if ((p < 0) || (p > (sizeof(progress_chars) - 2))) |
67 | p = 4; | 68 | p = sizeof(progress_chars) - 2; |
68 | 69 | ||
69 | printf("%c", progress_chars[p]); | 70 | putchar(progress_chars[p]); |
70 | fflush(stdout); | 71 | fflush(stdout); |
71 | } | 72 | } |
72 | 73 | ||
73 | /* | 74 | /* |
75 | * Seed OpenSSL's random number generator | ||
76 | */ | ||
77 | void | ||
78 | seed_rng() | ||
79 | { | ||
80 | char buf[32]; | ||
81 | |||
82 | get_random_bytes(buf, sizeof(buf)); | ||
83 | RAND_seed(buf, sizeof(buf)); | ||
84 | memset(buf, 0, sizeof(buf)); | ||
85 | } | ||
86 | |||
87 | /* | ||
74 | * Generates RSA public and private keys. This initializes the data | 88 | * Generates RSA public and private keys. This initializes the data |
75 | * structures; they should be freed with rsa_clear_private_key and | 89 | * structures; they should be freed with rsa_clear_private_key and |
76 | * rsa_clear_public_key. | 90 | * rsa_clear_public_key. |
@@ -81,6 +95,8 @@ rsa_generate_key(RSA *prv, RSA *pub, unsigned int bits) | |||
81 | { | 95 | { |
82 | RSA *key; | 96 | RSA *key; |
83 | 97 | ||
98 | seed_rng(); | ||
99 | |||
84 | if (rsa_verbose) { | 100 | if (rsa_verbose) { |
85 | printf("Generating RSA keys: "); | 101 | printf("Generating RSA keys: "); |
86 | fflush(stdout); | 102 | fflush(stdout); |