]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
speedtest: add NSEC3 hashing test
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Wed, 17 Feb 2021 09:39:12 +0000 (10:39 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Wed, 17 Feb 2021 09:39:12 +0000 (10:39 +0100)
pdns/Makefile.am
pdns/speedtest.cc

index 053212287d359b2afcabaaaddd871920385b03f3..2f7cd11533c74f3d20128a1945e22bf7e340a167 100644 (file)
@@ -908,6 +908,7 @@ endif
 speedtest_SOURCES = \
        base32.cc \
        base64.cc base64.hh \
+       dnssecinfra.cc dnssecinfra.hh \
        dnslabeltext.cc \
        dnsname.cc dnsname.hh \
        dnsparser.cc dnsparser.hh \
@@ -1405,6 +1406,8 @@ testrunner_LDADD = \
 if PKCS11
 testrunner_SOURCES += pkcs11signers.cc pkcs11signers.hh
 testrunner_LDADD += $(P11KIT1_LIBS)
+speedtest_SOURCES += pkcs11signers.cc pkcs11signers.hh
+speedtest_LDADD += $(P11KIT1_LIBS)
 endif
 
 if LIBSODIUM
index 79384363e2e7d7f25b5dac72068fdcd47bd02648..5a3c39df69e326bcbe1066578d932aed8c7d58bc 100644 (file)
@@ -9,6 +9,7 @@
 #include "iputils.hh"
 #include <fstream>
 #include "uuid-utils.hh"
+#include "dnssecinfra.hh"
 
 #ifndef RECURSOR
 #include "statbag.hh"
@@ -843,6 +844,24 @@ struct UUIDGenTest
   }
 };
 
+struct NSEC3HashTest
+{
+  explicit NSEC3HashTest(int iterations, string salt) : d_iterations(iterations), d_salt(salt) {}
+
+  string getName() const
+  {
+    return (boost::format("%d NSEC3 iterations, salt length %d") % d_iterations % d_salt.length()).str();
+  }
+
+  void operator()() const
+  {
+    hashQNameWithSalt(d_salt, d_iterations, d_name);
+  }
+  int d_iterations;
+  string d_salt;
+  DNSName d_name = DNSName("www.example.com");
+};
+
 int main(int argc, char** argv)
 try
 {
@@ -930,6 +949,18 @@ try
 
   doRun(UUIDGenTest());
 
+  doRun(NSEC3HashTest(1, "ABCD"));
+  doRun(NSEC3HashTest(10, "ABCD"));
+  doRun(NSEC3HashTest(50, "ABCD"));
+  doRun(NSEC3HashTest(150, "ABCD"));
+  doRun(NSEC3HashTest(500, "ABCD"));
+
+  doRun(NSEC3HashTest(1, "ABCDABCDABCDABCDABCDABCDABCDABCD"));
+  doRun(NSEC3HashTest(10, "ABCDABCDABCDABCDABCDABCDABCDABCD"));
+  doRun(NSEC3HashTest(50, "ABCDABCDABCDABCDABCDABCDABCDABCD"));
+  doRun(NSEC3HashTest(150, "ABCDABCDABCDABCDABCDABCDABCDABCD"));
+  doRun(NSEC3HashTest(500, "ABCDABCDABCDABCDABCDABCDABCDABCD"));
+
 #ifndef RECURSOR
   S.doRings();