@@ -421,9 +421,8 @@ std::optional<NSEC3> find_matching_nsec3(const std::vector<RR> &nsec3_rrset, con
421421 const auto &nsec3 = std::get<NSEC3>(nsec3_rrset[0 ].data );
422422
423423 auto matching_domain = get_nsec3_domain (nsec3, domain, zone_domain);
424- for (const auto &nsec3_rr : nsec3_rrset) {
425- if (nsec3_rr.domain == matching_domain) return std::get<NSEC3>(nsec3_rr.data );
426- }
424+ auto nsec3_rr = std::ranges::find (nsec3_rrset, matching_domain, &RR::domain);
425+ if (nsec3_rr != nsec3_rrset.end ()) return std::get<NSEC3>(nsec3_rr->data );
427426 } catch (...) {
428427 }
429428 return std::nullopt ;
@@ -614,27 +613,26 @@ bool authenticate_name_error(const std::string &domain, const std::vector<RR> &n
614613 return false ;
615614}
616615
617- bool authenticate_no_ds (const std::string &domain, const std::vector<RR> &nsec3_rrset, const std::optional<RR> &nsec_rr ,
618- const std::string &zone_domain) {
616+ std::optional< bool > authenticate_no_ds (const std::string &domain, const std::vector<RR> &nsec3_rrset,
617+ const std::optional<RR> &nsec_rr, const std::string &zone_domain) {
619618 if (!nsec3_rrset.empty ()) {
620619 auto nsec3 = find_matching_nsec3 (nsec3_rrset, domain, zone_domain);
621620 if (nsec3.has_value ()) {
622- if (nsec3->types .contains (RRType::DS) || nsec3->types .contains (RRType::CNAME)) return false ;
623-
624- return true ;
621+ if (nsec3->types .contains (RRType::DS) || nsec3->types .contains (RRType::CNAME)) return std::nullopt ;
622+ return nsec3->types .contains (RRType::DNSKEY);
625623 }
626624
627625 // If no NSEC3 matches the name, the next closer NSEC3 must have opt out flag set.
628626 auto encloser_proof = verify_closest_encloser_proof (nsec3_rrset, domain, zone_domain);
629- return encloser_proof.has_value () && encloser_proof->next_closer_opt_out ;
627+ if (!encloser_proof.has_value () || !encloser_proof->next_closer_opt_out ) return std::nullopt ;
628+ return true ;
630629 }
631630
632- if (!nsec_rr.has_value () || nsec_rr->type != RRType::NSEC) return false ;
631+ if (!nsec_rr.has_value () || nsec_rr->type != RRType::NSEC) return std:: nullopt ;
633632 const auto &nsec = std::get<NSEC>(nsec_rr->data );
634633
635- if (nsec.types .contains (RRType::DS) || nsec.types .contains (RRType::CNAME)) return false ;
636-
637- return true ;
634+ if (nsec.types .contains (RRType::DS) || nsec.types .contains (RRType::CNAME)) return std::nullopt ;
635+ return nsec.types .contains (RRType::DNSKEY);
638636}
639637
640638bool authenticate_no_rrset (RRType rr_type, const std::string &domain, const std::vector<RR> &nsec3_rrset,
0 commit comments