#include "dnswriter.hh"
#include "base64.hh"
#include <fstream>
-#include <sodium.h>
#include "sodcrypto.hh"
#undef L
openlog("dnsdist", LOG_PID, LOG_DAEMON);
g_console=true;
+#ifdef HAVE_LIBSODIUM
if (sodium_init() == -1) {
cerr<<"Unable to initialize crypto library"<<endl;
exit(EXIT_FAILURE);
}
+#endif
po::options_description desc("Allowed options"), hidden, alloptions;
desc.add_options()
AC_CONFIG_HEADERS([config.h])
AC_PROG_CC
AC_PROG_CXX
+PKG_CHECK_MODULES([libsodium], [libsodium], [AC_DEFINE([HAVE_LIBSODIUM], [1], [Define to 1 if you have libsodium])], [true])
AC_PROG_LIBTOOL
BOOST_REQUIRE([1.35])
BOOST_FOREACH
BOOST_PROGRAM_OPTIONS([mt])
-PKG_CHECK_MODULES([libsodium], [libsodium])
+
PDNS_WITH_LUA
AX_CXX_COMPILE_STDCXX_11(ext,mandatory)
#include "sodcrypto.hh"
+#ifdef HAVE_LIBSODIUM
+
string newKey()
{
unsigned char key[crypto_secretbox_KEYBYTES];
nonce.increment();
return string((char*)decrypted, sizeof(decrypted));
}
+#else
+std::string sodEncryptSym(const std::string& msg, const std::string& key, SodiumNonce& nonce)
+{
+ return msg;
+}
+std::string sodDecryptSym(const std::string& msg, const std::string& key, SodiumNonce& nonce)
+{
+ return msg;
+}
+
+string newKey()
+{
+ return "\"plaintext\"";
+}
+
+
+#endif
#include "base64.hh"
#pragma once
+#include "config.h"
#include <string>
#include <stdint.h>
-#include <sodium.h>
-#include <arpa/inet.h>
-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 <arpa/inet.h>
+#ifndef HAVE_LIBSODIUM
+struct SodiumNonce
+{
+ void init(){};
+ void increment(){};
+ unsigned char value[1];
+};
+#else
+#include <sodium.h>
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();