mirror of
https://github.com/matrix-construct/construct
synced 2024-06-01 17:48:56 +02:00
Add support for libsodium (NaCl) cryptography.
This commit is contained in:
parent
c91c1e39e8
commit
4a6b3f5fcc
|
@ -37,11 +37,11 @@ developed Boost libraries. These are included as a submodule in this repository.
|
||||||
**RocksDB** (based on LevelDB) - We replace sqlite3 with a lightweight and embedded database
|
**RocksDB** (based on LevelDB) - We replace sqlite3 with a lightweight and embedded database
|
||||||
and have furthered the mission of eliminating the need for external "IRC services"
|
and have furthered the mission of eliminating the need for external "IRC services"
|
||||||
|
|
||||||
|
*Other dependencies:* **sodium** (NaCl crypto), **OpenSSL**, **zlib**, **snappy** (for rocksdb)
|
||||||
|
|
||||||
*Build dependencies:* **gnu++14 compiler**, **automake**, **autoconf**, **autoconf2.13**,
|
*Build dependencies:* **gnu++14 compiler**, **automake**, **autoconf**, **autoconf2.13**,
|
||||||
**autoconf-archive**, **libtool**, **shtool**
|
**autoconf-archive**, **libtool**, **shtool**
|
||||||
|
|
||||||
*Other dependencies:* **OpenSSL**, **zlib**, **snappy** (for rocksdb)
|
|
||||||
|
|
||||||
|
|
||||||
#### Downloading Charybdis
|
#### Downloading Charybdis
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ AM_CPPFLAGS = \
|
||||||
@ROCKSDB_CPPFLAGS@ \
|
@ROCKSDB_CPPFLAGS@ \
|
||||||
@JS_CPPFLAGS@ \
|
@JS_CPPFLAGS@ \
|
||||||
@BOOST_CPPFLAGS@ \
|
@BOOST_CPPFLAGS@ \
|
||||||
|
@SODIUM_CPPFLAGS@ \
|
||||||
###
|
###
|
||||||
|
|
||||||
AM_LDFLAGS = \
|
AM_LDFLAGS = \
|
||||||
|
@ -29,6 +30,7 @@ charybdis_LDFLAGS = \
|
||||||
@ROCKSDB_LDFLAGS@ \
|
@ROCKSDB_LDFLAGS@ \
|
||||||
@JS_LDFLAGS@ \
|
@JS_LDFLAGS@ \
|
||||||
@BOOST_LDFLAGS@ \
|
@BOOST_LDFLAGS@ \
|
||||||
|
@SODIUM_LDFLAGS@ \
|
||||||
###
|
###
|
||||||
|
|
||||||
charybdis_LDADD = \
|
charybdis_LDADD = \
|
||||||
|
@ -36,6 +38,7 @@ charybdis_LDADD = \
|
||||||
@ROCKSDB_LIBS@ \
|
@ROCKSDB_LIBS@ \
|
||||||
@JS_LIBS@ \
|
@JS_LIBS@ \
|
||||||
@BOOST_LIBS@ \
|
@BOOST_LIBS@ \
|
||||||
|
@SODIUM_LIBS@ \
|
||||||
-lcrypto \
|
-lcrypto \
|
||||||
-lssl \
|
-lssl \
|
||||||
-lz \
|
-lz \
|
||||||
|
|
21
configure.ac
21
configure.ac
|
@ -848,6 +848,26 @@ AC_SUBST(GMP_LDFLAGS, [])
|
||||||
AC_SUBST(GMP_LIBS, ["-lgmp"])
|
AC_SUBST(GMP_LIBS, ["-lgmp"])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl libsodium (NaCl) crypto support
|
||||||
|
dnl
|
||||||
|
|
||||||
|
dnl PKG_CHECK_MODULES(SODIUM, [sodium], [have_sodium="yes"], [have_sodium="no"])
|
||||||
|
AC_CHECK_LIB([sodium], sodium_init, [have_sodium="yes"], [have_sodium="no"])
|
||||||
|
AM_CONDITIONAL([SODIUM], [test "x$have_sodium" = "xyes"])
|
||||||
|
|
||||||
|
AM_COND_IF([SODIUM], [],
|
||||||
|
[
|
||||||
|
AC_MSG_ERROR([Failed to find libsodium (The NaCl cryptographic library)])
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_SUBST(SODIUM_CPPFLAGS, [])
|
||||||
|
AC_SUBST(SODIUM_LDFLAGS, [])
|
||||||
|
AC_SUBST(SODIUM_LIBS, ["-lsodium"])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl OpenSSL support
|
dnl OpenSSL support
|
||||||
dnl
|
dnl
|
||||||
|
@ -1254,6 +1274,7 @@ echo "Compiler flags (CXXFLAGS) ......... $CXXFLAGS"
|
||||||
echo "Building boost .................... $with_included_boost"
|
echo "Building boost .................... $with_included_boost"
|
||||||
echo "Building RocksDB................... $with_included_rocksdb"
|
echo "Building RocksDB................... $with_included_rocksdb"
|
||||||
echo "Building JS (SpiderMonkey) ........ $with_included_js"
|
echo "Building JS (SpiderMonkey) ........ $with_included_js"
|
||||||
|
echo "Sodium support .................... $have_sodium"
|
||||||
echo "Precompiled headers ............... $build_pch"
|
echo "Precompiled headers ............... $build_pch"
|
||||||
echo "Developer debug ................... $debug"
|
echo "Developer debug ................... $debug"
|
||||||
echo "GNU MP support .................... $have_gmp"
|
echo "GNU MP support .................... $have_gmp"
|
||||||
|
|
|
@ -81,6 +81,7 @@ namespace ircd::buffer
|
||||||
template<class it> it copy(it &dest, const it &stop, const const_raw_buffer &);
|
template<class it> it copy(it &dest, const it &stop, const const_raw_buffer &);
|
||||||
template<class it> size_t copy(const it &dest, const size_t &max, const const_raw_buffer &buffer);
|
template<class it> size_t copy(const it &dest, const size_t &max, const const_raw_buffer &buffer);
|
||||||
size_t copy(const mutable_raw_buffer &dst, const const_raw_buffer &src);
|
size_t copy(const mutable_raw_buffer &dst, const const_raw_buffer &src);
|
||||||
|
void zero(const mutable_raw_buffer &buf);
|
||||||
|
|
||||||
// Iterable of buffers tools
|
// Iterable of buffers tools
|
||||||
template<template<class> class I, class T> size_t size(const I<T> &buffers);
|
template<template<class> class I, class T> size_t size(const I<T> &buffers);
|
||||||
|
|
|
@ -11,6 +11,7 @@ AM_CPPFLAGS = \
|
||||||
@ROCKSDB_CPPFLAGS@ \
|
@ROCKSDB_CPPFLAGS@ \
|
||||||
@JS_CPPFLAGS@ \
|
@JS_CPPFLAGS@ \
|
||||||
@BOOST_CPPFLAGS@ \
|
@BOOST_CPPFLAGS@ \
|
||||||
|
@SODIUM_CPPFLAGS@ \
|
||||||
-include ircd/ircd.h \
|
-include ircd/ircd.h \
|
||||||
###
|
###
|
||||||
|
|
||||||
|
@ -42,12 +43,14 @@ libircd_la_LDFLAGS = \
|
||||||
@ROCKSDB_LDFLAGS@ \
|
@ROCKSDB_LDFLAGS@ \
|
||||||
@JS_LDFLAGS@ \
|
@JS_LDFLAGS@ \
|
||||||
@BOOST_LDFLAGS@ \
|
@BOOST_LDFLAGS@ \
|
||||||
|
@SODIUM_LDFLAGS@ \
|
||||||
###
|
###
|
||||||
|
|
||||||
libircd_la_LIBADD = \
|
libircd_la_LIBADD = \
|
||||||
@ROCKSDB_LIBS@ \
|
@ROCKSDB_LIBS@ \
|
||||||
@JS_LIBS@ \
|
@JS_LIBS@ \
|
||||||
@BOOST_LIBS@ \
|
@BOOST_LIBS@ \
|
||||||
|
@SODIUM_LIBS@ \
|
||||||
-lcrypto \
|
-lcrypto \
|
||||||
-lssl \
|
-lssl \
|
||||||
-lz \
|
-lz \
|
||||||
|
@ -75,6 +78,7 @@ libircd_la_SOURCES = \
|
||||||
parse.cc \
|
parse.cc \
|
||||||
resource.cc \
|
resource.cc \
|
||||||
rfc1459.cc \
|
rfc1459.cc \
|
||||||
|
sodium.cc \
|
||||||
###
|
###
|
||||||
|
|
||||||
if JS
|
if JS
|
||||||
|
|
|
@ -83,12 +83,13 @@ try
|
||||||
|
|
||||||
ircd::main_context = main_context.detach();
|
ircd::main_context = main_context.detach();
|
||||||
ircd::runlevel_changed = std::move(runlevel_changed);
|
ircd::runlevel_changed = std::move(runlevel_changed);
|
||||||
log::info("%s. boost %u.%u.%u. rocksdb %s.",
|
log::info("%s. boost %u.%u.%u. rocksdb %s. sodium %s.",
|
||||||
PACKAGE_STRING,
|
PACKAGE_STRING,
|
||||||
boost_version[0],
|
boost_version[0],
|
||||||
boost_version[1],
|
boost_version[1],
|
||||||
boost_version[2],
|
boost_version[2],
|
||||||
db::version);
|
db::version,
|
||||||
|
nacl::version());
|
||||||
|
|
||||||
log::info("%s %ld %s. configured: %s. compiled: %s %s",
|
log::info("%s %ld %s. configured: %s. compiled: %s %s",
|
||||||
BRANDING_VERSION,
|
BRANDING_VERSION,
|
||||||
|
@ -170,6 +171,7 @@ try
|
||||||
// more appropriate.
|
// more appropriate.
|
||||||
|
|
||||||
ctx::ole::init _ole_; // Thread OffLoad Engine
|
ctx::ole::init _ole_; // Thread OffLoad Engine
|
||||||
|
nacl::init _nacl_; // nacl crypto
|
||||||
net::init _net_; // Networking
|
net::init _net_; // Networking
|
||||||
client::init _client_; // Client related
|
client::init _client_; // Client related
|
||||||
db::init _db_; // RocksDB
|
db::init _db_; // RocksDB
|
||||||
|
|
47
ircd/sodium.cc
Normal file
47
ircd/sodium.cc
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Charybdis Development Team
|
||||||
|
* Copyright (C) 2017 Jason Volk <jason@zemos.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice is present in all copies.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sodium.h>
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Internal
|
||||||
|
//
|
||||||
|
|
||||||
|
__attribute__((constructor))
|
||||||
|
static void
|
||||||
|
ircd_init()
|
||||||
|
{
|
||||||
|
if(sodium_init() < 0)
|
||||||
|
throw std::runtime_error("sodium_init(): error");
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// ircd/buffer.h
|
||||||
|
//
|
||||||
|
|
||||||
|
void
|
||||||
|
ircd::buffer::zero(const mutable_raw_buffer &buf)
|
||||||
|
{
|
||||||
|
sodium_memzero(data(buf), size(buf));
|
||||||
|
}
|
Loading…
Reference in a new issue