Use strtottl() for the -T option, and make a new strtodigest()
function for parsing DS digest type names.
---
bin/dnssec/dnssec-dsfromkey.c | 24 +++---------------------
bin/dnssec/dnssectool.c | 19 +++++++++++++++++++
bin/dnssec/dnssectool.h | 3 +++
3 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/bin/dnssec/dnssec-dsfromkey.c b/bin/dnssec/dnssec-dsfromkey.c
index ad44c3c..8597d05 100644
--- a/bin/dnssec/dnssec-dsfromkey.c
+++ b/bin/dnssec/dnssec-dsfromkey.c
@@ -346,7 +346,7 @@ usage(void) {
int
main(int argc, char **argv) {
- char *algname = NULL, *classname = NULL;
+ char *classname = NULL;
char *filename = NULL, *dir = NULL, *namestr;
char *lookaside = NULL;
char *endp;
@@ -393,7 +393,7 @@ main(int argc, char **argv) {
showall = ISC_TRUE;
break;
case 'a':
- algname = isc_commandline_argument;
+ dtype = strtodsdigest(isc_commandline_argument);
both = ISC_FALSE;
break;
case 'C':
@@ -430,7 +430,7 @@ main(int argc, char **argv) {
break;
case 'T':
emitttl = ISC_TRUE;
- ttl = atol(isc_commandline_argument);
+ ttl = strtottl(isc_commandline_argument);
break;
case 'v':
verbose = strtol(isc_commandline_argument, &endp, 0);
@@ -460,24 +460,6 @@ main(int argc, char **argv) {
}
}
- if (algname != NULL) {
- if (strcasecmp(algname, "SHA1") == 0 ||
- strcasecmp(algname, "SHA-1") == 0)
- dtype = DNS_DSDIGEST_SHA1;
- else if (strcasecmp(algname, "SHA256") == 0 ||
- strcasecmp(algname, "SHA-256") == 0)
- dtype = DNS_DSDIGEST_SHA256;
-#if defined(HAVE_OPENSSL_GOST) || defined(HAVE_PKCS11_GOST)
- else if (strcasecmp(algname, "GOST") == 0)
- dtype = DNS_DSDIGEST_GOST;
-#endif
- else if (strcasecmp(algname, "SHA384") == 0 ||
- strcasecmp(algname, "SHA-384") == 0)
- dtype = DNS_DSDIGEST_SHA384;
- else
- fatal("unknown algorithm %s", algname);
- }
-
rdclass = strtoclass(classname);
if (usekeyset && filename != NULL)
diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c
index 908a2bc..6e67391 100644
--- a/bin/dnssec/dnssectool.c
+++ b/bin/dnssec/dnssectool.c
@@ -414,6 +414,25 @@ strtoclass(const char *str) {
return (rdclass);
}
+unsigned int
+strtodsdigest(const char *algname) {
+ if (strcasecmp(algname, "SHA1") == 0 ||
+ strcasecmp(algname, "SHA-1") == 0)
+ return (DNS_DSDIGEST_SHA1);
+ else if (strcasecmp(algname, "SHA256") == 0 ||
+ strcasecmp(algname, "SHA-256") == 0)
+ return (DNS_DSDIGEST_SHA256);
+#if defined(HAVE_OPENSSL_GOST) || defined(HAVE_PKCS11_GOST)
+ else if (strcasecmp(algname, "GOST") == 0)
+ return (DNS_DSDIGEST_GOST);
+#endif
+ else if (strcasecmp(algname, "SHA384") == 0 ||
+ strcasecmp(algname, "SHA-384") == 0)
+ return (DNS_DSDIGEST_SHA384);
+ else
+ fatal("unknown algorithm %s", algname);
+}
+
isc_result_t
try_dir(const char *dirname) {
isc_result_t result;
diff --git a/bin/dnssec/dnssectool.h b/bin/dnssec/dnssectool.h
index 13cbf33..8de518b 100644
--- a/bin/dnssec/dnssectool.h
+++ b/bin/dnssec/dnssectool.h
@@ -65,6 +65,9 @@ isc_stdtime_t
strtotime(const char *str, isc_int64_t now, isc_int64_t base,
isc_boolean_t *setp);
+unsigned int
+strtodsdigest(const char *str);
+
dns_rdataclass_t
strtoclass(const char *str);
--
2.10.1.445.g3cdd5d1