From: Bert Hubert Date: Thu, 6 Jan 2011 09:15:39 +0000 (+0000) Subject: implement 'narrow' NSEC3 generation w/o consulting the database ordering, based on... X-Git-Tag: auth-3.0~437 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=22c5aa60dedb111bf9a65994f4e90ed3eff94006;p=pdns implement 'narrow' NSEC3 generation w/o consulting the database ordering, based on an idea by Roy Arends & discussions with Dan Kaminsky. This will probably have to be tuned further. git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1810 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/dbdnsseckeeper.cc b/pdns/dbdnsseckeeper.cc index 41aece34a..7e47cc4c4 100644 --- a/pdns/dbdnsseckeeper.cc +++ b/pdns/dbdnsseckeeper.cc @@ -99,10 +99,16 @@ void DNSSECKeeper::activateKey(const std::string& zname, unsigned int id) d_db.activateDomainKey(zname, id); } -bool DNSSECKeeper::getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* ns3p) +bool DNSSECKeeper::getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* ns3p, bool* narrow) { - vector meta; + if(narrow) { + d_db.getDomainMetadata(zname, "NSEC3NARROW", meta); + *narrow=false; + if(!meta.empty() && meta[0]=="1") + *narrow=true; + } + meta.clear(); d_db.getDomainMetadata(zname, "NSEC3PARAM", meta); if(meta.empty()) @@ -122,12 +128,17 @@ bool DNSSECKeeper::getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordConte return true; } -void DNSSECKeeper::setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& ns3p) +void DNSSECKeeper::setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& ns3p, const bool& narrow) { string descr = ns3p.getZoneRepresentation(); vector meta; meta.push_back(descr); d_db.setDomainMetadata(zname, "NSEC3PARAM", meta); + + meta.clear(); + if(narrow) + meta.push_back("1"); + d_db.setDomainMetadata(zname, "NSEC3NARROW", meta); } void DNSSECKeeper::unsetNSEC3PARAM(const std::string& zname) diff --git a/pdns/dnsseckeeper.hh b/pdns/dnsseckeeper.hh index 00ec87752..1d117e662 100644 --- a/pdns/dnsseckeeper.hh +++ b/pdns/dnsseckeeper.hh @@ -116,8 +116,8 @@ public: void secureZone(const std::string& fname, int algorithm); - bool getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* n3p=0); - void setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& n3p); + bool getNSEC3PARAM(const std::string& zname, NSEC3PARAMRecordContent* n3p=0, bool* narrow=0); + void setNSEC3PARAM(const std::string& zname, const NSEC3PARAMRecordContent& n3p, const bool& narrow=false); void unsetNSEC3PARAM(const std::string& zname); }; diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 00bcae353..b3fe3c43a 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -512,7 +512,7 @@ void PacketHandler::emitNSEC3(const NSEC3PARAMRecordContent& ns3prc, const std:: rr.ttl=3600; rr.qtype=QType::NSEC3; rr.content=n3rc.getZoneRepresentation(); - cerr<<"nsec3: '"<addRecord(rr); @@ -530,9 +530,10 @@ void PacketHandler::addNSECX(DNSPacket *p, DNSPacket *r, const string& target, c { NSEC3PARAMRecordContent ns3rc; cerr<<"Doing NSEC3PARAM lookup for '"<qdomain<<"|"<qtype.getName()<<": "; - if(d_dk.getNSEC3PARAM(auth, &ns3rc)) { - cerr<<"Present"<getBeforeAndAfterNamesAbsolute(id, hashed, unhashed, before, after); + } + // cerr<<"rgetNSEC3Hashes: "<qdomain))); - sd.db->getBeforeAndAfterNamesAbsolute(sd.domain_id, hashed, unhashed, before, after); + unhashed = p->qdomain; + hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3rc.d_iterations, ns3rc.d_salt, unhashed))); + getNSEC3Hashes(narrow, sd.db,sd.domain_id, hashed, unhashed, before, after); cerr<<"Done calling for main, before='"<getBeforeAndAfterNamesAbsolute(sd.domain_id, hashed, unhashed, before, after); + unhashed=dotConcat("*", auth); + hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3rc.d_iterations, ns3rc.d_salt, unhashed))); + + getNSEC3Hashes(narrow, sd.db, sd.domain_id, hashed, unhashed, before, after); cerr<<"Done calling for '*', before='"< 2 ? cmds[2] : "1 0 1 ab"; - + bool narrow = cmds.size() > 3 && cmds[3]=="narrow"; NSEC3PARAMRecordContent ns3pr(nsec3params); - dk.setNSEC3PARAM(cmds[1], ns3pr); + dk.setNSEC3PARAM(cmds[1], ns3pr, narrow); } else if(cmds[0]=="unset-nsec3") { dk.unsetNSEC3PARAM(cmds[1]);