summaryrefslogtreecommitdiff
path: root/toxencryptsave
diff options
context:
space:
mode:
authorGregory Mullen (GrayHatter) <greg@grayhatter.com>2016-02-13 20:50:16 -0800
committerGregory Mullen (GrayHatter) <greg@grayhatter.com>2016-02-13 20:50:16 -0800
commit58ebf7a5b6e006c656b6b704d149f391587f394d (patch)
tree16ae59b69f3cda092939078901c186f1f9a63c69 /toxencryptsave
parentea21a541ff39570d87620d15e67e797e4fce0a2b (diff)
added versioning to toxencryptsave
Diffstat (limited to 'toxencryptsave')
-rw-r--r--toxencryptsave/toxencryptsave.c24
-rw-r--r--toxencryptsave/toxencryptsave.h90
2 files changed, 114 insertions, 0 deletions
diff --git a/toxencryptsave/toxencryptsave.c b/toxencryptsave/toxencryptsave.c
index 5c40f639..800d5d11 100644
--- a/toxencryptsave/toxencryptsave.c
+++ b/toxencryptsave/toxencryptsave.c
@@ -47,6 +47,30 @@
47#error TOX_PASS_ENCRYPTION_EXTRA_LENGTH is assumed to be equal to (crypto_box_MACBYTES + crypto_box_NONCEBYTES + crypto_pwhash_scryptsalsa208sha256_SALTBYTES + TOX_ENC_SAVE_MAGIC_LENGTH) 47#error TOX_PASS_ENCRYPTION_EXTRA_LENGTH is assumed to be equal to (crypto_box_MACBYTES + crypto_box_NONCEBYTES + crypto_pwhash_scryptsalsa208sha256_SALTBYTES + TOX_ENC_SAVE_MAGIC_LENGTH)
48#endif 48#endif
49 49
50uint32_t toxes_version_major(void)
51{
52 return TOXES_VERSION_MAJOR;
53}
54
55uint32_t toxes_version_minor(void)
56{
57 return TOXES_VERSION_MINOR;
58}
59
60uint32_t toxes_version_patch(void)
61{
62 return TOXES_VERSION_PATCH;
63}
64
65bool toxes_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch)
66{
67 return (TOXES_VERSION_MAJOR == major && /* Force the major version */
68 (TOXES_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */
69 (TOXES_VERSION_MINOR == minor && TOXES_VERSION_PATCH >= patch) /* the patch must be the same or newer */
70 )
71 )
72}
73
50/* Clients should consider alerting their users that, unlike plain data, if even one bit 74/* Clients should consider alerting their users that, unlike plain data, if even one bit
51 * becomes corrupted, the data will be entirely unrecoverable. 75 * becomes corrupted, the data will be entirely unrecoverable.
52 * Ditto if they forget their password, there is no way to recover the data. 76 * Ditto if they forget their password, there is no way to recover the data.
diff --git a/toxencryptsave/toxencryptsave.h b/toxencryptsave/toxencryptsave.h
index 9e28b48e..03fe7533 100644
--- a/toxencryptsave/toxencryptsave.h
+++ b/toxencryptsave/toxencryptsave.h
@@ -42,6 +42,96 @@ struct Tox_Options;
42#define TOX_PASS_KEY_LENGTH 32 42#define TOX_PASS_KEY_LENGTH 32
43#define TOX_PASS_ENCRYPTION_EXTRA_LENGTH 80 43#define TOX_PASS_ENCRYPTION_EXTRA_LENGTH 80
44 44
45/**
46 * ToxAV.
47 */
48/**
49 * The ToxAV instance type. Each ToxAV instance can be bound to only one Tox
50 * instance, and Tox instance can have only one ToxAV instance. One must make
51 * sure to close ToxAV instance prior closing Tox instance otherwise undefined
52 * behaviour occurs. Upon closing of ToxAV instance, all active calls will be
53 * forcibly terminated without notifying peers.
54 *
55 */
56#ifndef TOXAV_DEFINED
57#define TOXAV_DEFINED
58typedef struct ToxAV ToxAV;
59#endif /* TOXAV_DEFINED */
60
61
62/*******************************************************************************
63 *
64 * :: API version
65 *
66 ******************************************************************************/
67/**
68 * The major version number. Incremented when the API or ABI changes in an
69 * incompatible way.
70 */
71#define TOXES_VERSION_MAJOR 0u
72
73/**
74 * The minor version number. Incremented when functionality is added without
75 * breaking the API or ABI. Set to 0 when the major version number is
76 * incremented.
77 */
78#define TOXES_VERSION_MINOR 0u
79
80/**
81 * The patch or revision number. Incremented when bugfixes are applied without
82 * changing any functionality or API or ABI.
83 */
84#define TOXES_VERSION_PATCH 0u
85
86/**
87 * A macro to check at preprocessing time whether the client code is compatible
88 * with the installed version of ToxAV.
89 */
90#define TOXES_VERSION_IS_API_COMPATIBLE(MAJOR, MINOR, PATCH) \
91 (TOXES_VERSION_MAJOR == MAJOR && \
92 (TOXES_VERSION_MINOR > MINOR || \
93 (TOXES_VERSION_MINOR == MINOR && \
94 TOXES_VERSION_PATCH >= PATCH)))
95
96/**
97 * A macro to make compilation fail if the client code is not compatible with
98 * the installed version of ToxAV.
99 */
100#define TOXES_VERSION_REQUIRE(MAJOR, MINOR, PATCH) \
101 typedef char toxes_required_version[TOXES_IS_COMPATIBLE(MAJOR, MINOR, PATCH) ? 1 : -1]
102
103/**
104 * A convenience macro to call toxES_version_is_compatible with the currently
105 * compiling API version.
106 */
107#define TOXES_VERSION_IS_ABI_COMPATIBLE() \
108 toxes_version_is_compatible(TOXES_VERSION_MAJOR, TOXES_VERSION_MINOR, TOXES_VERSION_PATCH)
109
110/**
111 * Return the major version number of the library. Can be used to display the
112 * ToxAV library version or to check whether the client is compatible with the
113 * dynamically linked version of ToxAV.
114 */
115uint32_t toxes_version_major(void);
116
117/**
118 * Return the minor version number of the library.
119 */
120uint32_t toxes_version_minor(void);
121
122/**
123 * Return the patch number of the library.
124 */
125uint32_t toxes_version_patch(void);
126
127/**
128 * Return whether the compiled library version is compatible with the passed
129 * version numbers.
130 */
131bool toxes_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch);
132
133
134
45/* This module is conceptually organized into two parts. The first part are the functions 135/* This module is conceptually organized into two parts. The first part are the functions
46 * with "key" in the name. To use these functions, first derive an encryption key 136 * with "key" in the name. To use these functions, first derive an encryption key
47 * from a password with tox_derive_key_from_pass, and use the returned key to 137 * from a password with tox_derive_key_from_pass, and use the returned key to