diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-12-19 02:47:42 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-12-22 10:26:59 +0000 |
commit | ce29c8e7ec91d95167b2dea3aee9fd1ae1aac254 (patch) | |
tree | a288df55c44e8edf816e6abbde19a70faef73394 /toxcore/tox.c | |
parent | 7122d2e862e028a730478d88cd61557fbed16ebf (diff) |
Wrap all sodium/nacl functions in crypto_core.c.
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r-- | toxcore/tox.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c index 37ea4849..7a9a708c 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -37,28 +37,28 @@ typedef struct Messenger Tox; | |||
37 | 37 | ||
38 | #define SET_ERROR_PARAMETER(param, x) {if(param) {*param = x;}} | 38 | #define SET_ERROR_PARAMETER(param, x) {if(param) {*param = x;}} |
39 | 39 | ||
40 | #if TOX_HASH_LENGTH != crypto_hash_sha256_BYTES | 40 | #if TOX_HASH_LENGTH != CRYPTO_SHA256_SIZE |
41 | #error TOX_HASH_LENGTH is assumed to be equal to crypto_hash_sha256_BYTES | 41 | #error TOX_HASH_LENGTH is assumed to be equal to CRYPTO_SHA256_SIZE |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #if FILE_ID_LENGTH != crypto_box_KEYBYTES | 44 | #if FILE_ID_LENGTH != CRYPTO_SYMMETRIC_KEY_SIZE |
45 | #error FILE_ID_LENGTH is assumed to be equal to crypto_box_KEYBYTES | 45 | #error FILE_ID_LENGTH is assumed to be equal to CRYPTO_SYMMETRIC_KEY_SIZE |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | #if TOX_FILE_ID_LENGTH != crypto_box_KEYBYTES | 48 | #if TOX_FILE_ID_LENGTH != CRYPTO_SYMMETRIC_KEY_SIZE |
49 | #error TOX_FILE_ID_LENGTH is assumed to be equal to crypto_box_KEYBYTES | 49 | #error TOX_FILE_ID_LENGTH is assumed to be equal to CRYPTO_SYMMETRIC_KEY_SIZE |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | #if TOX_FILE_ID_LENGTH != TOX_HASH_LENGTH | 52 | #if TOX_FILE_ID_LENGTH != TOX_HASH_LENGTH |
53 | #error TOX_FILE_ID_LENGTH is assumed to be equal to TOX_HASH_LENGTH | 53 | #error TOX_FILE_ID_LENGTH is assumed to be equal to TOX_HASH_LENGTH |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #if TOX_PUBLIC_KEY_SIZE != crypto_box_PUBLICKEYBYTES | 56 | #if TOX_PUBLIC_KEY_SIZE != CRYPTO_PUBLIC_KEY_SIZE |
57 | #error TOX_PUBLIC_KEY_SIZE is assumed to be equal to crypto_box_PUBLICKEYBYTES | 57 | #error TOX_PUBLIC_KEY_SIZE is assumed to be equal to CRYPTO_PUBLIC_KEY_SIZE |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #if TOX_SECRET_KEY_SIZE != crypto_box_SECRETKEYBYTES | 60 | #if TOX_SECRET_KEY_SIZE != CRYPTO_SECRET_KEY_SIZE |
61 | #error TOX_SECRET_KEY_SIZE is assumed to be equal to crypto_box_SECRETKEYBYTES | 61 | #error TOX_SECRET_KEY_SIZE is assumed to be equal to CRYPTO_SECRET_KEY_SIZE |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | #if TOX_MAX_NAME_LENGTH != MAX_NAME_LENGTH | 64 | #if TOX_MAX_NAME_LENGTH != MAX_NAME_LENGTH |
@@ -206,7 +206,7 @@ Tox *tox_new(const struct Tox_Options *options, TOX_ERR_NEW *error) | |||
206 | return NULL; | 206 | return NULL; |
207 | } | 207 | } |
208 | 208 | ||
209 | if (sodium_memcmp(options->savedata_data, TOX_ENC_SAVE_MAGIC_NUMBER, TOX_ENC_SAVE_MAGIC_LENGTH) == 0) { | 209 | if (crypto_memcmp(options->savedata_data, TOX_ENC_SAVE_MAGIC_NUMBER, TOX_ENC_SAVE_MAGIC_LENGTH) == 0) { |
210 | SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_ENCRYPTED); | 210 | SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_ENCRYPTED); |
211 | return NULL; | 211 | return NULL; |
212 | } | 212 | } |
@@ -495,7 +495,7 @@ void tox_self_get_public_key(const Tox *tox, uint8_t *public_key) | |||
495 | const Messenger *m = tox; | 495 | const Messenger *m = tox; |
496 | 496 | ||
497 | if (public_key) { | 497 | if (public_key) { |
498 | memcpy(public_key, m->net_crypto->self_public_key, crypto_box_PUBLICKEYBYTES); | 498 | memcpy(public_key, m->net_crypto->self_public_key, CRYPTO_PUBLIC_KEY_SIZE); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
@@ -504,7 +504,7 @@ void tox_self_get_secret_key(const Tox *tox, uint8_t *secret_key) | |||
504 | const Messenger *m = tox; | 504 | const Messenger *m = tox; |
505 | 505 | ||
506 | if (secret_key) { | 506 | if (secret_key) { |
507 | memcpy(secret_key, m->net_crypto->self_secret_key, crypto_box_SECRETKEYBYTES); | 507 | memcpy(secret_key, m->net_crypto->self_secret_key, CRYPTO_SECRET_KEY_SIZE); |
508 | } | 508 | } |
509 | } | 509 | } |
510 | 510 | ||
@@ -972,7 +972,7 @@ bool tox_hash(uint8_t *hash, const uint8_t *data, size_t length) | |||
972 | return 0; | 972 | return 0; |
973 | } | 973 | } |
974 | 974 | ||
975 | crypto_hash_sha256(hash, data, length); | 975 | crypto_sha256(hash, data, length); |
976 | return 1; | 976 | return 1; |
977 | } | 977 | } |
978 | 978 | ||
@@ -1645,7 +1645,7 @@ void tox_self_get_dht_id(const Tox *tox, uint8_t *dht_id) | |||
1645 | { | 1645 | { |
1646 | if (dht_id) { | 1646 | if (dht_id) { |
1647 | const Messenger *m = tox; | 1647 | const Messenger *m = tox; |
1648 | memcpy(dht_id , m->dht->self_public_key, crypto_box_PUBLICKEYBYTES); | 1648 | memcpy(dht_id , m->dht->self_public_key, CRYPTO_PUBLIC_KEY_SIZE); |
1649 | } | 1649 | } |
1650 | } | 1650 | } |
1651 | 1651 | ||