diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-12 16:27:19 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-12 16:27:19 -0400 |
commit | 79aa715514e7d587695ce0182fdf97537d9d9b85 (patch) | |
tree | 213a0566099fadd3b49f9e11cbb4c70053999360 /core/net_crypto.c | |
parent | e830861a9d96f4a8e8ea203e24cfe431f7960c04 (diff) |
First part of DHT hardening done.
Added crypto to the DHT communications.
This defeats completely the first attack mentioned in
docs/DHT_hardening.
Also updated the build system to build the latest test (it links it with
libsodium)
Diffstat (limited to 'core/net_crypto.c')
-rw-r--r-- | core/net_crypto.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/core/net_crypto.c b/core/net_crypto.c index 0bae2d2e..2af5239b 100644 --- a/core/net_crypto.c +++ b/core/net_crypto.c | |||
@@ -50,17 +50,17 @@ typedef struct | |||
50 | 50 | ||
51 | #define MAX_CRYPTO_CONNECTIONS 256 | 51 | #define MAX_CRYPTO_CONNECTIONS 256 |
52 | 52 | ||
53 | Crypto_Connection crypto_connections[MAX_CRYPTO_CONNECTIONS]; | 53 | static Crypto_Connection crypto_connections[MAX_CRYPTO_CONNECTIONS]; |
54 | 54 | ||
55 | #define MAX_FRIEND_REQUESTS 32 | 55 | #define MAX_FRIEND_REQUESTS 32 |
56 | 56 | ||
57 | //keeps track of the connection numbers for friends request so we can check later if they were sent | 57 | //keeps track of the connection numbers for friends request so we can check later if they were sent |
58 | int outbound_friendrequests[MAX_FRIEND_REQUESTS]; | 58 | static int outbound_friendrequests[MAX_FRIEND_REQUESTS]; |
59 | 59 | ||
60 | #define MAX_INCOMING 64 | 60 | #define MAX_INCOMING 64 |
61 | 61 | ||
62 | //keeps track of the connection numbers for friends request so we can check later if they were sent | 62 | //keeps track of the connection numbers for friends request so we can check later if they were sent |
63 | int incoming_connections[MAX_INCOMING]; | 63 | static int incoming_connections[MAX_INCOMING]; |
64 | 64 | ||
65 | //encrypts plain of length length to encrypted of length + 16 using the | 65 | //encrypts plain of length length to encrypted of length + 16 using the |
66 | //public key(32 bytes) of the receiver and the secret key of the sender and a 24 byte nonce | 66 | //public key(32 bytes) of the receiver and the secret key of the sender and a 24 byte nonce |
@@ -587,7 +587,7 @@ int new_incoming(int id) | |||
587 | 587 | ||
588 | //TODO: optimize this | 588 | //TODO: optimize this |
589 | //handle all new incoming connections. | 589 | //handle all new incoming connections. |
590 | void handle_incomings() | 590 | static void handle_incomings() |
591 | { | 591 | { |
592 | int income; | 592 | int income; |
593 | while(1) | 593 | while(1) |
@@ -601,7 +601,7 @@ void handle_incomings() | |||
601 | } | 601 | } |
602 | 602 | ||
603 | //handle received packets for not yet established crypto connections. | 603 | //handle received packets for not yet established crypto connections. |
604 | void receive_crypto() | 604 | static void receive_crypto() |
605 | { | 605 | { |
606 | uint32_t i; | 606 | uint32_t i; |
607 | for(i = 0; i < MAX_CRYPTO_CONNECTIONS; i++) | 607 | for(i = 0; i < MAX_CRYPTO_CONNECTIONS; i++) |
@@ -687,7 +687,7 @@ void initNetCrypto() | |||
687 | memset(incoming_connections, -1 ,sizeof(incoming_connections)); | 687 | memset(incoming_connections, -1 ,sizeof(incoming_connections)); |
688 | } | 688 | } |
689 | 689 | ||
690 | void killTimedout() | 690 | static void killTimedout() |
691 | { | 691 | { |
692 | uint32_t i; | 692 | uint32_t i; |
693 | for(i = 0; i < MAX_CRYPTO_CONNECTIONS; i++) | 693 | for(i = 0; i < MAX_CRYPTO_CONNECTIONS; i++) |