summaryrefslogtreecommitdiff
path: root/toxencryptsave/toxencryptsave.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-12-16 03:00:55 +0000
committeriphydf <iphydf@users.noreply.github.com>2017-12-29 23:24:54 +0000
commitd26f0eb3bcdd622cc8adae98974a27d7487fc6cb (patch)
tree5643926efde516051ee9fe9efa9e6f9b04ea0548 /toxencryptsave/toxencryptsave.h
parent2c8fb05f6e1631403053ef8648d5860e0ec15cc3 (diff)
Change toxencryptsave API to never overwrite pass keys.
Diffstat (limited to 'toxencryptsave/toxencryptsave.h')
-rw-r--r--toxencryptsave/toxencryptsave.h24
1 files changed, 7 insertions, 17 deletions
diff --git a/toxencryptsave/toxencryptsave.h b/toxencryptsave/toxencryptsave.h
index ef1ab152..c5a1dff9 100644
--- a/toxencryptsave/toxencryptsave.h
+++ b/toxencryptsave/toxencryptsave.h
@@ -99,8 +99,7 @@ typedef enum TOX_ERR_KEY_DERIVATION {
99 99
100 /** 100 /**
101 * The crypto lib was unable to derive a key from the given passphrase, 101 * The crypto lib was unable to derive a key from the given passphrase,
102 * which is usually a lack of memory issue. The functions accepting keys 102 * which is usually a lack of memory issue.
103 * do not produce this error.
104 */ 103 */
105 TOX_ERR_KEY_DERIVATION_FAILED, 104 TOX_ERR_KEY_DERIVATION_FAILED,
106 105
@@ -241,8 +240,8 @@ bool tox_pass_decrypt(const uint8_t *ciphertext, size_t ciphertext_len, const ui
241 * for encryption and decryption. It is derived from a salt and the user- 240 * for encryption and decryption. It is derived from a salt and the user-
242 * provided password. 241 * provided password.
243 * 242 *
244 * The Tox_Pass_Key structure is hidden in the implementation. It can be allocated 243 * The Tox_Pass_Key structure is hidden in the implementation. It can be created
245 * using tox_pass_key_new and must be deallocated using tox_pass_key_free. 244 * using tox_pass_key_derive or tox_pass_key_derive_with_salt and must be deallocated using tox_pass_key_free.
246 */ 245 */
247#ifndef TOX_PASS_KEY_DEFINED 246#ifndef TOX_PASS_KEY_DEFINED
248#define TOX_PASS_KEY_DEFINED 247#define TOX_PASS_KEY_DEFINED
@@ -250,15 +249,6 @@ typedef struct Tox_Pass_Key Tox_Pass_Key;
250#endif /* TOX_PASS_KEY_DEFINED */ 249#endif /* TOX_PASS_KEY_DEFINED */
251 250
252/** 251/**
253 * Create a new Tox_Pass_Key. The initial value of it is indeterminate. To
254 * initialise it, use one of the derive_* functions below.
255 *
256 * In case of failure, this function returns NULL. The only failure mode at
257 * this time is memory allocation failure, so this function has no error code.
258 */
259struct Tox_Pass_Key *tox_pass_key_new(void);
260
261/**
262 * Deallocate a Tox_Pass_Key. This function behaves like free(), so NULL is an 252 * Deallocate a Tox_Pass_Key. This function behaves like free(), so NULL is an
263 * acceptable argument value. 253 * acceptable argument value.
264 */ 254 */
@@ -279,8 +269,8 @@ void tox_pass_key_free(struct Tox_Pass_Key *_key);
279 * 269 *
280 * @return true on success. 270 * @return true on success.
281 */ 271 */
282bool tox_pass_key_derive(struct Tox_Pass_Key *_key, const uint8_t *passphrase, size_t passphrase_len, 272struct Tox_Pass_Key *tox_pass_key_derive(const uint8_t *passphrase, size_t passphrase_len,
283 TOX_ERR_KEY_DERIVATION *error); 273 TOX_ERR_KEY_DERIVATION *error);
284 274
285/** 275/**
286 * Same as above, except use the given salt for deterministic key derivation. 276 * Same as above, except use the given salt for deterministic key derivation.
@@ -291,8 +281,8 @@ bool tox_pass_key_derive(struct Tox_Pass_Key *_key, const uint8_t *passphrase, s
291 * 281 *
292 * @return true on success. 282 * @return true on success.
293 */ 283 */
294bool tox_pass_key_derive_with_salt(struct Tox_Pass_Key *_key, const uint8_t *passphrase, size_t passphrase_len, 284struct Tox_Pass_Key *tox_pass_key_derive_with_salt(const uint8_t *passphrase, size_t passphrase_len,
295 const uint8_t *salt, TOX_ERR_KEY_DERIVATION *error); 285 const uint8_t *salt, TOX_ERR_KEY_DERIVATION *error);
296 286
297/** 287/**
298 * Encrypt a plain text with a key produced by tox_pass_key_derive or tox_pass_key_derive_with_salt. 288 * Encrypt a plain text with a key produced by tox_pass_key_derive or tox_pass_key_derive_with_salt.