diff options
-rw-r--r-- | toxav/toxav.c | 20 | ||||
-rw-r--r-- | toxcore/tox.c | 13 | ||||
-rw-r--r-- | toxencryptsave/toxencryptsave.c | 24 | ||||
-rw-r--r-- | toxencryptsave/toxencryptsave.h | 81 |
4 files changed, 125 insertions, 13 deletions
diff --git a/toxav/toxav.c b/toxav/toxav.c index 448ce3f8..814c4f26 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -106,24 +106,28 @@ void call_kill_transmission(ToxAVCall *call); | |||
106 | 106 | ||
107 | uint32_t toxav_version_major(void) | 107 | uint32_t toxav_version_major(void) |
108 | { | 108 | { |
109 | return 0; | 109 | return TOXAV_VERSION_MAJOR; |
110 | } | 110 | } |
111 | |||
111 | uint32_t toxav_version_minor(void) | 112 | uint32_t toxav_version_minor(void) |
112 | { | 113 | { |
113 | return 0; | 114 | return TOXAV_VERSION_MINOR; |
114 | } | 115 | } |
116 | |||
115 | uint32_t toxav_version_patch(void) | 117 | uint32_t toxav_version_patch(void) |
116 | { | 118 | { |
117 | return 0; | 119 | return TOXAV_VERSION_PATCH; |
118 | } | 120 | } |
121 | |||
119 | bool toxav_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch) | 122 | bool toxav_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch) |
120 | { | 123 | { |
121 | (void)major; | 124 | return (TOXAV_VERSION_MAJOR == major && /* Force the major version */ |
122 | (void)minor; | 125 | (TOXAV_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */ |
123 | (void)patch; | 126 | (TOXAV_VERSION_MINOR == minor && TOXAV_VERSION_PATCH >= patch) /* the patch must be the same or newer */ |
124 | 127 | ) | |
125 | return 1; | 128 | ); |
126 | } | 129 | } |
130 | |||
127 | ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error) | 131 | ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error) |
128 | { | 132 | { |
129 | TOXAV_ERR_NEW rc = TOXAV_ERR_NEW_OK; | 133 | TOXAV_ERR_NEW rc = TOXAV_ERR_NEW_OK; |
diff --git a/toxcore/tox.c b/toxcore/tox.c index c28c5178..23d0d3e4 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -72,23 +72,26 @@ typedef struct Messenger Tox; | |||
72 | 72 | ||
73 | uint32_t tox_version_major(void) | 73 | uint32_t tox_version_major(void) |
74 | { | 74 | { |
75 | return 0; | 75 | return TOX_VERSION_MAJOR; |
76 | } | 76 | } |
77 | 77 | ||
78 | uint32_t tox_version_minor(void) | 78 | uint32_t tox_version_minor(void) |
79 | { | 79 | { |
80 | return 0; | 80 | return TOX_VERSION_MINOR; |
81 | } | 81 | } |
82 | 82 | ||
83 | uint32_t tox_version_patch(void) | 83 | uint32_t tox_version_patch(void) |
84 | { | 84 | { |
85 | return 0; | 85 | return TOX_VERSION_PATCH; |
86 | } | 86 | } |
87 | 87 | ||
88 | bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch) | 88 | bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch) |
89 | { | 89 | { |
90 | //TODO | 90 | return (TOX_VERSION_MAJOR == major && /* Force the major version */ |
91 | return 1; | 91 | (TOX_VERSION_MINOR > minor || /* Current minor version must be newer than requested -- or -- */ |
92 | (TOX_VERSION_MINOR == minor && TOX_VERSION_PATCH >= patch) /* the patch must be the same or newer */ | ||
93 | ) | ||
94 | ); | ||
92 | } | 95 | } |
93 | 96 | ||
94 | 97 | ||
diff --git a/toxencryptsave/toxencryptsave.c b/toxencryptsave/toxencryptsave.c index 5c40f639..bbe0422f 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 | ||
50 | uint32_t toxes_version_major(void) | ||
51 | { | ||
52 | return TOXES_VERSION_MAJOR; | ||
53 | } | ||
54 | |||
55 | uint32_t toxes_version_minor(void) | ||
56 | { | ||
57 | return TOXES_VERSION_MINOR; | ||
58 | } | ||
59 | |||
60 | uint32_t toxes_version_patch(void) | ||
61 | { | ||
62 | return TOXES_VERSION_PATCH; | ||
63 | } | ||
64 | |||
65 | bool 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..cf191810 100644 --- a/toxencryptsave/toxencryptsave.h +++ b/toxencryptsave/toxencryptsave.h | |||
@@ -42,6 +42,87 @@ 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 | * ToxEncryptSave. | ||
47 | */ | ||
48 | #ifndef TOXES_DEFINED | ||
49 | #define TOXES_DEFINED | ||
50 | #endif /* TOXES_DEFINED */ | ||
51 | |||
52 | |||
53 | /******************************************************************************* | ||
54 | * | ||
55 | * :: API version | ||
56 | * | ||
57 | ******************************************************************************/ | ||
58 | /** | ||
59 | * The major version number. Incremented when the API or ABI changes in an | ||
60 | * incompatible way. | ||
61 | */ | ||
62 | #define TOXES_VERSION_MAJOR 0u | ||
63 | |||
64 | /** | ||
65 | * The minor version number. Incremented when functionality is added without | ||
66 | * breaking the API or ABI. Set to 0 when the major version number is | ||
67 | * incremented. | ||
68 | */ | ||
69 | #define TOXES_VERSION_MINOR 0u | ||
70 | |||
71 | /** | ||
72 | * The patch or revision number. Incremented when bugfixes are applied without | ||
73 | * changing any functionality or API or ABI. | ||
74 | */ | ||
75 | #define TOXES_VERSION_PATCH 0u | ||
76 | |||
77 | /** | ||
78 | * A macro to check at preprocessing time whether the client code is compatible | ||
79 | * with the installed version of ToxAV. | ||
80 | */ | ||
81 | #define TOXES_VERSION_IS_API_COMPATIBLE(MAJOR, MINOR, PATCH) \ | ||
82 | (TOXES_VERSION_MAJOR == MAJOR && \ | ||
83 | (TOXES_VERSION_MINOR > MINOR || \ | ||
84 | (TOXES_VERSION_MINOR == MINOR && \ | ||
85 | TOXES_VERSION_PATCH >= PATCH))) | ||
86 | |||
87 | /** | ||
88 | * A macro to make compilation fail if the client code is not compatible with | ||
89 | * the installed version of ToxAV. | ||
90 | */ | ||
91 | #define TOXES_VERSION_REQUIRE(MAJOR, MINOR, PATCH) \ | ||
92 | typedef char toxes_required_version[TOXES_IS_COMPATIBLE(MAJOR, MINOR, PATCH) ? 1 : -1] | ||
93 | |||
94 | /** | ||
95 | * A convenience macro to call toxES_version_is_compatible with the currently | ||
96 | * compiling API version. | ||
97 | */ | ||
98 | #define TOXES_VERSION_IS_ABI_COMPATIBLE() \ | ||
99 | toxes_version_is_compatible(TOXES_VERSION_MAJOR, TOXES_VERSION_MINOR, TOXES_VERSION_PATCH) | ||
100 | |||
101 | /** | ||
102 | * Return the major version number of the library. Can be used to display the | ||
103 | * ToxAV library version or to check whether the client is compatible with the | ||
104 | * dynamically linked version of ToxAV. | ||
105 | */ | ||
106 | uint32_t toxes_version_major(void); | ||
107 | |||
108 | /** | ||
109 | * Return the minor version number of the library. | ||
110 | */ | ||
111 | uint32_t toxes_version_minor(void); | ||
112 | |||
113 | /** | ||
114 | * Return the patch number of the library. | ||
115 | */ | ||
116 | uint32_t toxes_version_patch(void); | ||
117 | |||
118 | /** | ||
119 | * Return whether the compiled library version is compatible with the passed | ||
120 | * version numbers. | ||
121 | */ | ||
122 | bool toxes_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch); | ||
123 | |||
124 | |||
125 | |||
45 | /* This module is conceptually organized into two parts. The first part are the functions | 126 | /* 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 | 127 | * 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 | 128 | * from a password with tox_derive_key_from_pass, and use the returned key to |