summaryrefslogtreecommitdiff
path: root/core/Messenger.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-07-12 16:27:19 -0400
committerirungentoo <irungentoo@gmail.com>2013-07-12 16:27:19 -0400
commit79aa715514e7d587695ce0182fdf97537d9d9b85 (patch)
tree213a0566099fadd3b49f9e11cbb4c70053999360 /core/Messenger.c
parente830861a9d96f4a8e8ea203e24cfe431f7960c04 (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/Messenger.c')
-rw-r--r--core/Messenger.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/core/Messenger.c b/core/Messenger.c
index 57bc50e2..8236c117 100644
--- a/core/Messenger.c
+++ b/core/Messenger.c
@@ -42,10 +42,10 @@ typedef struct
42 42
43#define MAX_NUM_FRIENDS 256 43#define MAX_NUM_FRIENDS 256
44 44
45Friend friendlist[MAX_NUM_FRIENDS]; 45static Friend friendlist[MAX_NUM_FRIENDS];
46 46
47 47
48uint32_t numfriends; 48static uint32_t numfriends;
49 49
50 50
51//return the friend id associated to that public key. 51//return the friend id associated to that public key.
@@ -189,7 +189,7 @@ int m_sendmessage(int friendnumber, uint8_t * message, uint32_t length)
189} 189}
190 190
191 191
192void (*friend_request)(uint8_t *, uint8_t *, uint16_t); 192static void (*friend_request)(uint8_t *, uint8_t *, uint16_t);
193 193
194//set the function that will be executed when a friend request is received. 194//set the function that will be executed when a friend request is received.
195void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t)) 195void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t))
@@ -198,7 +198,7 @@ void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t))
198} 198}
199 199
200 200
201void (*friend_message)(int, uint8_t *, uint16_t); 201static void (*friend_message)(int, uint8_t *, uint16_t);
202 202
203//set the function that will be executed when a message from a friend is received. 203//set the function that will be executed when a message from a friend is received.
204void m_callback_friendmessage(void (*function)(int, uint8_t *, uint16_t)) 204void m_callback_friendmessage(void (*function)(int, uint8_t *, uint16_t))
@@ -216,11 +216,10 @@ void initMessenger()
216 IP ip; 216 IP ip;
217 ip.i = 0; 217 ip.i = 0;
218 init_networking(ip, PORT); 218 init_networking(ip, PORT);
219 memcpy(self_client_id, self_public_key, crypto_box_PUBLICKEYBYTES);
220 219
221} 220}
222 221
223void doFriends() 222static void doFriends()
224{//TODO: add incoming connections and some other stuff. 223{//TODO: add incoming connections and some other stuff.
225 uint32_t i; 224 uint32_t i;
226 int len; 225 int len;
@@ -280,7 +279,7 @@ void doFriends()
280 } 279 }
281} 280}
282 281
283void doFriendRequest() 282static void doFriendRequest()
284{ 283{
285 uint8_t public_key[crypto_box_PUBLICKEYBYTES]; 284 uint8_t public_key[crypto_box_PUBLICKEYBYTES];
286 uint8_t temp[MAX_DATA_SIZE]; 285 uint8_t temp[MAX_DATA_SIZE];
@@ -296,7 +295,7 @@ void doFriendRequest()
296 295
297 296
298 297
299void doInbound() 298static void doInbound()
300{ 299{
301 uint8_t secret_nonce[crypto_box_NONCEBYTES]; 300 uint8_t secret_nonce[crypto_box_NONCEBYTES];
302 uint8_t public_key[crypto_box_PUBLICKEYBYTES]; 301 uint8_t public_key[crypto_box_PUBLICKEYBYTES];