From bb324029ad442a1f6dd7049a6e6fc1cbe4a05799 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 29 Oct 2013 03:45:34 +0100 Subject: Allow using libsodium instead of NaCl As libsodium has some strange include files (like a version.h), we try to use absolute include paths whenever possible in fastd now and rename our generated headers. --- src/CMakeLists.txt | 10 +++++----- src/compat.h | 2 +- src/fastd.c | 10 +++++++++- src/handshake.c | 2 +- src/methods/aes128_gcm/CMakeLists.txt | 2 +- src/methods/aes128_gcm/aes128_gcm.c | 4 ++-- src/methods/common.h | 2 +- src/methods/null/CMakeLists.txt | 2 +- src/methods/null/null.c | 2 +- src/methods/xsalsa20_poly1305/CMakeLists.txt | 2 +- src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c | 2 +- src/options.c | 2 +- src/protocols/ec25519_fhmqvc/CMakeLists.txt | 2 +- src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c | 8 ++++---- src/types.h | 2 +- 15 files changed, 31 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d3fa991..4f8ab25 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,8 @@ set_directory_properties(PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE) -set(FASTD_CFLAGS "-Wall -pthread ${UECC_CFLAGS_OTHER}") +set(FASTD_CFLAGS "-Wall -pthread ${UECC_CFLAGS_OTHER} ${NACL_CFLAGS_OTHER}") -include_directories(BEFORE ${FASTD_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CAP_INCLUDE_DIR} ${NACL_INCLUDE_DIR}) -link_directories(${UECC_LIBRARY_DIRS}) +include_directories(${FASTD_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CAP_INCLUDE_DIR} ${NACL_INCLUDE_DIRS}) +link_directories(${UECC_LIBRARY_DIRS} ${NACL_LIBRARY_DIRS}) add_subdirectory(protocols) @@ -35,8 +35,8 @@ add_executable(fastd ${METHOD_SOURCES} ) set_property(TARGET fastd PROPERTY COMPILE_FLAGS "${FASTD_CFLAGS}") -set_property(TARGET fastd PROPERTY LINK_FLAGS "-pthread ${UECC_LDFLAGS_OTHER}") -target_link_libraries(fastd ${RT_LIBRARY} ${CAP_LIBRARY} ${UECC_LIBRARIES} ${NACL_LIBRARY}) +set_property(TARGET fastd PROPERTY LINK_FLAGS "-pthread ${UECC_LDFLAGS_OTHER} ${NACL_LDFLAGS_OTHER}") +target_link_libraries(fastd ${RT_LIBRARY} ${CAP_LIBRARY} ${UECC_LIBRARIES} ${NACL_LIBRARIES}) add_dependencies(fastd version) diff --git a/src/compat.h b/src/compat.h index c127100..ba77f65 100644 --- a/src/compat.h +++ b/src/compat.h @@ -27,7 +27,7 @@ #ifndef _FASTD_COMPAT_H_ #define _FASTD_COMPAT_H_ -#include +#include #include #include diff --git a/src/fastd.c b/src/fastd.c index c434216..ea197d3 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -28,7 +28,7 @@ #include "crypto.h" #include "handshake.h" #include "peer.h" -#include +#include #include #include @@ -39,6 +39,10 @@ #include #include +#ifdef USE_LIBSODIUM +#include +#endif + static volatile bool sighup = false; static volatile bool terminate = false; @@ -751,6 +755,10 @@ static void drop_caps(fastd_context_t *ctx) { } int main(int argc, char *argv[]) { +#ifdef USE_LIBSODIUM + sodium_init(); +#endif + fastd_context_t ctx = {}; close_fds(&ctx); diff --git a/src/handshake.c b/src/handshake.c index 2986b90..aecce23 100644 --- a/src/handshake.c +++ b/src/handshake.c @@ -26,7 +26,7 @@ #include "handshake.h" #include "peer.h" -#include +#include static const char *const RECORD_TYPES[RECORD_MAX] = { diff --git a/src/methods/aes128_gcm/CMakeLists.txt b/src/methods/aes128_gcm/CMakeLists.txt index 1c5aa3f..6d07318 100644 --- a/src/methods/aes128_gcm/CMakeLists.txt +++ b/src/methods/aes128_gcm/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(BEFORE ${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR} ${NACL_INCLUDE_DIR}) +include_directories(${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR} ${NACL_INCLUDE_DIRS}) add_library(method_aes128_gcm OBJECT aes128_gcm.c diff --git a/src/methods/aes128_gcm/aes128_gcm.c b/src/methods/aes128_gcm/aes128_gcm.c index 610df7c..0b0ad56 100644 --- a/src/methods/aes128_gcm/aes128_gcm.c +++ b/src/methods/aes128_gcm/aes128_gcm.c @@ -24,8 +24,8 @@ */ -#include -#include +#include "../../fastd.h" +#include "../../crypto.h" #include "../common.h" diff --git a/src/methods/common.h b/src/methods/common.h index 0337265..0a26a32 100644 --- a/src/methods/common.h +++ b/src/methods/common.h @@ -27,7 +27,7 @@ #ifndef _FASTD_METHODS_COMMON_H_ #define _FASTD_METHODS_COMMON_H_ -#include +#include "../fastd.h" #define COMMON_NONCEBYTES 7 diff --git a/src/methods/null/CMakeLists.txt b/src/methods/null/CMakeLists.txt index 91c1832..90ead47 100644 --- a/src/methods/null/CMakeLists.txt +++ b/src/methods/null/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(BEFORE ${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR}) +include_directories(${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR}) add_library(method_null OBJECT null.c diff --git a/src/methods/null/null.c b/src/methods/null/null.c index 643e5e1..720cb79 100644 --- a/src/methods/null/null.c +++ b/src/methods/null/null.c @@ -24,7 +24,7 @@ */ -#include +#include "../../fastd.h" struct fastd_method_session_state { diff --git a/src/methods/xsalsa20_poly1305/CMakeLists.txt b/src/methods/xsalsa20_poly1305/CMakeLists.txt index 09b029c..170a1ed 100644 --- a/src/methods/xsalsa20_poly1305/CMakeLists.txt +++ b/src/methods/xsalsa20_poly1305/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(BEFORE ${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR} ${NACL_INCLUDE_DIR}) +include_directories(${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR} ${NACL_INCLUDE_DIRS}) add_library(method_xsalsa20_poly1305 OBJECT xsalsa20_poly1305.c diff --git a/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c index 0a9f2c8..825a4b8 100644 --- a/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c +++ b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c @@ -24,7 +24,7 @@ */ -#include +#include "../../fastd.h" #include "../common.h" #include diff --git a/src/options.c b/src/options.c index 8d93bf9..333061a 100644 --- a/src/options.c +++ b/src/options.c @@ -26,7 +26,7 @@ #include "fastd.h" #include "peer.h" -#include +#include #include diff --git a/src/protocols/ec25519_fhmqvc/CMakeLists.txt b/src/protocols/ec25519_fhmqvc/CMakeLists.txt index ff1e246..91d6eaa 100644 --- a/src/protocols/ec25519_fhmqvc/CMakeLists.txt +++ b/src/protocols/ec25519_fhmqvc/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(BEFORE ${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR} ${UECC_INCLUDE_DIRS}) +include_directories(${FASTD_SOURCE_DIR}/src ${FASTD_BINARY_DIR} ${UECC_INCLUDE_DIRS}) add_library(protocol_ec25519_fhmqvc OBJECT ec25519_fhmqvc.c diff --git a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c index 9fe1414..d894512 100644 --- a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c +++ b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c @@ -24,10 +24,10 @@ */ -#include -#include -#include -#include +#include "../../fastd.h" +#include "../../handshake.h" +#include "../../peer.h" +#include "../../sha256.h" #include diff --git a/src/types.h b/src/types.h index 8e70326..a2b7d38 100644 --- a/src/types.h +++ b/src/types.h @@ -33,7 +33,7 @@ #ifndef _FASTD_TYPES_H_ #define _FASTD_TYPES_H_ -#include +#include #include -- cgit v1.2.3