summaryrefslogtreecommitdiff
path: root/rr.c
diff options
context:
space:
mode:
authorJelte Jansen <jelte@NLnetLabs.nl>2009-07-21 10:35:35 +0200
committerJelte Jansen <jelte@NLnetLabs.nl>2009-07-21 10:35:35 +0200
commit72f186d742d78a68ad551e73b0017ab82f40288c (patch)
treeda9c47733a15ad87cb20c4fb658f5f0d7f8f6b22 /rr.c
parent3866a6c7e3314f30d21454985ee16d57b94935e4 (diff)
downloadldns-72f186d742d78a68ad551e73b0017ab82f40288c.tar.gz
don't guess, simply derive hash algorithm from ds
Diffstat (limited to 'rr.c')
-rw-r--r--rr.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/rr.c b/rr.c
index ef2405db..5a9dfbde 100644
--- a/rr.c
+++ b/rr.c
@@ -1501,13 +1501,19 @@ ldns_rr_compare(const ldns_rr *rr1, const ldns_rr *rr2)
* then compare the result with the given ds */
static int
ldns_rr_compare_ds_dnskey(ldns_rr *ds,
- ldns_rr *dnskey,
- ldns_algorithm algo)
+ ldns_rr *dnskey)
{
ldns_rr *ds_gen;
bool result = false;
+ ldns_algorithm algo;
- if (!dnskey || !ds) return false;
+ if (!dnskey || !ds ||
+ ldns_rr_get_type(ds) != LDNS_RR_TYPE_DS ||
+ ldns_rr_get_type(dnskey) != LDNS_RR_TYPE_DNSKEY) {
+ return false;
+ }
+
+ algo = ldns_rdf2native_int8(ldns_rr_rdf(ds, 2));
ds_gen = ldns_key_rr2ds(dnskey, algo);
if (ds_gen) {
@@ -1530,22 +1536,10 @@ ldns_rr_compare_ds(const ldns_rr *orr1, const ldns_rr *orr2)
if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DS &&
ldns_rr_get_type(rr2) == LDNS_RR_TYPE_DNSKEY) {
- result = ldns_rr_compare_ds_dnskey(rr1, rr2, LDNS_SHA1);
- if (!result) {
- /* also try SHA2 DS */
- result = ldns_rr_compare_ds_dnskey(rr1,
- rr2,
- LDNS_SHA256);
- }
+ result = ldns_rr_compare_ds_dnskey(rr1, rr2);
} 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, LDNS_SHA1);
- if (!result) {
- /* also try SHA2 DS */
- result = ldns_rr_compare_ds_dnskey(rr2,
- rr1,
- LDNS_SHA256);
- }
+ result = ldns_rr_compare_ds_dnskey(rr2, rr1);
} else {
result = (ldns_rr_compare(rr1, rr2) == 0);
}