summaryrefslogtreecommitdiff
path: root/toxencryptsave/toxencryptsave.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-01-28 21:30:39 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-01-30 23:35:50 +0000
commit92ffad1a72bc8c422426d52ac408bd71242dd047 (patch)
treef592f353068dd2043525dd2cc04d6124a4ed4bc4 /toxencryptsave/toxencryptsave.c
parent623e9ac331df7323660e21c8a2226523a5ee713b (diff)
Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
Diffstat (limited to 'toxencryptsave/toxencryptsave.c')
-rw-r--r--toxencryptsave/toxencryptsave.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/toxencryptsave/toxencryptsave.c b/toxencryptsave/toxencryptsave.c
index b7360b56..b83d6f1c 100644
--- a/toxencryptsave/toxencryptsave.c
+++ b/toxencryptsave/toxencryptsave.c
@@ -25,6 +25,7 @@
25#include "config.h" 25#include "config.h"
26#endif 26#endif
27 27
28#include "../toxcore/ccompat.h"
28#include "../toxcore/crypto_core.h" 29#include "../toxcore/crypto_core.h"
29#include "defines.h" 30#include "defines.h"
30#include "toxencryptsave.h" 31#include "toxencryptsave.h"
@@ -134,7 +135,7 @@ Tox_Pass_Key *tox_pass_key_derive_with_salt(const uint8_t *passphrase, size_t pp
134{ 135{
135 if (!salt || (!passphrase && pplength != 0)) { 136 if (!salt || (!passphrase && pplength != 0)) {
136 SET_ERROR_PARAMETER(error, TOX_ERR_KEY_DERIVATION_NULL); 137 SET_ERROR_PARAMETER(error, TOX_ERR_KEY_DERIVATION_NULL);
137 return NULL; 138 return nullptr;
138 } 139 }
139 140
140 uint8_t passkey[crypto_hash_sha256_BYTES]; 141 uint8_t passkey[crypto_hash_sha256_BYTES];
@@ -152,7 +153,7 @@ Tox_Pass_Key *tox_pass_key_derive_with_salt(const uint8_t *passphrase, size_t pp
152 crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE) != 0) { 153 crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE) != 0) {
153 /* out of memory most likely */ 154 /* out of memory most likely */
154 SET_ERROR_PARAMETER(error, TOX_ERR_KEY_DERIVATION_FAILED); 155 SET_ERROR_PARAMETER(error, TOX_ERR_KEY_DERIVATION_FAILED);
155 return NULL; 156 return nullptr;
156 } 157 }
157 158
158 sodium_memzero(passkey, crypto_hash_sha256_BYTES); /* wipe plaintext pw */ 159 sodium_memzero(passkey, crypto_hash_sha256_BYTES); /* wipe plaintext pw */
@@ -161,7 +162,7 @@ Tox_Pass_Key *tox_pass_key_derive_with_salt(const uint8_t *passphrase, size_t pp
161 162
162 if (!out_key) { 163 if (!out_key) {
163 SET_ERROR_PARAMETER(error, TOX_ERR_KEY_DERIVATION_FAILED); 164 SET_ERROR_PARAMETER(error, TOX_ERR_KEY_DERIVATION_FAILED);
164 return NULL; 165 return nullptr;
165 } 166 }
166 167
167 memcpy(out_key->salt, salt, crypto_pwhash_scryptsalsa208sha256_SALTBYTES); 168 memcpy(out_key->salt, salt, crypto_pwhash_scryptsalsa208sha256_SALTBYTES);
@@ -320,7 +321,7 @@ bool tox_pass_decrypt(const uint8_t *data, size_t length, const uint8_t *passphr
320 memcpy(salt, data + TOX_ENC_SAVE_MAGIC_LENGTH, crypto_pwhash_scryptsalsa208sha256_SALTBYTES); 321 memcpy(salt, data + TOX_ENC_SAVE_MAGIC_LENGTH, crypto_pwhash_scryptsalsa208sha256_SALTBYTES);
321 322
322 /* derive the key */ 323 /* derive the key */
323 Tox_Pass_Key *key = tox_pass_key_derive_with_salt(passphrase, pplength, salt, NULL); 324 Tox_Pass_Key *key = tox_pass_key_derive_with_salt(passphrase, pplength, salt, nullptr);
324 325
325 if (!key) { 326 if (!key) {
326 /* out of memory most likely */ 327 /* out of memory most likely */