From f4848ddb32612be96eba308c3e7e3361c4c33f98 Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Sat, 22 Jun 2013 13:38:14 +0200 Subject: [PATCH] Prints message and exits if app tries to use CURVE without libsodium --- src/options.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/options.cpp b/src/options.cpp index 9f911567..5f76d426 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -286,6 +286,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, break; case ZMQ_CURVE_SERVER: +# ifndef HAVE_LIBSODIUM + puts ("E: libzmq was not built using libsodium, CURVE not available"); + assert (false); +# endif if (is_int && (value == 0 || value == 1)) { as_server = value; mechanism = value? ZMQ_CURVE: ZMQ_NULL; @@ -294,6 +298,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, break; case ZMQ_CURVE_PUBLICKEY: +# ifndef HAVE_LIBSODIUM + puts ("E: libzmq was not built using libsodium, CURVE not available"); + assert (false); +# endif if (optvallen_ == CURVE_KEYSIZE) { memcpy (curve_public_key, optval_, CURVE_KEYSIZE); mechanism = ZMQ_CURVE; @@ -302,6 +310,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, break; case ZMQ_CURVE_SECRETKEY: +# ifndef HAVE_LIBSODIUM + puts ("E: libzmq was not built using libsodium, CURVE not available"); + assert (false); +# endif if (optvallen_ == CURVE_KEYSIZE) { memcpy (curve_secret_key, optval_, CURVE_KEYSIZE); mechanism = ZMQ_CURVE; @@ -310,6 +322,10 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, break; case ZMQ_CURVE_SERVERKEY: +# ifndef HAVE_LIBSODIUM + puts ("E: libzmq was not built using libsodium, CURVE not available"); + assert (false); +# endif if (optvallen_ == CURVE_KEYSIZE) { memcpy (curve_server_key, optval_, CURVE_KEYSIZE); as_server = 0;