Problem: use of libsodium vs. tweetnacl is confused

It's unclear which we need and in the source code, conditional code
treats tweetnacl as a subclass of libsodium, which is inaccurate.

Solution: redesign the configure/cmake API for this:

* tweetnacl is present by default and cannot be enabled
* libsodium can be enabled using --with-libsodium, which replaces
  the built-in tweetnacl
* CURVE encryption can be disabled entirely using --enable-curve=no

The macros we define in platform.hpp are:

    ZMQ_HAVE_CURVE    1        //  When CURVE is enabled
    HAVE_LIBSODIUM    1        //  When we are using libsodium
    HAVE_TWEETNACL    1        //  When we're using tweetnacl (default)

As of this patch, the default build of libzmq always has CURVE
security, and always uses tweetnacl.
This commit is contained in:
Pieter Hintjens
2016-02-11 13:32:01 +01:00
parent 42ab88e486
commit b49a60410a
16 changed files with 610 additions and 610 deletions

View File

@@ -320,7 +320,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
break;
# if defined ZMQ_HAVE_SO_PEERCRED || defined ZMQ_HAVE_LOCAL_PEERCRED
#if defined ZMQ_HAVE_SO_PEERCRED || defined ZMQ_HAVE_LOCAL_PEERCRED
case ZMQ_IPC_FILTER_UID:
if (optvallen_ == 0 && optval_ == NULL) {
ipc_uid_accept_filters.clear ();
@@ -344,9 +344,9 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
return 0;
}
break;
# endif
#endif
# if defined ZMQ_HAVE_SO_PEERCRED
#if defined ZMQ_HAVE_SO_PEERCRED
case ZMQ_IPC_FILTER_PID:
if (optvallen_ == 0 && optval_ == NULL) {
ipc_pid_accept_filters.clear ();
@@ -358,7 +358,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
return 0;
}
break;
# endif
#endif
case ZMQ_PLAIN_SERVER:
if (is_int && (value == 0 || value == 1)) {
@@ -403,8 +403,8 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
break;
// If libsodium isn't installed, these options provoke EINVAL
# ifdef HAVE_LIBSODIUM
// If curve encryption isn't built, these options provoke EINVAL
#ifdef ZMQ_HAVE_CURVE
case ZMQ_CURVE_SERVER:
if (is_int && (value == 0 || value == 1)) {
as_server = value;
@@ -496,7 +496,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
}
break;
# endif
#endif
case ZMQ_CONFLATE:
if (is_int && (value == 0 || value == 1)) {
@@ -506,7 +506,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
break;
// If libgssapi isn't installed, these options provoke EINVAL
# ifdef HAVE_LIBGSSAPI_KRB5
#ifdef HAVE_LIBGSSAPI_KRB5
case ZMQ_GSSAPI_SERVER:
if (is_int && (value == 0 || value == 1)) {
as_server = value;
@@ -538,7 +538,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
return 0;
}
break;
# endif
#endif
case ZMQ_HANDSHAKE_IVL:
if (is_int && value >= 0) {
@@ -577,7 +577,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
break;
# ifdef ZMQ_HAVE_VMCI
#ifdef ZMQ_HAVE_VMCI
case ZMQ_VMCI_BUFFER_SIZE:
if (optvallen_ == sizeof (uint64_t)) {
vmci_buffer_size = *((uint64_t*) optval_);
@@ -605,7 +605,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
return 0;
}
break;
# endif
#endif
case ZMQ_USE_FD:
if (is_int && value >= -1) {
@@ -888,8 +888,8 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
}
break;
// If libsodium isn't installed, these options provoke EINVAL
# ifdef HAVE_LIBSODIUM
// If curve encryption isn't built, these options provoke EINVAL
#ifdef ZMQ_HAVE_CURVE
case ZMQ_CURVE_SERVER:
if (is_int) {
*value = as_server && mechanism == ZMQ_CURVE;
@@ -932,7 +932,7 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
return 0;
}
break;
# endif
#endif
case ZMQ_CONFLATE:
if (is_int) {
@@ -942,7 +942,7 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
break;
// If libgssapi isn't installed, these options provoke EINVAL
# ifdef HAVE_LIBGSSAPI_KRB5
#ifdef HAVE_LIBGSSAPI_KRB5
case ZMQ_GSSAPI_SERVER:
if (is_int) {
*value = as_server && mechanism == ZMQ_GSSAPI;