Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ldns_rr_compare_{ds,ds_dnskey}() available for CDS and CDNSKEY RRs #248

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions rr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand Down
Loading