From 918233d224c7683cc11adb49f8059fb9fbbfb8ef Mon Sep 17 00:00:00 2001 From: Arthur Goodluck Date: Thu, 28 Mar 2013 15:32:36 +0000 Subject: [PATCH 1/3] Echo of random seedfile can be null. The error message was created from the 'optargs' variable which is only correct if the -s whatever was the last item on the command line. --- oclvanitygen.c | 2 +- vanitygen.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/oclvanitygen.c b/oclvanitygen.c index 9755ef6..f80e1b3 100644 --- a/oclvanitygen.c +++ b/oclvanitygen.c @@ -313,7 +313,7 @@ main(int argc, char **argv) #endif opt = RAND_load_file(seedfile, opt); if (!opt) { - fprintf(stderr, "Could not load RNG seed %s\n", optarg); + fprintf(stderr, "Could not load RNG seed '%s'\n", seedfile); return 1; } if (verbose > 0) { diff --git a/vanitygen.c b/vanitygen.c index 9d88121..497693f 100644 --- a/vanitygen.c +++ b/vanitygen.c @@ -527,7 +527,7 @@ main(int argc, char **argv) #endif opt = RAND_load_file(seedfile, opt); if (!opt) { - fprintf(stderr, "Could not load RNG seed %s\n", optarg); + fprintf(stderr, "Could not load RNG seed '%s'\n", seedfile); return 1; } if (verbose > 0) { From 7a3dec8a2c26fbf74e73df857cbc63032f9f4a06 Mon Sep 17 00:00:00 2001 From: Arthur Goodluck Date: Thu, 28 Mar 2013 15:42:52 +0000 Subject: [PATCH 2/3] Use /dev/random by default if available. General security principle, always default to the most secure option. If someone wants to -s /dev/zero the still can of course, but we assume they know what they are doing! Not all non windows platforms have a /dev/random, you can disable it on Linux if you really want to, so we check first. --- oclvanitygen.c | 11 +++++++++++ vanitygen.c | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/oclvanitygen.c b/oclvanitygen.c index f80e1b3..975c777 100644 --- a/oclvanitygen.c +++ b/oclvanitygen.c @@ -302,6 +302,17 @@ main(int argc, char **argv) "WARNING: case insensitive mode incompatible with " "regular expressions\n"); + if (!seedfile) + { +#if !defined(_WIN32) + struct stat st; + if (stat("/dev/random", &st) == 0) + { + seedfile = "/dev/random"; + } +#endif + } + if (seedfile) { opt = -1; #if !defined(_WIN32) diff --git a/vanitygen.c b/vanitygen.c index 497693f..e9f0b8b 100644 --- a/vanitygen.c +++ b/vanitygen.c @@ -516,6 +516,17 @@ main(int argc, char **argv) addrtype = scriptaddrtype; } + if (!seedfile) + { +#if !defined(_WIN32) + struct stat st; + if (stat("/dev/random", &st) == 0) + { + seedfile = "/dev/random"; + } +#endif + } + if (seedfile) { opt = -1; #if !defined(_WIN32) From 2b166b48ad1ec1864367a9a6c11d9ca2274db1b2 Mon Sep 17 00:00:00 2001 From: Arthur Goodluck Date: Thu, 28 Mar 2013 15:50:24 +0000 Subject: [PATCH 3/3] Downgraded RNG seed message to -v only Now we read from /dev/random by default, this message isn't really that important anymore. --- oclvanitygen.c | 2 +- vanitygen.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/oclvanitygen.c b/oclvanitygen.c index 975c777..e0e1cef 100644 --- a/oclvanitygen.c +++ b/oclvanitygen.c @@ -327,7 +327,7 @@ main(int argc, char **argv) fprintf(stderr, "Could not load RNG seed '%s'\n", seedfile); return 1; } - if (verbose > 0) { + if (verbose > 1) { fprintf(stderr, "Read %d bytes from RNG seed file\n", opt); } diff --git a/vanitygen.c b/vanitygen.c index e9f0b8b..2300b42 100644 --- a/vanitygen.c +++ b/vanitygen.c @@ -541,7 +541,7 @@ main(int argc, char **argv) fprintf(stderr, "Could not load RNG seed '%s'\n", seedfile); return 1; } - if (verbose > 0) { + if (verbose > 1) { fprintf(stderr, "Read %d bytes from RNG seed file\n", opt); }