From: bert hubert Date: Sun, 8 Mar 2015 14:16:15 +0000 (+0100) Subject: make libsodium optimal X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~88^2~72 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0b62ec78600c34f5afe3c8e00dac01a9f298f050;p=thirdparty%2Fpdns.git make libsodium optimal --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 26fe837acd..93f0308f40 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -36,7 +36,6 @@ #include "dnswriter.hh" #include "base64.hh" #include -#include #include "sodcrypto.hh" #undef L @@ -912,10 +911,12 @@ try openlog("dnsdist", LOG_PID, LOG_DAEMON); g_console=true; +#ifdef HAVE_LIBSODIUM if (sodium_init() == -1) { cerr<<"Unable to initialize crypto library"< #include -#include -#include -void sodTest(); -std::string newKeypair(); - -std::string sodEncryptAsym(const std::string& msg, const std::string& secretSource, - const std::string& publicDest); - - -std::string sodDecryptAsym(const std::string& msg, const std::string& publicSource, - const std::string& secretDest); +#include +#ifndef HAVE_LIBSODIUM +struct SodiumNonce +{ + void init(){}; + void increment(){}; + unsigned char value[1]; +}; +#else +#include struct SodiumNonce { @@ -36,7 +36,8 @@ struct SodiumNonce unsigned char value[crypto_secretbox_NONCEBYTES]; }; - +#endif +std::string newKeypair(); std::string sodEncryptSym(const std::string& msg, const std::string& key, SodiumNonce&); std::string sodDecryptSym(const std::string& msg, const std::string& key, SodiumNonce&); std::string newKey();