Commit 3d3e7bce authored by Brian Wellington's avatar Brian Wellington
Browse files

Add '-r randomfile' option to all tools

parent d08577ac
......@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-keygen.c,v 1.33 2000/06/09 22:34:17 bwelling Exp $ */
/* $Id: dnssec-keygen.c,v 1.34 2000/06/10 01:28:06 bwelling Exp $ */
#include <config.h>
......@@ -76,6 +76,8 @@ usage(void) {
"3 (dnssec) for all others\n");
printf(" -s strength value this key signs DNS records with\n");
printf(" default: 0\n");
printf(" -r randomdev\n");
printf(" a file containing random data\n");
printf(" -v verbose level\n");
exit (-1);
......@@ -84,6 +86,7 @@ usage(void) {
int
main(int argc, char **argv) {
char *algname = NULL, *nametype = NULL, *type = NULL;
char *randomfile = NULL;
char *prog, *endp;
dst_key_t *key = NULL, *oldkey;
dns_fixedname_t fname;
......@@ -116,7 +119,7 @@ main(int argc, char **argv) {
dns_result_register();
while ((ch = isc_commandline_parse(argc, argv,
"a:b:eg:n:t:p:s:hv:")) != -1)
"a:b:eg:n:t:p:s:hr:v:")) != -1)
{
switch (ch) {
case 'a':
......@@ -163,6 +166,12 @@ main(int argc, char **argv) {
fatal("-s must be followed by a number "
"[0..15]");
break;
case 'r':
randomfile = isc_mem_strdup(mctx,
isc_commandline_argument);
if (randomfile == NULL)
fatal("out of memory");
break;
case 'v':
endp = NULL;
verbose = strtol(isc_commandline_argument, &endp, 0);
......@@ -179,7 +188,9 @@ main(int argc, char **argv) {
}
}
setup_entropy(mctx, &ectx);
setup_entropy(mctx, randomfile, &ectx);
if (randomfile != NULL)
isc_mem_free(mctx, randomfile);
ret = dst_lib_init(mctx, ectx,
ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY);
if (ret != ISC_R_SUCCESS)
......@@ -317,8 +328,9 @@ main(int argc, char **argv) {
mctx, &key);
if (ret != ISC_R_SUCCESS) {
fatal("failed to generate key %s/%d: %s\n",
nametostr(name), alg, dst_result_totext(ret));
fatal("failed to generate key %s/%s: %s\n",
nametostr(name), algtostr(alg),
dst_result_totext(ret));
exit(-1);
}
......
......@@ -101,6 +101,8 @@ usage(void) {
fprintf(stderr, "\t\tSIG end time - "
"absolute|from start|from now (now + 30 days)\n");
fprintf(stderr, "\t-t ttl\n");
fprintf(stderr, "\t-r randomdev:\n");
fprintf(stderr, "\t\ta file containing random data\n");
fprintf(stderr, "\t-v level:\n");
fprintf(stderr, "\t\tverbose level (0)\n");
......@@ -115,6 +117,7 @@ int
main(int argc, char *argv[]) {
int i, ch;
char *startstr = NULL, *endstr = NULL;
char *randomfile = NULL;
dns_fixedname_t fdomain;
dns_name_t *domain = NULL;
char *output = NULL;
......@@ -141,7 +144,7 @@ main(int argc, char *argv[]) {
dns_result_register();
while ((ch = isc_commandline_parse(argc, argv, "s:e:t:v:")) != -1)
while ((ch = isc_commandline_parse(argc, argv, "s:e:t:r:v:")) != -1)
{
switch (ch) {
case 's':
......@@ -165,6 +168,13 @@ main(int argc, char *argv[]) {
fatal("TTL must be numeric");
break;
case 'r':
randomfile = isc_mem_strdup(mctx,
isc_commandline_argument);
if (randomfile == NULL)
fatal("out of memory");
break;
case 'v':
endp = NULL;
verbose = strtol(isc_commandline_argument, &endp, 0);
......@@ -184,7 +194,9 @@ main(int argc, char *argv[]) {
if (argc < 1)
usage();
setup_entropy(mctx, &ectx);
setup_entropy(mctx, randomfile, &ectx);
if (randomfile != NULL)
isc_mem_free(mctx, randomfile);
result = dst_lib_init(mctx, ectx,
ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY);
if (result != ISC_R_SUCCESS)
......
......@@ -70,6 +70,8 @@ usage(void) {
fprintf(stderr, "Options: (default value in parenthesis) \n");
fprintf(stderr, "\t-v level:\n");
fprintf(stderr, "\t\tverbose level (0)\n");
fprintf(stderr, "\t-r randomdev:\n");
fprintf(stderr, "\t\ta file containing random data\n");
fprintf(stderr, "\n");
......@@ -136,6 +138,7 @@ main(int argc, char *argv[]) {
char *output = NULL;
char *endp;
unsigned char *data;
char *randomfile = NULL;
dns_db_t *db;
dns_dbnode_t *node;
dns_dbversion_t *version;
......@@ -155,9 +158,16 @@ main(int argc, char *argv[]) {
dns_result_register();
while ((ch = isc_commandline_parse(argc, argv, "v:")) != -1)
while ((ch = isc_commandline_parse(argc, argv, "r:v:")) != -1)
{
switch (ch) {
case 'r':
randomfile = isc_mem_strdup(mctx,
isc_commandline_argument);
if (randomfile == NULL)
fatal("out of memory");
break;
case 'v':
endp = NULL;
verbose = strtol(isc_commandline_argument, &endp, 0);
......@@ -177,7 +187,9 @@ main(int argc, char *argv[]) {
if (argc < 2)
usage();
setup_entropy(mctx, &ectx);
setup_entropy(mctx, randomfile, &ectx);
if (randomfile != NULL)
isc_mem_free(mctx, randomfile);
result = dst_lib_init(mctx, ectx,
ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY);
if (result != ISC_R_SUCCESS)
......
......@@ -1190,8 +1190,9 @@ usage(void) {
fprintf(stderr, "\t\tfile the signed zone is written in "
"(zonefile + .signed)\n");
fprintf(stderr, "\t-a:\n");
fprintf(stderr, "\t\tverify generated signatures "
"(if currently valid)\n");
fprintf(stderr, "\t\tverify generated signatures\n");
fprintf(stderr, "\t-r randomdev:\n");
fprintf(stderr, "\t\ta file containing random data\n");
fprintf(stderr, "\n");
......@@ -1206,6 +1207,7 @@ main(int argc, char *argv[]) {
int i, ch;
char *startstr = NULL, *endstr = NULL;
char *origin = NULL, *file = NULL, *output = NULL;
char *randomfile = NULL;
char *endp;
dns_db_t *db;
dns_dbversion_t *version;
......@@ -1219,7 +1221,7 @@ main(int argc, char *argv[]) {
dns_result_register();
while ((ch = isc_commandline_parse(argc, argv, "s:e:c:v:o:f:ah"))
while ((ch = isc_commandline_parse(argc, argv, "s:e:c:v:o:f:ahr:"))
!= -1) {
switch (ch) {
case 's':
......@@ -1243,6 +1245,13 @@ main(int argc, char *argv[]) {
fatal("cycle period must be numeric");
break;
case 'r':
randomfile = isc_mem_strdup(mctx,
isc_commandline_argument);
if (randomfile == NULL)
fatal("out of memory");
break;
case 'v':
endp = NULL;
verbose = strtol(isc_commandline_argument, &endp, 0);
......@@ -1275,7 +1284,9 @@ main(int argc, char *argv[]) {
}
}
setup_entropy(mctx, &ectx);
setup_entropy(mctx, randomfile, &ectx);
if (randomfile != NULL)
isc_mem_free(mctx, randomfile);
result = dst_lib_init(mctx, ectx,
ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY);
if (result != ISC_R_SUCCESS)
......
......@@ -35,7 +35,7 @@
extern int verbose;
extern const char *program;
static isc_entropysource_t *devrandom = NULL;
static isc_entropysource_t *filesource = NULL;
void
fatal(const char *format, ...) {
......@@ -169,18 +169,27 @@ setup_logging(int verbose, isc_mem_t *mctx, isc_log_t **logp) {
}
void
setup_entropy(isc_mem_t *mctx, isc_entropy_t **ectx) {
setup_entropy(isc_mem_t *mctx, const char *randomfile, isc_entropy_t **ectx) {
isc_result_t result;
result = isc_entropy_create(mctx, ectx);
if (result != ISC_R_SUCCESS)
fatal("could not create entropy object");
(void) isc_entropy_createfilesource(*ectx, "/dev/random", 0,
&devrandom);
if (randomfile != NULL) {
result = isc_entropy_createfilesource(*ectx, randomfile, 0,
&filesource);
if (result == ISC_R_SUCCESS)
return;
}
result = isc_entropy_createfilesource(*ectx, "/dev/random", 0,
&filesource);
if (result != ISC_R_SUCCESS)
fatal("No randomfile specified, and /dev/random not present.");
return;
}
void
cleanup_entropy(isc_entropy_t **ectx) {
if (devrandom != NULL)
isc_entropy_destroysource(&devrandom);
if (filesource != NULL)
isc_entropy_destroysource(&filesource);
isc_entropy_detach(ectx);
}
......@@ -40,7 +40,7 @@ void
setup_logging(int verbose, isc_mem_t *mctx, isc_log_t **logp);
void
setup_entropy(isc_mem_t *mctx, isc_entropy_t **ectx);
setup_entropy(isc_mem_t *mctx, const char *randomfile, isc_entropy_t **ectx);
void
cleanup_entropy(isc_entropy_t **ectx);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment