diff options
-rw-r--r-- | auto_tests/encryptsave_test.c | 15 | ||||
-rw-r--r-- | toxav/toxav_old.c | 8 | ||||
-rw-r--r-- | toxcore/crypto_core.c | 4 | ||||
-rw-r--r-- | toxcore/crypto_core.h | 2 | ||||
-rw-r--r-- | toxcore/network.c | 5 |
5 files changed, 20 insertions, 14 deletions
diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c index 266dfe96..c970b756 100644 --- a/auto_tests/encryptsave_test.c +++ b/auto_tests/encryptsave_test.c | |||
@@ -41,13 +41,14 @@ void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *dat | |||
41 | START_TEST(test_known_kdf) | 41 | START_TEST(test_known_kdf) |
42 | { | 42 | { |
43 | unsigned char out[crypto_box_BEFORENMBYTES]; | 43 | unsigned char out[crypto_box_BEFORENMBYTES]; |
44 | crypto_pwhash_scryptsalsa208sha256(out, | 44 | int res = crypto_pwhash_scryptsalsa208sha256(out, |
45 | crypto_box_BEFORENMBYTES, | 45 | crypto_box_BEFORENMBYTES, |
46 | pw, | 46 | pw, |
47 | pwlen, | 47 | pwlen, |
48 | salt, | 48 | salt, |
49 | crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE * 8, | 49 | crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE * 8, |
50 | crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE); | 50 | crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE); |
51 | ck_assert_msg(res != -1, "crypto function failed"); | ||
51 | ck_assert_msg(memcmp(out, known_key, crypto_box_BEFORENMBYTES) == 0, "derived key is wrong"); | 52 | ck_assert_msg(memcmp(out, known_key, crypto_box_BEFORENMBYTES) == 0, "derived key is wrong"); |
52 | } | 53 | } |
53 | END_TEST | 54 | END_TEST |
diff --git a/toxav/toxav_old.c b/toxav/toxav_old.c index 7d7e5e7b..0294a609 100644 --- a/toxav/toxav_old.c +++ b/toxav/toxav_old.c | |||
@@ -39,7 +39,8 @@ int toxav_add_av_groupchat(struct Tox *tox, void (*audio_callback)(void *, int, | |||
39 | uint8_t, unsigned int, void *), void *userdata) | 39 | uint8_t, unsigned int, void *), void *userdata) |
40 | { | 40 | { |
41 | Messenger *m = (Messenger *)tox; | 41 | Messenger *m = (Messenger *)tox; |
42 | return add_av_groupchat(m->group_chat_object, audio_callback, userdata); | 42 | return add_av_groupchat(m->group_chat_object, (void (*)(Messenger *, int, int, const int16_t *, unsigned int, |
43 | uint8_t, unsigned int, void *))audio_callback, userdata); | ||
43 | } | 44 | } |
44 | 45 | ||
45 | /* Join a AV group (you need to have been invited first.) | 46 | /* Join a AV group (you need to have been invited first.) |
@@ -57,7 +58,8 @@ int toxav_join_av_groupchat(struct Tox *tox, int32_t friendnumber, const uint8_t | |||
57 | void *userdata) | 58 | void *userdata) |
58 | { | 59 | { |
59 | Messenger *m = (Messenger *)tox; | 60 | Messenger *m = (Messenger *)tox; |
60 | return join_av_groupchat(m->group_chat_object, friendnumber, data, length, audio_callback, userdata); | 61 | return join_av_groupchat(m->group_chat_object, friendnumber, data, length, (void (*)(Messenger *, int, int, |
62 | const int16_t *, unsigned int, uint8_t, unsigned int, void *))audio_callback, userdata); | ||
61 | } | 63 | } |
62 | 64 | ||
63 | /* Send audio to the group chat. | 65 | /* Send audio to the group chat. |
@@ -78,4 +80,4 @@ int toxav_group_send_audio(struct Tox *tox, int groupnumber, const int16_t *pcm, | |||
78 | { | 80 | { |
79 | Messenger *m = (Messenger *)tox; | 81 | Messenger *m = (Messenger *)tox; |
80 | return group_send_audio(m->group_chat_object, groupnumber, pcm, samples, channels, sample_rate); | 82 | return group_send_audio(m->group_chat_object, groupnumber, pcm, samples, channels, sample_rate); |
81 | } \ No newline at end of file | 83 | } |
diff --git a/toxcore/crypto_core.c b/toxcore/crypto_core.c index a733c38e..3b379ca6 100644 --- a/toxcore/crypto_core.c +++ b/toxcore/crypto_core.c | |||
@@ -76,9 +76,9 @@ int public_key_valid(const uint8_t *public_key) | |||
76 | * encrypt/decrypt operation. | 76 | * encrypt/decrypt operation. |
77 | * enc_key has to be crypto_box_BEFORENMBYTES bytes long. | 77 | * enc_key has to be crypto_box_BEFORENMBYTES bytes long. |
78 | */ | 78 | */ |
79 | void encrypt_precompute(const uint8_t *public_key, const uint8_t *secret_key, uint8_t *enc_key) | 79 | int encrypt_precompute(const uint8_t *public_key, const uint8_t *secret_key, uint8_t *enc_key) |
80 | { | 80 | { |
81 | crypto_box_beforenm(enc_key, public_key, secret_key); | 81 | return crypto_box_beforenm(enc_key, public_key, secret_key); |
82 | } | 82 | } |
83 | 83 | ||
84 | int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *plain, uint32_t length, | 84 | int encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce, const uint8_t *plain, uint32_t length, |
diff --git a/toxcore/crypto_core.h b/toxcore/crypto_core.h index ab509f09..1c9d7f94 100644 --- a/toxcore/crypto_core.h +++ b/toxcore/crypto_core.h | |||
@@ -87,7 +87,7 @@ int decrypt_data(const uint8_t *public_key, const uint8_t *secret_key, const uin | |||
87 | /* Fast encrypt/decrypt operations. Use if this is not a one-time communication. | 87 | /* Fast encrypt/decrypt operations. Use if this is not a one-time communication. |
88 | encrypt_precompute does the shared-key generation once so it does not have | 88 | encrypt_precompute does the shared-key generation once so it does not have |
89 | to be preformed on every encrypt/decrypt. */ | 89 | to be preformed on every encrypt/decrypt. */ |
90 | void encrypt_precompute(const uint8_t *public_key, const uint8_t *secret_key, uint8_t *enc_key); | 90 | int encrypt_precompute(const uint8_t *public_key, const uint8_t *secret_key, uint8_t *enc_key); |
91 | 91 | ||
92 | /* Encrypts plain of length length to encrypted of length + 16 using a | 92 | /* Encrypts plain of length length to encrypted of length + 16 using a |
93 | * secret key crypto_box_KEYBYTES big and a 24 byte nonce. | 93 | * secret key crypto_box_KEYBYTES big and a 24 byte nonce. |
diff --git a/toxcore/network.c b/toxcore/network.c index c6cf6ed4..244512c0 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -451,7 +451,10 @@ int networking_at_startup(void) | |||
451 | #ifdef USE_RANDOMBYTES_STIR | 451 | #ifdef USE_RANDOMBYTES_STIR |
452 | randombytes_stir(); | 452 | randombytes_stir(); |
453 | #else | 453 | #else |
454 | sodium_init(); | 454 | |
455 | if (sodium_init() != 0) | ||
456 | return -1; | ||
457 | |||
455 | #endif /*USE_RANDOMBYTES_STIR*/ | 458 | #endif /*USE_RANDOMBYTES_STIR*/ |
456 | 459 | ||
457 | #endif/*VANILLA_NACL*/ | 460 | #endif/*VANILLA_NACL*/ |