From: bert hubert Date: Wed, 27 Apr 2016 13:10:17 +0000 (+0200) Subject: enable function to hash qnames w/o having the NSEC3PARAM ready X-Git-Tag: rec-4.0.0-alpha3~43^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e480500517aa246b19f4a00447790057fe11b01e;p=pdns enable function to hash qnames w/o having the NSEC3PARAM ready --- diff --git a/pdns/dnssecinfra.cc b/pdns/dnssecinfra.cc index 7c59814d6..a7bebe03f 100644 --- a/pdns/dnssecinfra.cc +++ b/pdns/dnssecinfra.cc @@ -404,12 +404,17 @@ uint32_t getStartOfWeek() string hashQNameWithSalt(const NSEC3PARAMRecordContent& ns3prc, const DNSName& qname) { - unsigned int times = ns3prc.d_iterations; + return hashQNameWithSalt(ns3prc.d_salt, ns3prc.d_iterations, qname); +} + +string hashQNameWithSalt(const std::string& salt, unsigned int iterations, const DNSName& qname) +{ + unsigned int times = iterations; unsigned char hash[20]; string toHash(qname.toDNSStringLC()); for(;;) { - toHash.append(ns3prc.d_salt); + toHash.append(salt); SHA1((unsigned char*)toHash.c_str(), toHash.length(), hash); toHash.assign((char*)hash, sizeof(hash)); if(!times--) diff --git a/pdns/dnssecinfra.hh b/pdns/dnssecinfra.hh index e0d15335e..bd95b439b 100644 --- a/pdns/dnssecinfra.hh +++ b/pdns/dnssecinfra.hh @@ -127,6 +127,7 @@ int getRRSIGsForRRSET(DNSSECKeeper& dk, const DNSName& signer, const DNSName sig vector >& toSign, vector &rrc); string hashQNameWithSalt(const NSEC3PARAMRecordContent& ns3prc, const DNSName& qname); +string hashQNameWithSalt(const std::string& salt, unsigned int iterations, const DNSName& qname); void decodeDERIntegerSequence(const std::string& input, vector& output); class DNSPacket; void addRRSigs(DNSSECKeeper& dk, UeberBackend& db, const std::set& authMap, vector& rrs);