Gabriel Kihlman <[email protected]> writes:
> I wanted to wait longer when creating new keys so here is a simple
> diff to add an argument to be able to set rounds to something larger
> than a hardcoded 42.
..and this time calling errx with the errstr from strtonum as one should.
Index: signify.c
===================================================================
RCS file: /cvs/src/usr.bin/signify/signify.c,v
retrieving revision 1.126
diff -u -p -u -r1.126 signify.c
--- signify.c 6 Oct 2016 22:38:25 -0000 1.126
+++ signify.c 5 Mar 2017 15:10:00 -0000
@@ -79,7 +79,7 @@ usage(const char *error)
fprintf(stderr, "usage:"
#ifndef VERIFYONLY
"\t%1$s -C [-q] -p pubkey -x sigfile [file ...]\n"
- "\t%1$s -G [-n] [-c comment] -p pubkey -s seckey\n"
+ "\t%1$s -G [-n] [-c comment] -p pubkey -s seckey [-r rounds]\n"
"\t%1$s -S [-ez] [-x sigfile] -s seckey -m message\n"
#endif
"\t%1$s -V [-eqz] [-p pubkey] [-t keytype] [-x sigfile] -m
message\n",
@@ -751,6 +751,7 @@ main(int argc, char **argv)
*sigfile = NULL;
char sigfilebuf[PATH_MAX];
const char *comment = "signify";
+ const char *errstr = NULL;
char *keytype = NULL;
int ch, rounds;
int embedded = 0;
@@ -769,7 +770,7 @@ main(int argc, char **argv)
rounds = 42;
- while ((ch = getopt(argc, argv, "CGSVzc:em:np:qs:t:x:")) != -1) {
+ while ((ch = getopt(argc, argv, "CGSVzc:em:np:qs:t:x:r:")) != -1) {
switch (ch) {
#ifndef VERIFYONLY
case 'C':
@@ -790,6 +791,10 @@ main(int argc, char **argv)
case 'z':
gzip = 1;
break;
+ case 'r':
+ rounds = strtonum(optarg, 42, (1U << 31) - 1, &errstr);
+ if (errstr != NULL)
+ errx(1, "rounds: %s", errstr);
#endif
case 'V':
if (verb)