]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
cleanup: more consistent abbreviated DS digest type mnemonics
authorTony Finch <dot@dotat.at>
Wed, 2 Oct 2019 18:43:09 +0000 (19:43 +0100)
committerOndřej Surý <ondrej@isc.org>
Thu, 10 Oct 2019 16:31:39 +0000 (12:31 -0400)
BIND supports the non-standard DNSKEY algorithm mnemonic ECDSA256
everywhere ECDSAP256SHA256 is allowed, and allows algorithm numbers
interchangeably with mnemonics. This is all done in one place by the
dns_secalg_fromtext() function.

DS digest types were less consistent: the rdata parser does not allow
abbreviations like SHA1, but the dnssec-* command line tools do; and
the command line tools do not alow numeric types though that is the
norm in rdata.

The command line tools now use the dns_dsdigest_fromtext() function
instead of rolling their own variant, and dns_dsdigest_fromtext() now
knows about abbreviated digest type mnemonics.

bin/dnssec/dnssectool.c
lib/dns/rcode.c

index 5ba2cc12663bbec3bcd1ac64b130c4e06f3fb54a..d409965fed51ba79737b471b8b53de9a36cf7f20 100644 (file)
@@ -314,35 +314,30 @@ dns_rdataclass_t
 strtoclass(const char *str) {
        isc_textregion_t r;
        dns_rdataclass_t rdclass;
-       isc_result_t ret;
+       isc_result_t result;
 
        if (str == NULL)
                return dns_rdataclass_in;
        DE_CONST(str, r.base);
        r.length = strlen(str);
-       ret = dns_rdataclass_fromtext(&rdclass, &r);
-       if (ret != ISC_R_SUCCESS)
+       result = dns_rdataclass_fromtext(&rdclass, &r);
+       if (result != ISC_R_SUCCESS)
                fatal("unknown class %s", 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);
-       } else if (strcasecmp(algname, "SHA384") == 0 ||
-                  strcasecmp(algname, "SHA-384") == 0)
-       {
-               return (DNS_DSDIGEST_SHA384);
-       } else {
-               fatal("unknown algorithm %s", algname);
-       }
+strtodsdigest(const char *str) {
+       isc_textregion_t r;
+       dns_dsdigest_t alg;
+       isc_result_t result;
+
+       DE_CONST(str, r.base);
+       r.length = strlen(str);
+       result = dns_dsdigest_fromtext(&alg, &r);
+       if (result != ISC_R_SUCCESS)
+               fatal("unknown DS algorithm %s", str);
+       return (alg);
 }
 
 static int
index 2853671d2c5f40723c03e11ed4e715253d2880e5..f9fe07cb04bd620be54c275b89a54602b7b57521 100644 (file)
 
 #define DSDIGESTNAMES \
        { DNS_DSDIGEST_SHA1, "SHA-1", 0 }, \
+       { DNS_DSDIGEST_SHA1, "SHA1", 0 }, \
        { DNS_DSDIGEST_SHA256, "SHA-256", 0 }, \
+       { DNS_DSDIGEST_SHA256, "SHA256", 0 }, \
        { DNS_DSDIGEST_GOST, "GOST", 0 }, \
        { DNS_DSDIGEST_SHA384, "SHA-384", 0 }, \
+       { DNS_DSDIGEST_SHA384, "SHA384", 0 }, \
        { 0, NULL, 0}
 
 struct tbl {