summaryrefslogtreecommitdiff
path: root/toxencryptsave/toxencryptsave.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxencryptsave/toxencryptsave.h')
-rw-r--r--toxencryptsave/toxencryptsave.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/toxencryptsave/toxencryptsave.h b/toxencryptsave/toxencryptsave.h
new file mode 100644
index 00000000..64617b27
--- /dev/null
+++ b/toxencryptsave/toxencryptsave.h
@@ -0,0 +1,68 @@
1/* toxencryptsave.h
2 *
3 * The Tox encrypted save functions.
4 *
5 * Copyright (C) 2013 Tox project All Rights Reserved.
6 *
7 * This file is part of Tox.
8 *
9 * Tox is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * Tox is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23
24#ifndef TOXENCRYPTSAVE_H
25#define TOXENCRYPTSAVE_H
26
27#include "../toxcore/tox.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/* This "module" provides functions analogous to tox_load and tox_save in toxcore
34 * Clients should consider alerting their users that, unlike plain data, if even one bit
35 * becomes corrupted, the data will be entirely unrecoverable.
36 * Ditto if they forget their password, there is no way to recover the data.
37 */
38
39/* return size of the messenger data (for encrypted saving). */
40uint32_t tox_encrypted_size(const Tox *tox);
41
42/* Save the messenger data encrypted with the given password.
43 * data must be at least tox_encrypted_size().
44 *
45 * returns 0 on success
46 * returns -1 on failure
47 */
48int tox_encrypted_save(const Tox *tox, uint8_t *data, uint8_t *passphrase, uint32_t pplength);
49
50/* Load the messenger from encrypted data of size length.
51 *
52 * returns 0 on success
53 * returns -1 on failure
54 */
55int tox_encrypted_load(Tox *tox, const uint8_t *data, uint32_t length, uint8_t *passphrase, uint32_t pplength);
56
57/* Determines whether or not the given data is encrypted (by checking the magic number)
58 *
59 * returns 1 if it is encrypted
60 * returns 0 otherwise
61 */
62int tox_is_data_encrypted(const uint8_t *data);
63
64#ifdef __cplusplus
65}
66#endif
67
68#endif