Allow select rand method.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20005 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -54,10 +54,13 @@ RCSID("$Id$");
|
|||||||
static int version_flag;
|
static int version_flag;
|
||||||
static int help_flag;
|
static int help_flag;
|
||||||
static int len = 1024 * 1024;
|
static int len = 1024 * 1024;
|
||||||
|
static char *rand_method;
|
||||||
|
|
||||||
static struct getargs args[] = {
|
static struct getargs args[] = {
|
||||||
{ "length", 0, arg_integer, &len,
|
{ "length", 0, arg_integer, &len,
|
||||||
"length", NULL },
|
"length", NULL },
|
||||||
|
{ "method", 0, arg_string, &rand_method,
|
||||||
|
"method", NULL },
|
||||||
{ "version", 0, arg_flag, &version_flag,
|
{ "version", 0, arg_flag, &version_flag,
|
||||||
"print version", NULL },
|
"print version", NULL },
|
||||||
{ "help", 0, arg_flag, &help_flag,
|
{ "help", 0, arg_flag, &help_flag,
|
||||||
@@ -109,10 +112,17 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
buffer = emalloc(len);
|
buffer = emalloc(len);
|
||||||
|
|
||||||
RAND_set_rand_method(RAND_fortuna_method());
|
if (rand_method) {
|
||||||
|
if (strcasecmp(rand_method, "fortuna") == 0)
|
||||||
RAND_seed(buffer, len);
|
RAND_set_rand_method(RAND_fortuna_method());
|
||||||
|
else if (strcasecmp(rand_method, "unix") == 0)
|
||||||
|
RAND_set_rand_method(RAND_unix_method());
|
||||||
|
else if (strcasecmp(rand_method, "egd") == 0)
|
||||||
|
RAND_set_rand_method(RAND_egd_method());
|
||||||
|
else
|
||||||
|
errx(1, "unknown method %s", rand_method);
|
||||||
|
}
|
||||||
|
|
||||||
if (RAND_status() != 1)
|
if (RAND_status() != 1)
|
||||||
errx(1, "random not ready yet");
|
errx(1, "random not ready yet");
|
||||||
|
|
||||||
@@ -123,5 +133,10 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
|
if (RAND_write_file("test.file") != 1)
|
||||||
|
errx(1, "RAND_write_file");
|
||||||
|
if (RAND_load_file("test.file", 1024) != 1)
|
||||||
|
errx(1, "RAND_load_file");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user