* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#ifdef HAVE_IPCRYPT2
#include <memory>
+#endif
#include <stdexcept>
#include <string>
#include <sys/socket.h>
#include "dnsdist-ipcrypt2.hh"
+#ifdef HAVE_IPCRYPT2
#include "ipcrypt2.h"
+#endif
#include "iputils.hh"
// ipcrypt2 namespace does not have to be dnsdist-specific
namespace pdns::ipcrypt2
{
-IPCrypt2::IPCrypt2(const IPCryptMethod& method, const std::string& key) :
+IPCrypt2::IPCrypt2([[maybe_unused]] const IPCryptMethod& method, [[maybe_unused]] const std::string& key) :
d_method(method)
{
+#ifdef HAVE_IPCRYPT2
switch (method) {
case IPCryptMethod::pfx: {
if (key.size() != IPCRYPT_PFX_KEYBYTES) {
throw std::runtime_error("Unsupported IPCrypt2 method");
break;
}
+#else
+ throw std::runtime_error("IPCrypt2 is not supported");
+#endif
}
IPCrypt2::~IPCrypt2()
{
+#ifdef HAVE_IPCRYPT2
switch (d_method) {
case IPCryptMethod::pfx:
if (d_ipcryptCtxPfx != nullptr) {
default:
return;
}
+#endif
};
-ComboAddress IPCrypt2::encrypt(const ComboAddress& address) const
+ComboAddress IPCrypt2::encrypt([[maybe_unused]] const ComboAddress& address) const // NOLINT(readability-convert-member-functions-to-static)
{
+#ifdef HAVE_IPCRYPT2
switch (d_method) {
case IPCryptMethod::pfx: {
uint8_t ip16[16];
throw std::runtime_error("Unsupported method");
break;
}
+#else
+ throw std::runtime_error("IPCrypt2 is not supported");
+#endif
}
}
#ifdef HAVE_IPCIPHER
cout << "ipcipher ";
#endif
+#ifdef HAVE_IPCRYPT2
+ cout << "ipcrypt2 ";
+#endif
#ifdef HAVE_LIBEDIT
cout << "libedit ";
#endif
+opt_ipcrypt2 = get_option('ipcrypt2')
+
+can_build=true
if target_machine.cpu_family() == 'aarch64'
code = '''
# if defined(_MSC_VER) && defined(_M_ARM64)
}
'''
compiler = meson.get_compiler('cpp')
- result = compiler.compiles(code, name: 'uint64x2_t tests')
- assert(result, 'Compiler does not support calculation with uint64x2_t on ARM64')
+ can_build = compiler.compiles(code, name: 'uint64x2_t tests')
endif
+
+dep_ipcrypt2 = declare_dependency()
+
+if can_build
lib_ipcrypt2 = static_library(
'ipcrypt2',
'ipcrypt2.c',
link_with: lib_ipcrypt2,
include_directories: include_directories('./include'),
)
+endif
+
+if not can_build and opt_ipcrypt2.enabled()
+ error('ipcrypt2 support was requested but ipcrypt2 can not be built')
+endif
+enable_ipcrypt2 = can_build and not opt_ipcrypt2.disabled()
+conf.set('HAVE_IPCRYPT2', enable_ipcrypt2, description: 'ipcrypt2 support')
+summary('ipcrypt2', enable_ipcrypt2, bool_yn: true, section: 'Configuration')
return 0;
}
])],[
+ dnl We just define this. Proper detection is only done in Meson
+ AC_DEFINE([HAVE_IPCRYPT2], [1], [Define to 1 to build with IPCrypt2])
AC_MSG_RESULT([ok])
],[
AC_MSG_FAILURE([no])
option('hardening-experimental-scp', type: 'feature', value: 'disabled', description: 'Stack Clash Protection')
option('hardening-fortify-source', type: 'combo', choices: ['auto', 'disabled', '1', '2', '3'], value: '2', description: 'Source fortification level')
option('ipcipher', type: 'feature', value: 'auto', description: 'IPCipher')
+option('ipcrypt2', type: 'feature', value: 'auto', description: 'IPCrypt2')
option('tls-libssl', type: 'feature', value: 'auto', description: 'OpenSSL-based TLS')
option('tls-libssl-dir', type: 'string', value: '', description: 'Alternate OpenSSL location')
option('tls-libssl-engines', type: 'boolean', value: false, description: 'OpenSSL-based TLS with TLS engines')
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#ifdef HAVE_IPCRYPT2
+
#ifndef BOOST_TEST_DYN_LINK
#define BOOST_TEST_DYN_LINK
#include "iputils.hh"
}
BOOST_AUTO_TEST_SUITE_END()
+
+#endif // HAVE_IPCRYPT2