diff --git a/lib/dns/include/dns/rdata.h b/lib/dns/include/dns/rdata.h index 257a22c9fd..51dc0804b8 100644 --- a/lib/dns/include/dns/rdata.h +++ b/lib/dns/include/dns/rdata.h @@ -572,6 +572,13 @@ dns_rdatatype_isdnssec(dns_rdatatype_t type); * \li 'type' is a valid rdata type. */ +bool +dns_rdatatype_iskeymaterial(dns_rdatatype_t type); +/*%< + * Return true iff the rdata type 'type' is a DNSSEC key + * related type, like DNSKEY, CDNSKEY, or CDS. + */ + bool dns_rdatatype_iszonecutauth(dns_rdatatype_t type); /*%< diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 592b9746da..227dfbc795 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -2262,6 +2262,12 @@ dns_rdatatype_isdnssec(dns_rdatatype_t type) { return (false); } +bool +dns_rdatatype_iskeymaterial(dns_rdatatype_t type) { + return (type == dns_rdatatype_dnskey || type == dns_rdatatype_cdnskey || + type == dns_rdatatype_cds); +} + bool dns_rdatatype_iszonecutauth(dns_rdatatype_t type) { if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_ZONECUTAUTH) != diff --git a/lib/dns/update.c b/lib/dns/update.c index c3f162ad10..a94d35276e 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -1205,10 +1205,7 @@ add_sigs(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, } } - if (type == dns_rdatatype_dnskey || - type == dns_rdatatype_cdnskey || - type == dns_rdatatype_cds) - { + if (dns_rdatatype_iskeymaterial(type)) { /* * DNSKEY RRset is signed with KSK. * CDS and CDNSKEY RRsets too (RFC 7344, 4.1). @@ -1242,10 +1239,7 @@ add_sigs(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, /* * CDS and CDNSKEY are signed with KSK (RFC 7344, 4.1). */ - if (type == dns_rdatatype_dnskey || - type == dns_rdatatype_cdnskey || - type == dns_rdatatype_cds) - { + if (dns_rdatatype_iskeymaterial(type)) { if (!KSK(keys[i]) && keyset_kskonly) { continue; } @@ -1675,10 +1669,7 @@ next_state: &flag)); if (flag) { isc_stdtime_t exp; - if (type == dns_rdatatype_dnskey || - type == dns_rdatatype_cdnskey || - type == dns_rdatatype_cds) - { + if (dns_rdatatype_iskeymaterial(type)) { exp = state->keyexpire; } else if (type == dns_rdatatype_soa) { exp = state->soaexpire; diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 02e3890c6f..8897a46123 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -6777,9 +6777,7 @@ del_sigs(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, result = dns_rdata_tostruct(&rdata, &rrsig, NULL); RUNTIME_CHECK(result == ISC_R_SUCCESS); - if (type != dns_rdatatype_dnskey && type != dns_rdatatype_cds && - type != dns_rdatatype_cdnskey) - { + if (!dns_rdatatype_iskeymaterial(type)) { bool warn = false, deleted = false; if (delsig_ok(&rrsig, keys, nkeys, kasp, &warn)) { result = update_one_rr(db, ver, zonediff->diff, @@ -7097,10 +7095,7 @@ add_sigs(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, dns_zone_t *zone, both = have_ksk && have_zsk; } - if (type == dns_rdatatype_dnskey || - type == dns_rdatatype_cdnskey || - type == dns_rdatatype_cds) - { + if (dns_rdatatype_iskeymaterial(type)) { /* * DNSKEY RRset is signed with KSK. * CDS and CDNSKEY RRsets too (RFC 7344, 4.1). @@ -7140,10 +7135,7 @@ add_sigs(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name, dns_zone_t *zone, /* * CDS and CDNSKEY are signed with KSK (RFC 7344, 4.1). */ - if (type == dns_rdatatype_dnskey || - type == dns_rdatatype_cdnskey || - type == dns_rdatatype_cds) - { + if (dns_rdatatype_iskeymaterial(type)) { if (!KSK(keys[i]) && keyset_kskonly) { continue; } @@ -7545,9 +7537,7 @@ signed_with_good_key(dns_zone_t *zone, dns_db_t *db, dns_dbnode_t *node, } KASP_UNLOCK(kasp); - if (type == dns_rdatatype_dnskey || - type == dns_rdatatype_cdnskey || type == dns_rdatatype_cds) - { + if (dns_rdatatype_iskeymaterial(type)) { /* * CDS and CDNSKEY are signed with KSK like DNSKEY. * (RFC 7344, section 4.1 specifies that they must @@ -7723,10 +7713,7 @@ sign_a_node(dns_db_t *db, dns_zone_t *zone, dns_name_t *name, { goto next_rdataset; } - if (rdataset.type == dns_rdatatype_dnskey || - rdataset.type == dns_rdatatype_cdnskey || - rdataset.type == dns_rdatatype_cds) - { + if (dns_rdatatype_iskeymaterial(rdataset.type)) { /* * CDS and CDNSKEY are signed with KSK like DNSKEY. * (RFC 7344, section 4.1 specifies that they must @@ -8324,9 +8311,7 @@ dns__zone_updatesigs(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *version, isc_stdtime_t exp = expire; if (keyexpire != 0 && - (tuple->rdata.type == dns_rdatatype_dnskey || - tuple->rdata.type == dns_rdatatype_cdnskey || - tuple->rdata.type == dns_rdatatype_cds)) + dns_rdatatype_iskeymaterial(tuple->rdata.type)) { exp = keyexpire; } diff --git a/lib/ns/query.c b/lib/ns/query.c index c1e91484cf..7c98d1ab47 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -12352,9 +12352,7 @@ ns_query_start(ns_client_t *client, isc_nmhandle_t *handle) { /* * Turn on minimal response for (C)DNSKEY and (C)DS queries. */ - if (qtype == dns_rdatatype_dnskey || qtype == dns_rdatatype_ds || - qtype == dns_rdatatype_cdnskey || qtype == dns_rdatatype_cds) - { + if (dns_rdatatype_iskeymaterial(qtype) || qtype == dns_rdatatype_ds) { client->query.attributes |= (NS_QUERYATTR_NOAUTHORITY | NS_QUERYATTR_NOADDITIONAL); } else if (qtype == dns_rdatatype_ns) { diff --git a/lib/ns/update.c b/lib/ns/update.c index 983ca84e26..dfba72db5e 100644 --- a/lib/ns/update.c +++ b/lib/ns/update.c @@ -3390,6 +3390,29 @@ update_action(isc_task_t *task, isc_event_t *event) { continue; } } +#if 0 + /* + * Don't remove DNSKEY, CDNSKEY, CDS records + * that are in use (under our control). + */ + if (dns_rdatatype_iskeymaterial(rdata.type)) { + isc_result_t r; + bool inuse = false; + r = dns_zone_dnskey_inuse(zone, &rdata, + &inuse); + if (r != ISC_R_SUCCESS) { + FAIL(r); + } + if (inuse) { + update_log(client, zone, + LOGLEVEL_PROTOCOL, + "attempt to " + "delete in use " + "DNSKEY ignored"); + continue; + } + } +#endif } dns_name_format(name, namestr, sizeof(namestr)); dns_rdatatype_format(rdata.type, typestr,