summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-09-13 10:42:14 -0400
committerirungentoo <irungentoo@gmail.com>2013-09-13 10:42:14 -0400
commit339dcd60707ea7b46f5c450569d32f852a1c0be7 (patch)
tree37ab2079cd253a5aa9c7dbf79442325d81efc5a1 /toxcore/DHT.c
parentf8b979a92a8c316c49bed28e158a468a2f74346c (diff)
Nonce generation changes.
Nonces don't need to be random, only different. also random_int now gives same quality random numbers for both NaCl and libsodium.
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index e2d91256..a11f1aad 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -498,7 +498,7 @@ static int getnodes(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *cli
498 uint8_t plain[sizeof(ping_id) + CLIENT_ID_SIZE]; 498 uint8_t plain[sizeof(ping_id) + CLIENT_ID_SIZE];
499 uint8_t encrypt[sizeof(ping_id) + CLIENT_ID_SIZE + ENCRYPTION_PADDING]; 499 uint8_t encrypt[sizeof(ping_id) + CLIENT_ID_SIZE + ENCRYPTION_PADDING];
500 uint8_t nonce[crypto_box_NONCEBYTES]; 500 uint8_t nonce[crypto_box_NONCEBYTES];
501 random_nonce(nonce); 501 new_nonce(nonce);
502 502
503 memcpy(plain, &ping_id, sizeof(ping_id)); 503 memcpy(plain, &ping_id, sizeof(ping_id));
504 memcpy(plain + sizeof(ping_id), client_id, CLIENT_ID_SIZE); 504 memcpy(plain + sizeof(ping_id), client_id, CLIENT_ID_SIZE);
@@ -540,7 +540,7 @@ static int sendnodes(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *cl
540 uint8_t plain[sizeof(ping_id) + sizeof(Node_format) * MAX_SENT_NODES]; 540 uint8_t plain[sizeof(ping_id) + sizeof(Node_format) * MAX_SENT_NODES];
541 uint8_t encrypt[sizeof(ping_id) + sizeof(Node_format) * MAX_SENT_NODES + ENCRYPTION_PADDING]; 541 uint8_t encrypt[sizeof(ping_id) + sizeof(Node_format) * MAX_SENT_NODES + ENCRYPTION_PADDING];
542 uint8_t nonce[crypto_box_NONCEBYTES]; 542 uint8_t nonce[crypto_box_NONCEBYTES];
543 random_nonce(nonce); 543 new_nonce(nonce);
544 544
545 memcpy(plain, &ping_id, sizeof(ping_id)); 545 memcpy(plain, &ping_id, sizeof(ping_id));
546 memcpy(plain + sizeof(ping_id), nodes_list, num_nodes * sizeof(Node_format)); 546 memcpy(plain + sizeof(ping_id), nodes_list, num_nodes * sizeof(Node_format));