diff --git a/configure.ac b/configure.ac index 44e901a5..ac130181 100644 --- a/configure.ac +++ b/configure.ac @@ -63,10 +63,44 @@ LIBZMQ_CHECK_ENABLE_DEBUG # Check wheter to enable code coverage LIBZMQ_WITH_GCOV -# Checks for libraries -AC_CHECK_LIB([pthread], [pthread_create]) -AC_CHECK_LIB([rt], [clock_gettime]) -AC_CHECK_LIB([sodium], [sodium_init],,AC_MSG_WARN(libsodium is needed for CURVE security)) +# Allow libsodium to be installed in a custom path: + +AC_ARG_WITH([libsodium], + [AS_HELP_STRING([--with-libsodium], + [Specify libsodium prefix])], + [zmq_search_libsodium="yes"], + []) + +if test "x$zmq_search_libsodium" = "xyes"; then + if test -r "${with_libsodium}/include/sodium.h"; then + CPPFLAGS="-I${with_libsodium}/include ${CPPFLAGS}" + LDFLAGS="-L${with_libsodium}/lib ${LDFLAGS}" + fi +fi + +AC_ARG_WITH([libsodium-include-dir], + [AS_HELP_STRING([--with-libsodium-include-dir], + [Specify libsodium include prefix])], + [zmq_search_libsodium_include="yes"], + []) + +if test "x$zmq_search_libsodium_include" = "xyes"; then + if test -r "${with_libsodium_include_dir}/sodium.h"; then + CPPFLAGS="-I${with_libsodium_include_dir}/include ${CPPFLAGS}" + fi +fi + +AC_ARG_WITH([libsodium_lib_dir], + [AS_HELP_STRING([--with-libsodium-lib-dir], + [Specify libsodium library prefix])], + [zmq_search_libsodium_lib="yes"], + []) + +if test "x$zmq_search_libsodium_lib" = "xyes"; then + if test -r "${with_libsodium_lib_dir}/libsodium.{a|so|dylib}"; then + LDFLAGS="-L${with_libsodium}/lib ${LDFLAGS}" + fi +fi # Set pedantic libzmq_pedantic="yes" @@ -122,6 +156,9 @@ case "${host_os}" in if test "x$solaris_has_atomic" = "xno"; then AC_DEFINE(ZMQ_FORCE_MUTEXES, 1, [Force to use mutexes]) fi + # ssp library is required for libsodium on Solaris-like systems + LDFLAGS="-lssp $LDFLAGS" + CPPFLAGS="$CPPFLAGS -Wno-long-long" ;; *freebsd*) # Define on FreeBSD to enable all library features @@ -215,6 +252,11 @@ case "${host_os}" in ;; esac +# Checks for libraries +AC_CHECK_LIB([pthread], [pthread_create]) +AC_CHECK_LIB([rt], [clock_gettime]) +AC_CHECK_LIB([sodium], [sodium_init],,AC_MSG_WARN(libsodium is needed for CURVE security)) + # # Check if the compiler supports -fvisibility=hidden flag. MinGW32 uses __declspec # diff --git a/include/zmq_utils.h b/include/zmq_utils.h index a40df7e2..4fe8fcd2 100644 --- a/include/zmq_utils.h +++ b/include/zmq_utils.h @@ -82,6 +82,12 @@ ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn* func, void* arg); /* Wait for thread to complete then free up resources. */ ZMQ_EXPORT void zmq_threadclose (void* thread); +/* Encode data with Z85 encoding. Returns encoded data */ +ZMQ_EXPORT char *zmq_z85_encode (char *dest, uint8_t *data, size_t size); + +/* Decode data with Z85 encoding. Returns decoded data */ +ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, char *string); + #undef ZMQ_EXPORT #ifdef __cplusplus diff --git a/tools/curve_keygen.c b/tools/curve_keygen.c index c18c4621..eb1f0bbb 100644 --- a/tools/curve_keygen.c +++ b/tools/curve_keygen.c @@ -25,6 +25,7 @@ */ #include +#include #include #ifdef HAVE_LIBSODIUM # include