diff options
Diffstat (limited to 'toxencryptsave/toxencryptsave.c')
-rw-r--r-- | toxencryptsave/toxencryptsave.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/toxencryptsave/toxencryptsave.c b/toxencryptsave/toxencryptsave.c index e2f28a58..e6150ce2 100644 --- a/toxencryptsave/toxencryptsave.c +++ b/toxencryptsave/toxencryptsave.c | |||
@@ -82,7 +82,7 @@ bool tox_get_salt(const uint8_t *data, uint8_t *salt) | |||
82 | * | 82 | * |
83 | * returns true on success | 83 | * returns true on success |
84 | */ | 84 | */ |
85 | bool tox_derive_key_from_pass(uint8_t *passphrase, size_t pplength, TOX_PASS_KEY *out_key, | 85 | bool tox_derive_key_from_pass(const uint8_t *passphrase, size_t pplength, TOX_PASS_KEY *out_key, |
86 | TOX_ERR_KEY_DERIVATION *error) | 86 | TOX_ERR_KEY_DERIVATION *error) |
87 | { | 87 | { |
88 | uint8_t salt[crypto_pwhash_scryptsalsa208sha256_SALTBYTES]; | 88 | uint8_t salt[crypto_pwhash_scryptsalsa208sha256_SALTBYTES]; |
@@ -93,10 +93,10 @@ bool tox_derive_key_from_pass(uint8_t *passphrase, size_t pplength, TOX_PASS_KEY | |||
93 | /* Same as above, except with use the given salt for deterministic key derivation. | 93 | /* Same as above, except with use the given salt for deterministic key derivation. |
94 | * The salt must be TOX_PASS_SALT_LENGTH bytes in length. | 94 | * The salt must be TOX_PASS_SALT_LENGTH bytes in length. |
95 | */ | 95 | */ |
96 | bool tox_derive_key_with_salt(uint8_t *passphrase, size_t pplength, uint8_t *salt, TOX_PASS_KEY *out_key, | 96 | bool tox_derive_key_with_salt(const uint8_t *passphrase, size_t pplength, const uint8_t *salt, TOX_PASS_KEY *out_key, |
97 | TOX_ERR_KEY_DERIVATION *error) | 97 | TOX_ERR_KEY_DERIVATION *error) |
98 | { | 98 | { |
99 | if (pplength == 0 || !passphrase || !salt || !out_key) { | 99 | if (!salt || !out_key || (!passphrase && pplength != 0)) { |
100 | SET_ERROR_PARAMETER(error, TOX_ERR_KEY_DERIVATION_NULL); | 100 | SET_ERROR_PARAMETER(error, TOX_ERR_KEY_DERIVATION_NULL); |
101 | return 0; | 101 | return 0; |
102 | } | 102 | } |
@@ -180,7 +180,7 @@ bool tox_pass_key_encrypt(const uint8_t *data, size_t data_len, const TOX_PASS_K | |||
180 | * | 180 | * |
181 | * returns true on success | 181 | * returns true on success |
182 | */ | 182 | */ |
183 | bool tox_pass_encrypt(const uint8_t *data, size_t data_len, uint8_t *passphrase, size_t pplength, uint8_t *out, | 183 | bool tox_pass_encrypt(const uint8_t *data, size_t data_len, const uint8_t *passphrase, size_t pplength, uint8_t *out, |
184 | TOX_ERR_ENCRYPTION *error) | 184 | TOX_ERR_ENCRYPTION *error) |
185 | { | 185 | { |
186 | TOX_PASS_KEY key; | 186 | TOX_PASS_KEY key; |
@@ -252,10 +252,10 @@ bool tox_pass_key_decrypt(const uint8_t *data, size_t length, const TOX_PASS_KEY | |||
252 | * | 252 | * |
253 | * returns true on success | 253 | * returns true on success |
254 | */ | 254 | */ |
255 | bool tox_pass_decrypt(const uint8_t *data, size_t length, uint8_t *passphrase, size_t pplength, uint8_t *out, | 255 | bool tox_pass_decrypt(const uint8_t *data, size_t length, const uint8_t *passphrase, size_t pplength, uint8_t *out, |
256 | TOX_ERR_DECRYPTION *error) | 256 | TOX_ERR_DECRYPTION *error) |
257 | { | 257 | { |
258 | if (length <= TOX_PASS_ENCRYPTION_EXTRA_LENGTH || pplength == 0) { | 258 | if (length <= TOX_PASS_ENCRYPTION_EXTRA_LENGTH) { |
259 | SET_ERROR_PARAMETER(error, TOX_ERR_DECRYPTION_INVALID_LENGTH); | 259 | SET_ERROR_PARAMETER(error, TOX_ERR_DECRYPTION_INVALID_LENGTH); |
260 | return 0; | 260 | return 0; |
261 | } | 261 | } |