Fix compilation fail on no libsodium

This commit is contained in:
Stephen Seo 2020-03-06 13:03:47 +09:00
parent 75f54119bf
commit e01a1ccd94
2 changed files with 7 additions and 1 deletions

View file

@ -35,7 +35,9 @@
#include "TSLQueue.hpp" #include "TSLQueue.hpp"
#include "UDPC.h" #include "UDPC.h"
#include <sodium.h> #ifdef UDPC_LIBSODIUM_ENABLED
# include <sodium.h>
#endif
#define UDPC_MIN_HEADER_SIZE 20 #define UDPC_MIN_HEADER_SIZE 20
#define UDPC_CON_HEADER_SIZE (UDPC_MIN_HEADER_SIZE+4) #define UDPC_CON_HEADER_SIZE (UDPC_MIN_HEADER_SIZE+4)

View file

@ -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) { 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]; unsigned char pk[crypto_sign_PUBLICKEYBYTES];
if(crypto_sign_ed25519_sk_to_pk(pk, sk) != 0) { if(crypto_sign_ed25519_sk_to_pk(pk, sk) != 0) {
return 0; return 0;
} }
return UDPC_set_libsodium_keys(ctx, sk, pk); return UDPC_set_libsodium_keys(ctx, sk, pk);
#endif
} }
int UDPC_unset_libsodium_keys(UDPC_HContext ctx) { int UDPC_unset_libsodium_keys(UDPC_HContext ctx) {