#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);
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);
}
{
RSA *key;
+ seed_rng();
+
if (rsa_verbose) {
printf("Generating RSA keys: ");
fflush(stdout);