]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Make ldns_rr_compare_ds() and ldns_rr_compare_ds_dnskey() available for CDS and CDNSK... 248/head
author[Thomas Green] <thomas.green@afnic.fr>
Tue, 27 Aug 2024 12:04:29 +0000 (14:04 +0200)
committer[Thomas Green] <thomas.green@afnic.fr>
Tue, 27 Aug 2024 12:04:29 +0000 (14:04 +0200)
rr.c

diff --git a/rr.c b/rr.c
index 16f08d3500aa6776d202255a0adc01356d6eef49..95d07d31c75b81962d344f5f1244721e2e0779b7 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -1681,8 +1681,8 @@ ldns_rr_compare(const ldns_rr *rr1, const ldns_rr *rr2)
        return result;
 }
 
-/* convert dnskey to a ds with the given algorithm,
- * then compare the result with the given ds */
+/* convert (c)dnskey to a (c)ds with the given algorithm,
+ * then compare the result with the given (c)ds */
 static int
 ldns_rr_compare_ds_dnskey(ldns_rr *ds,
                           ldns_rr *dnskey)
@@ -1692,8 +1692,10 @@ ldns_rr_compare_ds_dnskey(ldns_rr *ds,
        ldns_hash algo;
 
        if (!dnskey || !ds ||
-           ldns_rr_get_type(ds) != LDNS_RR_TYPE_DS ||
-           ldns_rr_get_type(dnskey) != LDNS_RR_TYPE_DNSKEY) {
+           (ldns_rr_get_type(ds) != LDNS_RR_TYPE_DS &&
+            ldns_rr_get_type(ds) != LDNS_RR_TYPE_CDS) ||
+           (ldns_rr_get_type(dnskey) != LDNS_RR_TYPE_DNSKEY &&
+            ldns_rr_get_type(dnskey) != LDNS_RR_TYPE_CDNSKEY)) {
                return false;
        }
 
@@ -1727,6 +1729,12 @@ ldns_rr_compare_ds(const ldns_rr *orr1, const ldns_rr *orr2)
        } else if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DNSKEY &&
            ldns_rr_get_type(rr2) == LDNS_RR_TYPE_DS) {
                result = ldns_rr_compare_ds_dnskey(rr2, rr1);
+       } else if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_CDS &&
+           ldns_rr_get_type(rr2) == LDNS_RR_TYPE_CDNSKEY) {
+               result = ldns_rr_compare_ds_dnskey(rr1, rr2);
+       } else if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_CDNSKEY &&
+           ldns_rr_get_type(rr2) == LDNS_RR_TYPE_CDS) {
+               result = ldns_rr_compare_ds_dnskey(rr2, rr1);
        } else {
                result = (ldns_rr_compare(rr1, rr2) == 0);
        }