mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixes.
Fixed bug from merged PR. Don't build useless files when building with libsodium.
This commit is contained in:
parent
ccfa6c6a4f
commit
dfe5d9b256
|
@ -17,7 +17,6 @@
|
||||||
#include "../toxcore/crypto_core.h"
|
#include "../toxcore/crypto_core.h"
|
||||||
#ifdef VANILLA_NACL
|
#ifdef VANILLA_NACL
|
||||||
#include "../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h"
|
#include "../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h"
|
||||||
#include "../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h" /* sodium_memzero */
|
|
||||||
#endif
|
#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};
|
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};
|
||||||
|
|
|
@ -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_NTOX, test "x$BUILD_NTOX" = "xyes")
|
||||||
AM_CONDITIONAL(BUILD_AV, test "x$BUILD_AV" = "xyes")
|
AM_CONDITIONAL(BUILD_AV, test "x$BUILD_AV" = "xyes")
|
||||||
AM_CONDITIONAL(BUILD_TESTING, test "x$BUILD_TESTING" = "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")
|
AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes")
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
|
|
|
@ -158,6 +158,7 @@ void increment_nonce(uint8_t *nonce)
|
||||||
*/
|
*/
|
||||||
uint32_t i = crypto_box_NONCEBYTES;
|
uint32_t i = crypto_box_NONCEBYTES;
|
||||||
uint_fast16_t carry = 1U;
|
uint_fast16_t carry = 1U;
|
||||||
|
|
||||||
for (; i != 0; --i) {
|
for (; i != 0; --i) {
|
||||||
carry += (uint_fast16_t) nonce[i - 1];
|
carry += (uint_fast16_t) nonce[i - 1];
|
||||||
nonce[i - 1] = (uint8_t) carry;
|
nonce[i - 1] = (uint8_t) carry;
|
||||||
|
@ -173,7 +174,7 @@ void increment_nonce_number(uint8_t *nonce, uint32_t host_order_num)
|
||||||
* are independent of user-controlled input (you may have heard of the Heartbleed bug).
|
* are independent of user-controlled input (you may have heard of the Heartbleed bug).
|
||||||
*/
|
*/
|
||||||
const uint32_t big_endian_num = htonl(host_order_num);
|
const uint32_t big_endian_num = htonl(host_order_num);
|
||||||
const uint8_t* const num_vec = (const uint8_t*) &big_endian_num;
|
const uint8_t *const num_vec = (const uint8_t *) &big_endian_num;
|
||||||
uint8_t num_as_nonce[crypto_box_NONCEBYTES] = {0};
|
uint8_t num_as_nonce[crypto_box_NONCEBYTES] = {0};
|
||||||
num_as_nonce[crypto_box_NONCEBYTES - 4] = num_vec[0];
|
num_as_nonce[crypto_box_NONCEBYTES - 4] = num_vec[0];
|
||||||
num_as_nonce[crypto_box_NONCEBYTES - 3] = num_vec[1];
|
num_as_nonce[crypto_box_NONCEBYTES - 3] = num_vec[1];
|
||||||
|
@ -182,9 +183,10 @@ void increment_nonce_number(uint8_t *nonce, uint32_t host_order_num)
|
||||||
|
|
||||||
uint32_t i = crypto_box_NONCEBYTES;
|
uint32_t i = crypto_box_NONCEBYTES;
|
||||||
uint_fast16_t carry = 0U;
|
uint_fast16_t carry = 0U;
|
||||||
|
|
||||||
for (; i != 0; --i) {
|
for (; i != 0; --i) {
|
||||||
carry += (uint_fast16_t) nonce[i] + (uint_fast16_t) num_as_nonce[i];
|
carry += (uint_fast16_t) nonce[i - 1] + (uint_fast16_t) num_as_nonce[i - 1];
|
||||||
nonce[i] = (unsigned char) carry;
|
nonce[i - 1] = (unsigned char) carry;
|
||||||
carry >>= 8;
|
carry >>= 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,7 +229,7 @@ int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_ke
|
||||||
crypto_box_MACBYTES)
|
crypto_box_MACBYTES)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
uint8_t* nonce = packet + 1 + crypto_box_PUBLICKEYBYTES * 2;
|
uint8_t *nonce = packet + 1 + crypto_box_PUBLICKEYBYTES * 2;
|
||||||
new_nonce(nonce);
|
new_nonce(nonce);
|
||||||
uint8_t temp[MAX_CRYPTO_REQUEST_SIZE]; // FIXME sodium_memzero before exit function
|
uint8_t temp[MAX_CRYPTO_REQUEST_SIZE]; // FIXME sodium_memzero before exit function
|
||||||
memcpy(temp + 1, data, length);
|
memcpy(temp + 1, data, length);
|
||||||
|
@ -265,7 +267,7 @@ int handle_request(const uint8_t *self_public_key, const uint8_t *self_secret_ke
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memcpy(public_key, packet + 1 + crypto_box_PUBLICKEYBYTES, crypto_box_PUBLICKEYBYTES);
|
memcpy(public_key, packet + 1 + crypto_box_PUBLICKEYBYTES, crypto_box_PUBLICKEYBYTES);
|
||||||
const uint8_t* nonce = packet + 1 + crypto_box_PUBLICKEYBYTES * 2;
|
const uint8_t *nonce = packet + 1 + crypto_box_PUBLICKEYBYTES * 2;
|
||||||
uint8_t temp[MAX_CRYPTO_REQUEST_SIZE]; // FIXME sodium_memzero before exit function
|
uint8_t temp[MAX_CRYPTO_REQUEST_SIZE]; // FIXME sodium_memzero before exit function
|
||||||
int len1 = decrypt_data(public_key, self_secret_key, nonce,
|
int len1 = decrypt_data(public_key, self_secret_key, nonce,
|
||||||
packet + 1 + crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES,
|
packet + 1 + crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES,
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
#include <crypto_verify_32.h>
|
#include <crypto_verify_32.h>
|
||||||
#include <crypto_scalarmult_curve25519.h>
|
#include <crypto_scalarmult_curve25519.h>
|
||||||
#define crypto_box_MACBYTES (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES)
|
#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
|
#endif
|
||||||
|
|
||||||
#define crypto_box_KEYBYTES (crypto_box_BEFORENMBYTES)
|
#define crypto_box_KEYBYTES (crypto_box_BEFORENMBYTES)
|
||||||
|
|
|
@ -363,7 +363,8 @@ static int handle_crypto_handshake(const Net_Crypto *c, uint8_t *nonce, uint8_t
|
||||||
if (len != sizeof(plain))
|
if (len != sizeof(plain))
|
||||||
return -1;
|
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;
|
return -1;
|
||||||
|
|
||||||
memcpy(nonce, plain, crypto_box_NONCEBYTES);
|
memcpy(nonce, plain, crypto_box_NONCEBYTES);
|
||||||
|
|
|
@ -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;
|
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,
|
index = add_to_entries(onion_a, source, packet_public_key, data_public_key,
|
||||||
packet + (ANNOUNCE_REQUEST_SIZE_RECV - ONION_RETURN_3));
|
packet + (ANNOUNCE_REQUEST_SIZE_RECV - ONION_RETURN_3));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,7 +5,12 @@ libtoxencryptsave_la_include_HEADERS = \
|
||||||
|
|
||||||
libtoxencryptsave_la_includedir = $(includedir)/tox
|
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/crypto_scrypt.h \
|
||||||
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.c \
|
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pbkdf2-sha256.c \
|
||||||
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.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/sysendian.h \
|
||||||
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h \
|
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/utils.h \
|
||||||
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c \
|
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c \
|
||||||
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c \
|
../toxencryptsave/crypto_pwhash_scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c
|
||||||
../toxencryptsave/toxencryptsave.h \
|
endif
|
||||||
../toxencryptsave/toxencryptsave.c
|
|
||||||
|
|
||||||
|
|
||||||
libtoxencryptsave_la_CFLAGS = -I$(top_srcdir) \
|
libtoxencryptsave_la_CFLAGS = -I$(top_srcdir) \
|
||||||
-I$(top_srcdir)/toxcore \
|
-I$(top_srcdir)/toxcore \
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
|
|
||||||
#ifdef VANILLA_NACL
|
#ifdef VANILLA_NACL
|
||||||
#include "crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h"
|
#include "crypto_pwhash_scryptsalsa208sha256/crypto_pwhash_scryptsalsa208sha256.h"
|
||||||
#include "crypto_pwhash_scryptsalsa208sha256/utils.h" /* sodium_memzero */
|
|
||||||
#include <crypto_hash_sha256.h>
|
#include <crypto_hash_sha256.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user