From: Otto Date: Wed, 22 Sep 2021 13:10:05 +0000 (+0200) Subject: Add our various random implementations to speedtest X-Git-Tag: rec-4.6.0-alpha1~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18ebfecafda9f182c21975f67d2afd8ca387418b;p=thirdparty%2Fpdns.git Add our various random implementations to speedtest --- diff --git a/pdns/Makefile.am b/pdns/Makefile.am index d8a7cafbe0..9628a5bee2 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -916,9 +916,11 @@ tsig_tests_LDADD += $(P11KIT1_LIBS) endif speedtest_SOURCES = \ + arguments.cc arguments.hh \ base32.cc \ base64.cc base64.hh \ credentials.cc credentials.hh \ + dns_random.cc dns_random.hh \ dnslabeltext.cc \ dnsname.cc dnsname.hh \ dnsparser.cc dnsparser.hh \ diff --git a/pdns/speedtest.cc b/pdns/speedtest.cc index 50f40cb119..b64dd76db3 100644 --- a/pdns/speedtest.cc +++ b/pdns/speedtest.cc @@ -12,6 +12,8 @@ #include "uuid-utils.hh" #include "dnssecinfra.hh" #include "lock.hh" +#include "dns_random.hh" +#include "arguments.hh" #ifndef RECURSOR #include "statbag.hh" @@ -1047,6 +1049,26 @@ private: const std::string d_password{"test password"}; }; +struct RndSpeedTest +{ + explicit RndSpeedTest(std::string which) : name(which){ + ::arg().set("entropy-source", "If set, read entropy from this file")="/dev/urandom"; + ::arg().set("rng", "") = which; + dns_random_init("", true); + } + string getName() const + { + return "Random test " + name; + } + + void operator()() const + { + dns_random(0x10000); + } + + std::string name; +}; + struct CredentialsVerifyTest { explicit CredentialsVerifyTest() { @@ -1174,6 +1196,20 @@ try doRun(UUIDGenTest()); +#if defined(HAVE_RANDOMBYTES_STIR) + doRun(RndSpeedTest("sodium")); +#endif +#if defined(HAVE_RAND_BYTES) + doRun(RndSpeedTest("openssl")); +#endif +#if defined(HAVE_GETRANDOM) + doRun(RndSpeedTest("getrandom")); +#endif +#if defined(HAVE_ARC4RANDOM) + doRun(RndSpeedTest("arc4random")); +#endif + doRun(RndSpeedTest("urandom")); + doRun(NSEC3HashTest(1, "ABCD")); doRun(NSEC3HashTest(10, "ABCD")); doRun(NSEC3HashTest(50, "ABCD")); @@ -1201,6 +1237,7 @@ try doRun(StatRingDNSNameQTypeTest(DNSName("example.com"), QType(1))); #endif + cerr<<"Total runs: " << g_totalRuns<