From: Mukund Sivaraman Date: Wed, 3 Oct 2012 17:12:26 +0000 (+0530) Subject: [2268] Make all hash related checks use isc::dns::NSEC3Hash X-Git-Tag: trac2402_base~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25cd191443ffd0cffc036c53a0ff57ad2391cead;p=thirdparty%2Fkea.git [2268] Make all hash related checks use isc::dns::NSEC3Hash This is possible now as we have the new NSEC3Hash::create() variant. --- diff --git a/src/lib/datasrc/memory/zone_data_updater.cc b/src/lib/datasrc/memory/zone_data_updater.cc index f7042630d4..45c985e085 100644 --- a/src/lib/datasrc/memory/zone_data_updater.cc +++ b/src/lib/datasrc/memory/zone_data_updater.cc @@ -16,6 +16,9 @@ #include #include +#include + +#include using namespace isc::dns; using namespace isc::dns::rdata; @@ -243,20 +246,13 @@ ZoneDataUpdater::setupNSEC3(const ConstRRsetPtr rrset) { zone_data_.setNSEC3Data(nsec3_data); zone_data_.setSigned(true); } else { - size_t salt_len = nsec3_data->getSaltLen(); - const uint8_t* salt_data = nsec3_data->getSaltData(); - const std::vector& salt_data_2 = nsec3_rdata.getSalt(); - - if ((nsec3_rdata.getHashalg() != nsec3_data->hashalg) || - (nsec3_rdata.getIterations() != nsec3_data->iterations) || - (salt_data_2.size() != salt_len)) { - isc_throw(AddError, - rrset->getType() << " with inconsistent parameters: " - << rrset->toText()); - } + const boost::scoped_ptr hash + (NSEC3Hash::create(nsec3_data->hashalg, + nsec3_data->iterations, + nsec3_data->getSaltData(), + nsec3_data->getSaltLen())); - if ((salt_len > 0) && - (std::memcmp(&salt_data_2[0], salt_data, salt_len) != 0)) { + if (!hash->match(nsec3_rdata)) { isc_throw(AddError, rrset->getType() << " with inconsistent parameters: " << rrset->toText());