Core: SXT: libsodium dependency added;

master
Alexander Vdolainen 6 years ago
parent a01dd93bb8
commit bd8069058e

@ -55,6 +55,7 @@ dnl checking fpr dependencies
PKG_CHECK_MODULES(OPENSSL, [openssl]) PKG_CHECK_MODULES(OPENSSL, [openssl])
PKG_CHECK_MODULES(LIBTDATA, [libtdata >= 0.2.2]) PKG_CHECK_MODULES(LIBTDATA, [libtdata >= 0.2.2])
PKG_CHECK_MODULES(LIBSEXPR, [libsexpr >= 1.3.1]) PKG_CHECK_MODULES(LIBSEXPR, [libsexpr >= 1.3.1])
PKG_CHECK_MODULES(LIBSODIUM, [libsodium >= 1.0.15])
PKG_CHECK_MODULES(LIBNDBUF, [libndbuf]) PKG_CHECK_MODULES(LIBNDBUF, [libndbuf])
case $host_os in case $host_os in

@ -21,7 +21,7 @@ libsxt_la_SOURCES = \
libsxt_la_LDFLAGS = libsxt_la_LDFLAGS =
libsxt_la_LIBADD = -lpthread -lcrypto $(OPENSSL_LIBS) libsxt_la_LIBADD = -lpthread -lcrypto $(OPENSSL_LIBS) $(LIBSODIUM_LIBS)
if COND_WIN32 if COND_WIN32

@ -44,6 +44,7 @@
#include <uuid/uuid.h> #include <uuid/uuid.h>
#endif #endif
#include <sodium.h>
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/err.h> #include <openssl/err.h>
@ -68,6 +69,8 @@ int sxt_init(void)
OpenSSL_add_all_algorithms(); OpenSSL_add_all_algorithms();
if(sodium_init() == -1) return SXT_ERROR;
return lcrypt_init_ciphers(); return lcrypt_init_ciphers();
} }
@ -85,14 +88,7 @@ int sxt_reseed(void)
int sxt_get_random(void *data, int len, int pseudo) int sxt_get_random(void *data, int len, int pseudo)
{ {
if(pseudo) return RAND_bytes(data, len); randombytes_buf(data, (size_t) len);
else {
#if OPENSSL_API_COMPAT < 0x10100000L
RAND_pseudo_bytes(data, len);
#else
RAND_bytes(data, len);
#endif
}
return 1; return 1;
} }

@ -29,6 +29,8 @@
#include <string.h> #include <string.h>
#include <sys/time.h> #include <sys/time.h>
#include <sodium.h>
#include <openssl/aes.h> #include <openssl/aes.h>
#include <openssl/blowfish.h> #include <openssl/blowfish.h>
#include <openssl/rand.h> #include <openssl/rand.h>
@ -176,10 +178,7 @@ int lcrypt_init_ciphers(void)
/* misc */ /* misc */
int lcrypt_reseed(void) int lcrypt_reseed(void)
{ {
#ifndef WIN32 randombytes_stir();
struct timeval tv;
gettimeofday(&tv, NULL);
RAND_add(&tv, sizeof(struct timeval), 0.0);
#endif
return SXT_SUCCESS; return SXT_SUCCESS;
} }

Loading…
Cancel
Save