summaryrefslogtreecommitdiff
path: root/core/net_crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/net_crypto.c')
-rw-r--r--core/net_crypto.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/core/net_crypto.c b/core/net_crypto.c
index 62df614e..fe03b5ee 100644
--- a/core/net_crypto.c
+++ b/core/net_crypto.c
@@ -128,9 +128,9 @@ int decrypt_data(uint8_t * public_key, uint8_t * secret_key, uint8_t * nonce,
128void increment_nonce(uint8_t * nonce) 128void increment_nonce(uint8_t * nonce)
129{ 129{
130 uint32_t i; 130 uint32_t i;
131 for(i = 0; i < crypto_box_NONCEBYTES; i++) 131 for(i = 0; i < crypto_box_NONCEBYTES; ++i)
132 { 132 {
133 nonce[i]++; 133 ++nonce[i];
134 if(nonce[i] != 0) 134 if(nonce[i] != 0)
135 { 135 {
136 break; 136 break;
@@ -143,7 +143,7 @@ void increment_nonce(uint8_t * nonce)
143void random_nonce(uint8_t * nonce) 143void random_nonce(uint8_t * nonce)
144{ 144{
145 uint32_t i; 145 uint32_t i;
146 for(i = 0; i < crypto_box_NONCEBYTES; i++) 146 for(i = 0; i < crypto_box_NONCEBYTES; ++i)
147 { 147 {
148 nonce[i] = random_int() % 256; 148 nonce[i] = random_int() % 256;
149 } 149 }
@@ -228,7 +228,7 @@ int send_friendrequest(uint8_t * public_key, IP_Port ip_port, uint8_t * data, ui
228 return -1; 228 return -1;
229 } 229 }
230 uint32_t i; 230 uint32_t i;
231 for(i = 0; i < MAX_FRIEND_REQUESTS; i++) 231 for(i = 0; i < MAX_FRIEND_REQUESTS; ++i)
232 { 232 {
233 if(outbound_friendrequests[i] == -1) 233 if(outbound_friendrequests[i] == -1)
234 { 234 {
@@ -365,7 +365,7 @@ int handle_cryptohandshake(uint8_t * public_key, uint8_t * secret_nonce,
365int handle_friendrequest(uint8_t * public_key, uint8_t * data) 365int handle_friendrequest(uint8_t * public_key, uint8_t * data)
366{ 366{
367 uint32_t i; 367 uint32_t i;
368 for(i = 0; i < MAX_INCOMING; i++) 368 for(i = 0; i < MAX_INCOMING; ++i)
369 { 369 {
370 if(incoming_connections[i] != -1) 370 if(incoming_connections[i] != -1)
371 { 371 {
@@ -403,7 +403,7 @@ int handle_friendrequest(uint8_t * public_key, uint8_t * data)
403int getcryptconnection_id(uint8_t * public_key) 403int getcryptconnection_id(uint8_t * public_key)
404{ 404{
405 uint32_t i; 405 uint32_t i;
406 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; i++) 406 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; ++i)
407 { 407 {
408 if(crypto_connections[i].status > 0) 408 if(crypto_connections[i].status > 0)
409 { 409 {
@@ -432,7 +432,7 @@ int crypto_connect(uint8_t * public_key, IP_Port ip_port)
432 return -1; 432 return -1;
433 } 433 }
434 } 434 }
435 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; i++) 435 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; ++i)
436 { 436 {
437 if(crypto_connections[i].status == 0) 437 if(crypto_connections[i].status == 0)
438 { 438 {
@@ -469,7 +469,7 @@ int crypto_connect(uint8_t * public_key, IP_Port ip_port)
469int crypto_inbound(uint8_t * public_key, uint8_t * secret_nonce, uint8_t * session_key) 469int crypto_inbound(uint8_t * public_key, uint8_t * secret_nonce, uint8_t * session_key)
470{ 470{
471 uint32_t i; 471 uint32_t i;
472 for(i = 0; i < MAX_INCOMING; i++) 472 for(i = 0; i < MAX_INCOMING; ++i)
473 { 473 {
474 if(incoming_connections[i] != -1) 474 if(incoming_connections[i] != -1)
475 { 475 {
@@ -530,7 +530,7 @@ int accept_crypto_inbound(int connection_id, uint8_t * public_key, uint8_t * sec
530 { 530 {
531 return -1; 531 return -1;
532 }*/ 532 }*/
533 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; i++) 533 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; ++i)
534 { 534 {
535 if(crypto_connections[i].status == 0) 535 if(crypto_connections[i].status == 0)
536 { 536 {
@@ -603,7 +603,7 @@ void load_keys(uint8_t * keys)
603int new_incoming(int id) 603int new_incoming(int id)
604{ 604{
605 uint32_t i; 605 uint32_t i;
606 for(i = 0; i < MAX_INCOMING; i++) 606 for(i = 0; i < MAX_INCOMING; ++i)
607 { 607 {
608 if(incoming_connections[i] == -1) 608 if(incoming_connections[i] == -1)
609 { 609 {
@@ -633,7 +633,7 @@ static void handle_incomings()
633static void receive_crypto() 633static void receive_crypto()
634{ 634{
635 uint32_t i; 635 uint32_t i;
636 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; i++) 636 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; ++i)
637 { 637 {
638 if(crypto_connections[i].status == 1) 638 if(crypto_connections[i].status == 1)
639 { 639 {
@@ -717,7 +717,7 @@ void initNetCrypto()
717 memset(outbound_friendrequests, -1 ,sizeof(outbound_friendrequests)); 717 memset(outbound_friendrequests, -1 ,sizeof(outbound_friendrequests));
718 memset(incoming_connections, -1 ,sizeof(incoming_connections)); 718 memset(incoming_connections, -1 ,sizeof(incoming_connections));
719 uint32_t i; 719 uint32_t i;
720 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; i++) 720 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; ++i)
721 { 721 {
722 crypto_connections[i].number = ~0; 722 crypto_connections[i].number = ~0;
723 } 723 }
@@ -726,7 +726,7 @@ void initNetCrypto()
726static void killTimedout() 726static void killTimedout()
727{ 727{
728 uint32_t i; 728 uint32_t i;
729 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; i++) 729 for(i = 0; i < MAX_CRYPTO_CONNECTIONS; ++i)
730 { 730 {
731 if(crypto_connections[i].status != 0 && is_connected(crypto_connections[i].number) == 4) 731 if(crypto_connections[i].status != 0 && is_connected(crypto_connections[i].number) == 4)
732 { 732 {