]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix a typo RSASHA236 -> RSASHA256
authorTony Finch <fanf@isc.org>
Fri, 9 Dec 2022 12:52:05 +0000 (12:52 +0000)
committerTony Finch <dot@dotat.at>
Wed, 14 Dec 2022 12:46:56 +0000 (12:46 +0000)
Use dns_secalg_format() to avoid error-prone repetition.

(cherry picked from commit c18a9a208d47d0ea27a396165fd895b7c1af2c25)

lib/dns/zone.c

index 0d85af24d26e492d3c3ff481514802bc6daa86b6..7d26ab705c90ffb8a338493147b24daa9970cfad 100644 (file)
@@ -3537,42 +3537,24 @@ zone_check_dnskeys(dns_zone_t *zone, dns_db_t *db) {
                 * fermat number).
                 */
                if (dnskey.datalen > 1 && dnskey.data[0] == 1 &&
-                   dnskey.data[1] == 3)
+                   dnskey.data[1] == 3 &&
+                   (dnskey.algorithm == DNS_KEYALG_RSAMD5 ||
+                    dnskey.algorithm == DNS_KEYALG_RSASHA1 ||
+                    dnskey.algorithm == DNS_KEYALG_NSEC3RSASHA1 ||
+                    dnskey.algorithm == DNS_KEYALG_RSASHA256 ||
+                    dnskey.algorithm == DNS_KEYALG_RSASHA512))
                {
-                       const char *algorithm = "";
+                       char algorithm[DNS_SECALG_FORMATSIZE];
                        isc_region_t r;
-                       bool logit = true;
 
                        dns_rdata_toregion(&rdata, &r);
+                       dns_secalg_format(dnskey.algorithm, algorithm,
+                                         sizeof(algorithm));
 
-                       switch (dnskey.algorithm) {
-                       case DNS_KEYALG_RSAMD5:
-                               algorithm = "RSAMD5";
-                               break;
-                       case DNS_KEYALG_RSASHA1:
-                               algorithm = "RSASHA1";
-                               break;
-                       case DNS_KEYALG_NSEC3RSASHA1:
-                               algorithm = "NSEC3RSASHA1";
-                               break;
-                       case DNS_KEYALG_RSASHA256:
-                               algorithm = "RSASHA236";
-                               break;
-                       case DNS_KEYALG_RSASHA512:
-                               algorithm = "RSASHA512";
-                               break;
-                       default:
-                               logit = false;
-                               break;
-                       }
-
-                       if (logit) {
-                               dnssec_log(zone, ISC_LOG_WARNING,
-                                          "weak %s (%u) key found "
-                                          "(exponent=3, id=%u)",
-                                          algorithm, dnskey.algorithm,
-                                          dst_region_computeid(&r));
-                       }
+                       dnssec_log(zone, ISC_LOG_WARNING,
+                                  "weak %s (%u) key found (exponent=3, id=%u)",
+                                  algorithm, dnskey.algorithm,
+                                  dst_region_computeid(&r));
                }
                dns_rdata_reset(&rdata);
        }