diff options
author | dubslow <bunslow@gmail.com> | 2014-10-12 03:08:05 -0500 |
---|---|---|
committer | dubslow <bunslow@gmail.com> | 2014-10-12 03:11:11 -0500 |
commit | 57d3b3be05788ed46a7fef0b3073c6c5222cf8d3 (patch) | |
tree | 1bb4d0dbedc78ef729fcb0e317898ec61124f9c7 /toxencryptsave/toxencryptsave.h | |
parent | 458a09f6ab289afa1e475f388988d88e07dcb8b0 (diff) |
Fix include issue
Diffstat (limited to 'toxencryptsave/toxencryptsave.h')
-rw-r--r-- | toxencryptsave/toxencryptsave.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/toxencryptsave/toxencryptsave.h b/toxencryptsave/toxencryptsave.h index 2fb6a8c5..d805cf97 100644 --- a/toxencryptsave/toxencryptsave.h +++ b/toxencryptsave/toxencryptsave.h | |||
@@ -35,10 +35,11 @@ extern "C" { | |||
35 | typedef struct Tox Tox; | 35 | typedef struct Tox Tox; |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #define TOX_PASS_ENCRYPTION_EXTRA_LENGTH (crypto_box_MACBYTES + crypto_box_NONCEBYTES \ | 38 | // these two functions provide access to these defines in toxencryptsave.c, which |
39 | + crypto_pwhash_scryptsalsa208sha256_SALTBYTES) | 39 | //otherwise aren't actually available in clients... |
40 | int tox_pass_encryption_extra_length(); | ||
40 | 41 | ||
41 | #define TOX_PASS_KEY_LENGTH (crypto_box_KEYBYTES + crypto_pwhash_scryptsalsa208sha256_SALTBYTES) | 42 | int tox_pass_key_length(); |
42 | 43 | ||
43 | /* This "module" provides functions analogous to tox_load and tox_save in toxcore | 44 | /* This "module" provides functions analogous to tox_load and tox_save in toxcore |
44 | * Clients should consider alerting their users that, unlike plain data, if even one bit | 45 | * Clients should consider alerting their users that, unlike plain data, if even one bit |
@@ -50,7 +51,7 @@ typedef struct Tox Tox; | |||
50 | uint32_t tox_encrypted_size(const Tox *tox); | 51 | uint32_t tox_encrypted_size(const Tox *tox); |
51 | 52 | ||
52 | /* Generates a secret symmetric key from the given passphrase. out_key must be at least | 53 | /* Generates a secret symmetric key from the given passphrase. out_key must be at least |
53 | * TOX_PASS_KEY_LENGTH bytes long. | 54 | * tox_pass_key_length() bytes long. |
54 | * Be sure to not compromise the key! Only keep it in memory, do not write to disk. | 55 | * Be sure to not compromise the key! Only keep it in memory, do not write to disk. |
55 | * This function is fairly cheap, but irungentoo insists that you be allowed to | 56 | * This function is fairly cheap, but irungentoo insists that you be allowed to |
56 | * cache the result if you want, to minimize computation for repeated encryptions. | 57 | * cache the result if you want, to minimize computation for repeated encryptions. |
@@ -64,8 +65,8 @@ uint32_t tox_encrypted_size(const Tox *tox); | |||
64 | int tox_derive_key_from_pass(uint8_t *passphrase, uint32_t pplength, uint8_t *out_key); | 65 | int tox_derive_key_from_pass(uint8_t *passphrase, uint32_t pplength, uint8_t *out_key); |
65 | 66 | ||
66 | /* Encrypt arbitrary with a key produced by tox_derive_key_from_pass. The output | 67 | /* Encrypt arbitrary with a key produced by tox_derive_key_from_pass. The output |
67 | * array must be at least data_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH bytes long. | 68 | * array must be at least data_len + tox_pass_encryption_extra_length() bytes long. |
68 | * key must be TOX_PASS_KEY_LENGTH bytes. | 69 | * key must be tox_pass_key_length() bytes. |
69 | * If you already have a symmetric key from somewhere besides this module, simply | 70 | * If you already have a symmetric key from somewhere besides this module, simply |
70 | * call encrypt_data_symmetric in toxcore/crypto_core directly. | 71 | * call encrypt_data_symmetric in toxcore/crypto_core directly. |
71 | * | 72 | * |
@@ -73,10 +74,10 @@ int tox_derive_key_from_pass(uint8_t *passphrase, uint32_t pplength, uint8_t *ou | |||
73 | * returns 0 on success | 74 | * returns 0 on success |
74 | * returns -1 on failure | 75 | * returns -1 on failure |
75 | */ | 76 | */ |
76 | int tox_pass_key_encrypt(uint8_t *data, uint32_t data_len, const uint8_t *key, uint8_t *out); | 77 | int tox_pass_key_encrypt(const uint8_t *data, uint32_t data_len, const uint8_t *key, uint8_t *out); |
77 | 78 | ||
78 | /* Encrypts the given data with the given passphrase. The output array must be | 79 | /* Encrypts the given data with the given passphrase. The output array must be |
79 | * at least data_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH bytes long. This delegates | 80 | * at least data_len + tox_pass_encryption_extra_length() bytes long. This delegates |
80 | * to tox_derive_key_from_pass and tox_pass_key_encrypt. | 81 | * to tox_derive_key_from_pass and tox_pass_key_encrypt. |
81 | * | 82 | * |
82 | * tox_encrypted_save() is a good example of how to use this function. | 83 | * tox_encrypted_save() is a good example of how to use this function. |
@@ -84,7 +85,7 @@ int tox_pass_key_encrypt(uint8_t *data, uint32_t data_len, const uint8_t *key, u | |||
84 | * returns 0 on success | 85 | * returns 0 on success |
85 | * returns -1 on failure | 86 | * returns -1 on failure |
86 | */ | 87 | */ |
87 | int tox_pass_encrypt(uint8_t *data, uint32_t data_len, uint8_t *passphrase, uint32_t pplength, uint8_t *out); | 88 | int tox_pass_encrypt(const uint8_t *data, uint32_t data_len, uint8_t *passphrase, uint32_t pplength, uint8_t *out); |
88 | 89 | ||
89 | /* Save the messenger data encrypted with the given password. | 90 | /* Save the messenger data encrypted with the given password. |
90 | * data must be at least tox_encrypted_size(). | 91 | * data must be at least tox_encrypted_size(). |
@@ -97,18 +98,18 @@ int tox_encrypted_save(const Tox *tox, uint8_t *data, uint8_t *passphrase, uint3 | |||
97 | /* This is the inverse of tox_pass_key_encrypt, also using only keys produced by | 98 | /* This is the inverse of tox_pass_key_encrypt, also using only keys produced by |
98 | * tox_derive_key_from_pass. | 99 | * tox_derive_key_from_pass. |
99 | * | 100 | * |
100 | * returns the length of the output data (== data_len - TOX_PASS_ENCRYPTION_EXTRA_LENGTH) on success | 101 | * returns the length of the output data (== data_len - tox_pass_encryption_extra_length()) on success |
101 | * returns -1 on failure | 102 | * returns -1 on failure |
102 | */ | 103 | */ |
103 | int tox_pass_key_decrypt(const uint8_t* data, uint32_t length, const uint8_t* key, uint8_t* out); | 104 | int tox_pass_key_decrypt(const uint8_t* data, uint32_t length, const uint8_t* key, uint8_t* out); |
104 | 105 | ||
105 | /* Decrypts the given data with the given passphrase. The output array must be | 106 | /* Decrypts the given data with the given passphrase. The output array must be |
106 | * at least data_len - TOX_PASS_ENCRYPTION_EXTRA_LENGTH bytes long. This delegates | 107 | * at least data_len - tox_pass_encryption_extra_length() bytes long. This delegates |
107 | * to tox_pass_key_decrypt. | 108 | * to tox_pass_key_decrypt. |
108 | * | 109 | * |
109 | * tox_encrypted_load() is a good example of how to use this function. | 110 | * tox_encrypted_load() is a good example of how to use this function. |
110 | * | 111 | * |
111 | * returns the length of the output data (== data_len - TOX_PASS_ENCRYPTION_EXTRA_LENGTH) on success | 112 | * returns the length of the output data (== data_len - tox_pass_encryption_extra_length()) on success |
112 | * returns -1 on failure | 113 | * returns -1 on failure |
113 | */ | 114 | */ |
114 | int tox_pass_decrypt(const uint8_t *data, uint32_t length, uint8_t *passphrase, uint32_t pplength, uint8_t *out); | 115 | int tox_pass_decrypt(const uint8_t *data, uint32_t length, uint8_t *passphrase, uint32_t pplength, uint8_t *out); |