Browse Source

[2268] Make all hash related checks use isc::dns::NSEC3Hash

This is possible now as we have the new NSEC3Hash::create() variant.
Mukund Sivaraman 12 years ago
parent
commit
25cd191443
1 changed files with 9 additions and 13 deletions
  1. 9 13
      src/lib/datasrc/memory/zone_data_updater.cc

+ 9 - 13
src/lib/datasrc/memory/zone_data_updater.cc

@@ -16,6 +16,9 @@
 #include <datasrc/zone.h>
 
 #include <dns/rdataclass.h>
+#include <dns/nsec3hash.h>
+
+#include <boost/scoped_ptr.hpp>
 
 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<uint8_t>& 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<NSEC3Hash> 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());