diff options
Diffstat (limited to 'toxcore/crypto_core.h')
-rw-r--r-- | toxcore/crypto_core.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/toxcore/crypto_core.h b/toxcore/crypto_core.h index 1fca8078..7ee5f59e 100644 --- a/toxcore/crypto_core.h +++ b/toxcore/crypto_core.h | |||
@@ -25,12 +25,24 @@ | |||
25 | 25 | ||
26 | #include "network.h" | 26 | #include "network.h" |
27 | 27 | ||
28 | #ifndef VANILLA_NACL | ||
29 | /* We use libsodium by default. */ | ||
30 | #include <sodium.h> | ||
31 | #else | ||
32 | #include <crypto_box.h> | ||
33 | #include <randombytes.h> | ||
34 | #include <crypto_hash_sha256.h> | ||
35 | #include <crypto_hash_sha512.h> | ||
36 | #include <crypto_verify_16.h> | ||
37 | #include <crypto_verify_32.h> | ||
38 | #define crypto_box_MACBYTES (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES) | ||
39 | #endif | ||
28 | 40 | ||
29 | /* return zero if the buffer contains only zeros. */ | 41 | #define crypto_box_KEYBYTES (crypto_box_BEFORENMBYTES) |
30 | uint8_t crypto_iszero(uint8_t *buffer, uint32_t blen); | ||
31 | 42 | ||
32 | /* Use this instead of memcmp; not vulnerable to timing attacks. | 43 | /* Use this instead of memcmp; not vulnerable to timing attacks. |
33 | returns 0 if both mem locations of length are equal. */ | 44 | returns 0 if both mem locations of length are equal, |
45 | return -1 if they are not. */ | ||
34 | unsigned int crypto_cmp(uint8_t *mem1, uint8_t *mem2, uint32_t length); | 46 | unsigned int crypto_cmp(uint8_t *mem1, uint8_t *mem2, uint32_t length); |
35 | 47 | ||
36 | /* Encrypts plain of length length to encrypted of length + 16 using the | 48 | /* Encrypts plain of length length to encrypted of length + 16 using the |