diff options
Diffstat (limited to 'toxencryptsave/toxencryptsave.h')
-rw-r--r-- | toxencryptsave/toxencryptsave.h | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/toxencryptsave/toxencryptsave.h b/toxencryptsave/toxencryptsave.h index 9b613cac..db272592 100644 --- a/toxencryptsave/toxencryptsave.h +++ b/toxencryptsave/toxencryptsave.h | |||
@@ -35,7 +35,6 @@ extern "C" { | |||
35 | #define TOX_DEFINED | 35 | #define TOX_DEFINED |
36 | typedef struct Tox Tox; | 36 | typedef struct Tox Tox; |
37 | struct Tox_Options; | 37 | struct Tox_Options; |
38 | typedef enum TOX_ERR_NEW TOX_ERR_NEW; | ||
39 | #endif | 38 | #endif |
40 | 39 | ||
41 | // these functions provide access to these defines in toxencryptsave.c, which | 40 | // these functions provide access to these defines in toxencryptsave.c, which |
@@ -110,13 +109,66 @@ int tox_encrypted_save(const Tox *tox, uint8_t *data, uint8_t *passphrase, uint3 | |||
110 | */ | 109 | */ |
111 | int tox_pass_decrypt(const uint8_t *data, uint32_t length, uint8_t *passphrase, uint32_t pplength, uint8_t *out); | 110 | int tox_pass_decrypt(const uint8_t *data, uint32_t length, uint8_t *passphrase, uint32_t pplength, uint8_t *out); |
112 | 111 | ||
112 | typedef enum TOX_ERR_ENCRYPTED_NEW { | ||
113 | TOX_ERR_ENCRYPTED_NEW_OK, | ||
114 | TOX_ERR_ENCRYPTED_NEW_NULL, | ||
115 | /** | ||
116 | * The function was unable to allocate enough memory to store the internal | ||
117 | * structures for the Tox object. | ||
118 | */ | ||
119 | TOX_ERR_ENCRYPTED_NEW_MALLOC, | ||
120 | /** | ||
121 | * The function was unable to bind to a port. This may mean that all ports | ||
122 | * have already been bound, e.g. by other Tox instances, or it may mean | ||
123 | * a permission error. You may be able to gather more information from errno. | ||
124 | */ | ||
125 | TOX_ERR_ENCRYPTED_NEW_PORT_ALLOC, | ||
126 | /** | ||
127 | * proxy_type was invalid. | ||
128 | */ | ||
129 | TOX_ERR_ENCRYPTED_NEW_PROXY_BAD_TYPE, | ||
130 | /** | ||
131 | * proxy_type was valid but the proxy_host passed had an invalid format | ||
132 | * or was NULL. | ||
133 | */ | ||
134 | TOX_ERR_ENCRYPTED_NEW_PROXY_BAD_HOST, | ||
135 | /** | ||
136 | * proxy_type was valid, but the proxy_port was invalid. | ||
137 | */ | ||
138 | TOX_ERR_ENCRYPTED_NEW_PROXY_BAD_PORT, | ||
139 | /** | ||
140 | * The proxy host passed could not be resolved. | ||
141 | */ | ||
142 | TOX_ERR_ENCRYPTED_NEW_PROXY_NOT_FOUND, | ||
143 | /** | ||
144 | * The byte array to be loaded contained an encrypted save. | ||
145 | */ | ||
146 | TOX_ERR_ENCRYPTED_NEW_LOAD_ENCRYPTED, | ||
147 | /** | ||
148 | * The data format was invalid. This can happen when loading data that was | ||
149 | * saved by an older version of Tox, or when the data has been corrupted. | ||
150 | * When loading from badly formatted data, some data may have been loaded, | ||
151 | * and the rest is discarded. Passing an invalid length parameter also | ||
152 | * causes this error. | ||
153 | */ | ||
154 | TOX_ERR_ENCRYPTED_NEW_LOAD_BAD_FORMAT, | ||
155 | /** | ||
156 | * The encrypted byte array could not be decrypted. Either the data was | ||
157 | * corrupt or the password/key was incorrect. | ||
158 | * | ||
159 | * NOTE: This error code is only set by tox_encrypted_new() and | ||
160 | * tox_encrypted_key_new(), in the toxencryptsave module. | ||
161 | */ | ||
162 | TOX_ERR_ENCRYPTED_NEW_LOAD_DECRYPTION_FAILED | ||
163 | } TOX_ERR_ENCRYPTED_NEW; | ||
164 | |||
113 | /* Load the new messenger from encrypted data of size length. | 165 | /* Load the new messenger from encrypted data of size length. |
114 | * All other arguments are like toxcore/tox_new(). | 166 | * All other arguments are like toxcore/tox_new(). |
115 | * | 167 | * |
116 | * returns NULL on failure; see the documentation in toxcore/tox.h. | 168 | * returns NULL on failure; see the documentation in toxcore/tox.h. |
117 | */ | 169 | */ |
118 | Tox *tox_encrypted_new(const struct Tox_Options *options, const uint8_t *data, size_t length, uint8_t *passphrase, | 170 | Tox *tox_encrypted_new(const struct Tox_Options *options, const uint8_t *data, size_t length, uint8_t *passphrase, |
119 | size_t pplength, TOX_ERR_NEW *error); | 171 | size_t pplength, TOX_ERR_ENCRYPTED_NEW *error); |
120 | 172 | ||
121 | 173 | ||
122 | /******************************* BEGIN PART 1 ******************************* | 174 | /******************************* BEGIN PART 1 ******************************* |
@@ -190,7 +242,7 @@ int tox_pass_key_decrypt(const uint8_t *data, uint32_t length, const uint8_t *ke | |||
190 | * returns NULL on failure; see the documentation in toxcore/tox.h. | 242 | * returns NULL on failure; see the documentation in toxcore/tox.h. |
191 | */ | 243 | */ |
192 | Tox *tox_encrypted_key_new(const struct Tox_Options *options, const uint8_t *data, size_t length, uint8_t *key, | 244 | Tox *tox_encrypted_key_new(const struct Tox_Options *options, const uint8_t *data, size_t length, uint8_t *key, |
193 | TOX_ERR_NEW *error); | 245 | TOX_ERR_ENCRYPTED_NEW *error); |
194 | 246 | ||
195 | 247 | ||
196 | /* Determines whether or not the given data is encrypted (by checking the magic number) | 248 | /* Determines whether or not the given data is encrypted (by checking the magic number) |