Fixed bug from merged PR.

Don't build useless files when building with libsodium.
This commit is contained in:
irungentoo 2016-01-30 17:23:15 -05:00
parent ccfa6c6a4f
commit dfe5d9b256
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
8 changed files with 23 additions and 14 deletions

View File

@ -17,7 +17,6 @@
#include "../toxcore/crypto_core.h"
#ifdef VANILLA_NACL
#include "../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h"
#include "../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h" /* sodium_memzero */
#endif
unsigned char salt[32] = {0xB1, 0xC2, 0x09, 0xEE, 0x50, 0x6C, 0xF0, 0x20, 0xC4, 0xD6, 0xEB, 0xC0, 0x44, 0x51, 0x3B, 0x60, 0x4B, 0x39, 0x4A, 0xCF, 0x09, 0x53, 0x4F, 0xEA, 0x08, 0x41, 0xFA, 0xCA, 0x66, 0xD2, 0x68, 0x7F};

View File

@ -688,6 +688,7 @@ AM_CONDITIONAL(BUILD_TESTS, test "x$BUILD_TESTS" = "xyes")
AM_CONDITIONAL(BUILD_NTOX, test "x$BUILD_NTOX" = "xyes")
AM_CONDITIONAL(BUILD_AV, test "x$BUILD_AV" = "xyes")
AM_CONDITIONAL(BUILD_TESTING, test "x$BUILD_TESTING" = "xyes")
AM_CONDITIONAL(WITH_NACL, test "x$WANT_NACL" = "xyes")
AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes")
AC_CONFIG_FILES([Makefile

View File

@ -158,6 +158,7 @@ void increment_nonce(uint8_t *nonce)
*/
uint32_t i = crypto_box_NONCEBYTES;
uint_fast16_t carry = 1U;
for (; i != 0; --i) {
carry += (uint_fast16_t) nonce[i - 1];
nonce[i - 1] = (uint8_t) carry;
@ -182,9 +183,10 @@ void increment_nonce_number(uint8_t *nonce, uint32_t host_order_num)
uint32_t i = crypto_box_NONCEBYTES;
uint_fast16_t carry = 0U;
for (; i != 0; --i) {
carry += (uint_fast16_t) nonce[i] + (uint_fast16_t) num_as_nonce[i];
nonce[i] = (unsigned char) carry;
carry += (uint_fast16_t) nonce[i - 1] + (uint_fast16_t) num_as_nonce[i - 1];
nonce[i - 1] = (unsigned char) carry;
carry >>= 8;
}
}

View File

@ -37,6 +37,9 @@
#include <crypto_verify_32.h>
#include <crypto_scalarmult_curve25519.h>
#define crypto_box_MACBYTES (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES)
/* I know */
#define sodium_memcmp(a, b, c) memcmp(a, b, c)
#define sodium_memzero(a, c) memset(a, 0, c)
#endif
#define crypto_box_KEYBYTES (crypto_box_BEFORENMBYTES)

View File

@ -363,7 +363,8 @@ static int handle_crypto_handshake(const Net_Crypto *c, uint8_t *nonce, uint8_t
if (len != sizeof(plain))
return -1;
if (sodium_memcmp(cookie_hash, plain + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, crypto_hash_sha512_BYTES) != 0)
if (sodium_memcmp(cookie_hash, plain + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES,
crypto_hash_sha512_BYTES) != 0)
return -1;
memcpy(nonce, plain, crypto_box_NONCEBYTES);

View File

@ -316,7 +316,8 @@ static int handle_announce_request(void *object, IP_Port source, const uint8_t *
uint8_t *data_public_key = plain + ONION_PING_ID_SIZE + crypto_box_PUBLICKEYBYTES;
if (sodium_memcmp(ping_id1, plain, ONION_PING_ID_SIZE) == 0 || sodium_memcmp(ping_id2, plain, ONION_PING_ID_SIZE) == 0) {
if (sodium_memcmp(ping_id1, plain, ONION_PING_ID_SIZE) == 0
|| sodium_memcmp(ping_id2, plain, ONION_PING_ID_SIZE) == 0) {
index = add_to_entries(onion_a, source, packet_public_key, data_public_key,
packet + (ANNOUNCE_REQUEST_SIZE_RECV - ONION_RETURN_3));
} else {

View File

@ -5,7 +5,12 @@ libtoxencryptsave_la_include_HEADERS = \
libtoxencryptsave_la_includedir = $(includedir)/tox
libtoxencryptsave_la_SOURCES = ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h \
libtoxencryptsave_la_SOURCES = ../toxencryptsave/toxencryptsave.h \
../toxencryptsave/toxencryptsave.c
if WITH_NACL
libtoxencryptsave_la_SOURCES += ../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h \
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_scrypt.h \
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.c \
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c \
@ -19,10 +24,8 @@ libtoxencryptsave_la_SOURCES = ../toxencryptsave/crypto_pwhash_scryptsalsa208sha
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sysendian.h \
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h \
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c \
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c \
../toxencryptsave/toxencryptsave.h \
../toxencryptsave/toxencryptsave.c
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c
endif
libtoxencryptsave_la_CFLAGS = -I$(top_srcdir) \
-I$(top_srcdir)/toxcore \

View File

@ -32,7 +32,6 @@
#ifdef VANILLA_NACL
#include "crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h"
#include "crypto_pwhash_scryptsalsa208sha256/utils.h" /* sodium_memzero */
#include <crypto_hash_sha256.h>
#endif