diff options
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r-- | toxcore/DHT.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 3c265be3..ebc40e71 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -119,7 +119,7 @@ void get_shared_key(Shared_Keys *shared_keys, uint8_t *shared_key, const uint8_t | |||
119 | Shared_Key *key = &shared_keys->keys[index]; | 119 | Shared_Key *key = &shared_keys->keys[index]; |
120 | 120 | ||
121 | if (key->stored) { | 121 | if (key->stored) { |
122 | if (public_key_cmp(public_key, key->public_key) == 0) { | 122 | if (id_equal(public_key, key->public_key)) { |
123 | memcpy(shared_key, key->shared_key, CRYPTO_SHARED_KEY_SIZE); | 123 | memcpy(shared_key, key->shared_key, CRYPTO_SHARED_KEY_SIZE); |
124 | ++key->times_requested; | 124 | ++key->times_requested; |
125 | key->time_last_requested = unix_time(); | 125 | key->time_last_requested = unix_time(); |
@@ -232,7 +232,7 @@ int handle_request(const uint8_t *self_public_key, const uint8_t *self_secret_ke | |||
232 | return -1; | 232 | return -1; |
233 | } | 233 | } |
234 | 234 | ||
235 | if (public_key_cmp(packet + 1, self_public_key) != 0) { | 235 | if (!id_equal(packet + 1, self_public_key)) { |
236 | return -1; | 236 | return -1; |
237 | } | 237 | } |
238 | 238 | ||
@@ -1144,7 +1144,7 @@ uint32_t addto_lists(DHT *dht, IP_Port ip_port, const uint8_t *public_key) | |||
1144 | } else { | 1144 | } else { |
1145 | DHT_Friend *dht_friend = &dht->friends_list[i]; | 1145 | DHT_Friend *dht_friend = &dht->friends_list[i]; |
1146 | 1146 | ||
1147 | if (public_key_cmp(public_key, dht_friend->public_key) == 0) { | 1147 | if (id_equal(public_key, dht_friend->public_key)) { |
1148 | friend_foundip = dht_friend; | 1148 | friend_foundip = dht_friend; |
1149 | } | 1149 | } |
1150 | 1150 | ||
@@ -1364,7 +1364,7 @@ static uint8_t sent_getnode_to_node(DHT *dht, const uint8_t *public_key, IP_Port | |||
1364 | Node_format test; | 1364 | Node_format test; |
1365 | memcpy(&test, data, sizeof(Node_format)); | 1365 | memcpy(&test, data, sizeof(Node_format)); |
1366 | 1366 | ||
1367 | if (!ipport_equal(&test.ip_port, &node_ip_port) || public_key_cmp(test.public_key, public_key) != 0) { | 1367 | if (!ipport_equal(&test.ip_port, &node_ip_port) || !id_equal(test.public_key, public_key)) { |
1368 | return 0; | 1368 | return 0; |
1369 | } | 1369 | } |
1370 | 1370 | ||
@@ -2267,7 +2267,7 @@ static int send_hardening_getnode_res(const DHT *dht, const Node_format *sendto, | |||
2267 | static IPPTsPng *get_closelist_IPPTsPng(DHT *dht, const uint8_t *public_key, Family sa_family) | 2267 | static IPPTsPng *get_closelist_IPPTsPng(DHT *dht, const uint8_t *public_key, Family sa_family) |
2268 | { | 2268 | { |
2269 | for (uint32_t i = 0; i < LCLIENT_LIST; ++i) { | 2269 | for (uint32_t i = 0; i < LCLIENT_LIST; ++i) { |
2270 | if (public_key_cmp(dht->close_clientlist[i].public_key, public_key) != 0) { | 2270 | if (!id_equal(dht->close_clientlist[i].public_key, public_key)) { |
2271 | continue; | 2271 | continue; |
2272 | } | 2272 | } |
2273 | 2273 | ||
@@ -2375,7 +2375,7 @@ static int handle_hardening(void *object, IP_Port source, const uint8_t *source_ | |||
2375 | return 1; | 2375 | return 1; |
2376 | } | 2376 | } |
2377 | 2377 | ||
2378 | if (public_key_cmp(temp->hardening.send_nodes_pingedid, source_pubkey) != 0) { | 2378 | if (!id_equal(temp->hardening.send_nodes_pingedid, source_pubkey)) { |
2379 | return 1; | 2379 | return 1; |
2380 | } | 2380 | } |
2381 | 2381 | ||
@@ -2560,7 +2560,8 @@ static int cryptopacket_handle(void *object, IP_Port source, const uint8_t *pack | |||
2560 | return 1; | 2560 | return 1; |
2561 | } | 2561 | } |
2562 | 2562 | ||
2563 | if (public_key_cmp(packet + 1, dht->self_public_key) == 0) { // Check if request is for us. | 2563 | // Check if request is for us. |
2564 | if (id_equal(packet + 1, dht->self_public_key)) { | ||
2564 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 2565 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
2565 | uint8_t data[MAX_CRYPTO_REQUEST_SIZE]; | 2566 | uint8_t data[MAX_CRYPTO_REQUEST_SIZE]; |
2566 | uint8_t number; | 2567 | uint8_t number; |