From e01a1ccd94c9d8ba0a3c8aa05a767761b90a1d6d Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 6 Mar 2020 13:03:47 +0900 Subject: [PATCH] Fix compilation fail on no libsodium --- src/UDPC_Defines.hpp | 4 +++- src/UDPConnection.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/UDPC_Defines.hpp b/src/UDPC_Defines.hpp index 16c3c29..416fe19 100644 --- a/src/UDPC_Defines.hpp +++ b/src/UDPC_Defines.hpp @@ -35,7 +35,9 @@ #include "TSLQueue.hpp" #include "UDPC.h" -#include +#ifdef UDPC_LIBSODIUM_ENABLED +# include +#endif #define UDPC_MIN_HEADER_SIZE 20 #define UDPC_CON_HEADER_SIZE (UDPC_MIN_HEADER_SIZE+4) diff --git a/src/UDPConnection.cpp b/src/UDPConnection.cpp index 36d0932..1e0d28f 100644 --- a/src/UDPConnection.cpp +++ b/src/UDPConnection.cpp @@ -2349,11 +2349,15 @@ int UDPC_set_libsodium_keys(UDPC_HContext ctx, const unsigned char *sk, const un } int UDPC_set_libsodium_key_easy(UDPC_HContext ctx, const unsigned char *sk) { +#ifndef UDPC_LIBSODIUM_ENABLED + return 0; +#else unsigned char pk[crypto_sign_PUBLICKEYBYTES]; if(crypto_sign_ed25519_sk_to_pk(pk, sk) != 0) { return 0; } return UDPC_set_libsodium_keys(ctx, sk, pk); +#endif } int UDPC_unset_libsodium_keys(UDPC_HContext ctx) {