From 1bad4190cbd388f08e8432be2db3443456e086bd Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Sat, 10 Aug 2013 23:07:48 +0200 Subject: [PATCH] toBase32Hex case flip --- pdns/backends/bind/bindbackend2.cc | 6 +++--- pdns/backends/gsql/gsqlbackend.cc | 2 +- pdns/base32.cc | 2 +- pdns/nsec3dig.cc | 4 ++-- pdns/packethandler.cc | 8 ++++---- pdns/pdnssec.cc | 4 ++-- pdns/rcpgenerator.cc | 2 +- pdns/rfc2136handler.cc | 14 +++++++------- pdns/slavecommunicator.cc | 2 +- pdns/tcpreceiver.cc | 2 +- pdns/test-base32_cc.cc | 12 ++++++------ 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/pdns/backends/bind/bindbackend2.cc b/pdns/backends/bind/bindbackend2.cc index 76c061f69c..9d6a4305bd 100644 --- a/pdns/backends/bind/bindbackend2.cc +++ b/pdns/backends/bind/bindbackend2.cc @@ -638,7 +638,7 @@ void Bind2Backend::doEmptyNonTerminals(shared_ptr stage, int id, bool nse { rr.qname=qname+"."+bb2.d_name+"."; if(nsec3zone) - hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname))); + hashed=toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname)); insert(stage, id, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed); } } @@ -741,7 +741,7 @@ void Bind2Backend::loadConfig(string* status) if(nsec3zone) { if(rr.qtype.getCode() != QType::NSEC3 && rr.qtype.getCode() != QType::RRSIG) - hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname))); + hashed=toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname)); else hashed=""; } @@ -872,7 +872,7 @@ void Bind2Backend::queueReload(BB2DomainInfo *bbd) if(nsec3zone) { if(rr.qtype.getCode() != QType::NSEC3 && rr.qtype.getCode() != QType::RRSIG) - hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname))); + hashed=toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname)); else hashed=""; } diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 7be5d2ed46..0dc190d364 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -968,7 +968,7 @@ bool GSQLBackend::feedEnts3(int domain_id, const string &domain, set &no output = (boost::format(d_InsertEntQuery) % domain_id % toLower(sqlEscape(qname))).str(); } else { ordername=toBase32Hex(hashQNameWithSalt(times, salt, qname)); - output = (boost::format(d_InsertEntOrderQuery) % domain_id % toLower(sqlEscape(qname)) % toLower(sqlEscape(ordername))).str(); + output = (boost::format(d_InsertEntOrderQuery) % domain_id % toLower(sqlEscape(qname)) % sqlEscape(ordername)).str(); } try { diff --git a/pdns/base32.cc b/pdns/base32.cc index 5c96cc2ff1..a49f668f2e 100644 --- a/pdns/base32.cc +++ b/pdns/base32.cc @@ -73,7 +73,7 @@ static int unbase32hex(char c) /* convert a binary string to base32hex */ string toBase32Hex(const std::string& input) { - static const char base32hex[] = "0123456789ABCDEFGHIJKLMNOPQRSTUV="; + static const char base32hex[] = "0123456789abcdefghijklmnopqrstuv="; string ret; ret.reserve(4+ 8*input.length()/5); // optimization // process input in groups of 5 8-bit chunks, emit 8 5-bit chunks diff --git a/pdns/nsec3dig.cc b/pdns/nsec3dig.cc index f7540109ce..6fe3023e54 100644 --- a/pdns/nsec3dig.cc +++ b/pdns/nsec3dig.cc @@ -15,7 +15,7 @@ typedef set nsec3set; string nsec3Hash(const string &qname, const string &salt, unsigned int iters) { - return toLower(toBase32Hex(hashQNameWithSalt(iters, salt, qname))); + return toBase32Hex(hashQNameWithSalt(iters, salt, qname)); } void proveOrDeny(const nsec3set &nsec3s, const string &qname, const string &salt, unsigned int iters, set &proven, set &denied) @@ -130,7 +130,7 @@ try // cerr< parts; boost::split(parts, i->first.d_label, boost::is_any_of(".")); - nsec3s.insert(make_pair(toLower(parts[0]), toLower(toBase32Hex(r.d_nexthash)))); + nsec3s.insert(make_pair(toLower(parts[0]), toBase32Hex(r.d_nexthash))); nsec3salt = r.d_salt; nsec3iters = r.d_iterations; } diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 572b6a8f11..0d0c3f74b9 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -450,7 +450,7 @@ void PacketHandler::emitNSEC(const std::string& begin, const std::string& end, c void emitNSEC3(DNSBackend& B, const NSEC3PARAMRecordContent& ns3prc, const SOAData& sd, const std::string& unhashed, const std::string& begin, const std::string& end, const std::string& toNSEC3, DNSPacket *r, int mode) { -// cerr<<"We should emit NSEC3 '"<getBeforeAndAfterNamesAbsolute(id, toLower(toBase32Hex(hashed)), unhashed, before, after); + ret=db->getBeforeAndAfterNamesAbsolute(id, toBase32Hex(hashed), unhashed, before, after); before=fromBase32Hex(before); after=fromBase32Hex(after); } @@ -914,7 +914,7 @@ void PacketHandler::synthesiseRRSIGs(DNSPacket* p, DNSPacket* r) // now get the NSEC3 and NSEC3PARAM string hashed=hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, unhashed); getNSEC3Hashes(narrow, sd.db, sd.domain_id, hashed, false, unhashed, before, after); - unhashed=dotConcat(toLower(toBase32Hex(before)), sd.qname); + unhashed=dotConcat(toBase32Hex(before), sd.qname); n3rc.d_set=nrc.d_set; // Copy d_set from NSEC n3rc.d_algorithm=ns3pr.d_algorithm; diff --git a/pdns/pdnssec.cc b/pdns/pdnssec.cc index ca5ed9baeb..ebf381f359 100644 --- a/pdns/pdnssec.cc +++ b/pdns/pdnssec.cc @@ -240,7 +240,7 @@ bool rectifyZone(DNSSECKeeper& dk, const std::string& zone) if(haveNSEC3) { if(!narrow) { - hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, qname))); + hashed=toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, qname)); if(g_verbose) cerr<<"'"< '"<< hashed <<"'"<updateDNSSECOrderAndAuthAbsolute(sd.domain_id, qname, hashed, auth); @@ -1263,7 +1263,7 @@ try cerr<<"The '"<d_iterations, ns3pr->d_salt, qname))); + hashed = toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, qname)); di->backend->updateDNSSECOrderAndAuthAbsolute(di->id, qname, hashed, (ddepth == 0)); if (nssets.count(qname)) { @@ -242,7 +242,7 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, if(*haveNSEC3) { string hashed; if(! *narrow) - hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, rrLabel))); + hashed=toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, rrLabel)); if (*narrow) di->backend->nullifyDNSSECOrderNameAndUpdateAuth(di->id, rrLabel, auth); @@ -309,7 +309,7 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, { string hashed; if(! *narrow) - hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, rrLabel))); + hashed=toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, rrLabel)); if (*narrow) di->backend->nullifyDNSSECOrderNameAndUpdateAuth(di->id, rrLabel, auth); @@ -355,7 +355,7 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, if(*haveNSEC3) { string hashed; if(! *narrow) - hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, *qname))); + hashed=toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, *qname)); if (*narrow) di->backend->nullifyDNSSECOrderNameAndUpdateAuth(di->id, rrLabel, auth); @@ -488,7 +488,7 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, if(*haveNSEC3) { string hashed; if(! *narrow) - hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, *changeRec))); + hashed=toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, *changeRec)); di->backend->updateDNSSECOrderAndAuthAbsolute(di->id, *changeRec, hashed, true); } @@ -559,7 +559,7 @@ uint PacketHandler::performUpdate(const string &msgPrefix, const DNSRecord *rr, { string hashed; if(! *narrow) - hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, *i))); + hashed=toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, *i)); di->backend->updateDNSSECOrderAndAuthAbsolute(di->id, *i, hashed, true); } } @@ -998,7 +998,7 @@ void PacketHandler::increaseSerial(const string &msgPrefix, const DomainInfo *di else if (haveNSEC3) { string hashed; if (!narrow) - hashed = toLower(toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, newRec.qname))); + hashed = toBase32Hex(hashQNameWithSalt(ns3pr->d_iterations, ns3pr->d_salt, newRec.qname)); di->backend->updateDNSSECOrderAndAuthAbsolute(di->id, newRec.qname, hashed, true); } diff --git a/pdns/slavecommunicator.cc b/pdns/slavecommunicator.cc index 65d6fa1ffa..56df14007e 100644 --- a/pdns/slavecommunicator.cc +++ b/pdns/slavecommunicator.cc @@ -277,7 +277,7 @@ void CommunicatorClass::suck(const string &domain,const string &remote) if (dnssecZone && rr.qtype.getCode() != QType::RRSIG) { if (haveNSEC3) { // NSEC3 - ordername=toLower(toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname))); + ordername=toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname)); if(!narrow && (rr.auth || (rr.qtype.getCode() == QType::NS && (!gotOptOutFlag || secured.count(ordername))))) { di.backend->feedRecord(rr, &ordername); } else diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index c56385a333..0d786afd1b 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -736,7 +736,7 @@ int TCPNameserver::doAXFR(const string &target, shared_ptr q, int out inext = nsecxrepo.begin(); } n3rc.d_nexthash = inext->first; - rr.qname = dotConcat(toLower(toBase32Hex(iter->first)), sd.qname); + rr.qname = dotConcat(toBase32Hex(iter->first), sd.qname); rr.ttl = sd.default_ttl; rr.content = n3rc.getZoneRepresentation(); diff --git a/pdns/test-base32_cc.cc b/pdns/test-base32_cc.cc index 7293a2c4f6..e192b3237a 100644 --- a/pdns/test-base32_cc.cc +++ b/pdns/test-base32_cc.cc @@ -15,12 +15,12 @@ BOOST_AUTO_TEST_CASE(test_record_types) { // RFC test vectors cases_t cases = boost::assign::list_of (case_t(std::string(""), std::string(""))) - (case_t(std::string("f"), std::string("CO======"))) - (case_t(std::string("fo"), std::string("CPNG===="))) - (case_t(std::string("foo"), std::string("CPNMU==="))) - (case_t(std::string("foob"), std::string("CPNMUOG="))) - (case_t(std::string("fooba"), std::string("CPNMUOJ1"))) - (case_t(std::string("foobar"), std::string("CPNMUOJ1E8======"))) + (case_t(std::string("f"), std::string("co======"))) + (case_t(std::string("fo"), std::string("cpng===="))) + (case_t(std::string("foo"), std::string("cpnmu==="))) + (case_t(std::string("foob"), std::string("cpnmuog="))) + (case_t(std::string("fooba"), std::string("cpnmuoj1"))) + (case_t(std::string("foobar"), std::string("cpnmuoj1e8======"))) ; BOOST_FOREACH(const case_t& val, cases) { -- 2.47.2