/** test dname_is_wild routine */ static void dname_test_iswild(void) { unit_show_func("util/data/dname.c", "dname_iswild"); unit_assert( !dname_is_wild((uint8_t*)"\000") ); unit_assert( dname_is_wild((uint8_t*)"\001*\000") ); unit_assert( !dname_is_wild((uint8_t*)"\003net\000") ); unit_assert( dname_is_wild((uint8_t*)"\001*\003net\000") ); }
int val_rrset_wildcard(struct ub_packed_rrset_key* rrset, uint8_t** wc) { struct packed_rrset_data* d = (struct packed_rrset_data*)rrset-> entry.data; uint8_t labcount; int labdiff; uint8_t* wn; size_t i, wl; if(d->rrsig_count == 0) { return 1; } labcount = rrsig_get_labcount(d, d->count + 0); /* check rest of signatures identical */ for(i=1; i<d->rrsig_count; i++) { if(labcount != rrsig_get_labcount(d, d->count + i)) { return 0; } } /* OK the rrsigs check out */ /* if the RRSIG label count is shorter than the number of actual * labels, then this rrset was synthesized from a wildcard. * Note that the RRSIG label count doesn't count the root label. */ wn = rrset->rk.dname; wl = rrset->rk.dname_len; /* skip a leading wildcard label in the dname (RFC4035 2.2) */ if(dname_is_wild(wn)) { wn += 2; wl -= 2; } labdiff = (dname_count_labels(wn) - 1) - (int)labcount; if(labdiff > 0) { *wc = wn; dname_remove_labels(wc, &wl, labdiff); return 1; } return 1; }