diff options
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r-- | toxcore/net_crypto.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 762f5ebb..6d4f6a9b 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -2359,6 +2359,8 @@ void new_keys(Net_Crypto *c) | |||
2359 | 2359 | ||
2360 | /* Save the public and private keys to the keys array. | 2360 | /* Save the public and private keys to the keys array. |
2361 | * Length must be crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES. | 2361 | * Length must be crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES. |
2362 | * | ||
2363 | * TODO: Save only secret key. | ||
2362 | */ | 2364 | */ |
2363 | void save_keys(const Net_Crypto *c, uint8_t *keys) | 2365 | void save_keys(const Net_Crypto *c, uint8_t *keys) |
2364 | { | 2366 | { |
@@ -2366,13 +2368,13 @@ void save_keys(const Net_Crypto *c, uint8_t *keys) | |||
2366 | memcpy(keys + crypto_box_PUBLICKEYBYTES, c->self_secret_key, crypto_box_SECRETKEYBYTES); | 2368 | memcpy(keys + crypto_box_PUBLICKEYBYTES, c->self_secret_key, crypto_box_SECRETKEYBYTES); |
2367 | } | 2369 | } |
2368 | 2370 | ||
2369 | /* Load the public and private keys from the keys array. | 2371 | /* Load the secret key. |
2370 | * Length must be crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES. | 2372 | * Length must be crypto_box_SECRETKEYBYTES. |
2371 | */ | 2373 | */ |
2372 | void load_keys(Net_Crypto *c, const uint8_t *keys) | 2374 | void load_secret_key(Net_Crypto *c, const uint8_t *sk) |
2373 | { | 2375 | { |
2374 | memcpy(c->self_public_key, keys, crypto_box_PUBLICKEYBYTES); | 2376 | memcpy(c->self_secret_key, sk, crypto_box_SECRETKEYBYTES); |
2375 | memcpy(c->self_secret_key, keys + crypto_box_PUBLICKEYBYTES, crypto_box_SECRETKEYBYTES); | 2377 | crypto_scalarmult_curve25519_base(c->self_public_key, c->self_secret_key); |
2376 | } | 2378 | } |
2377 | 2379 | ||
2378 | /* Run this to (re)initialize net_crypto. | 2380 | /* Run this to (re)initialize net_crypto. |