diff options
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r-- | toxcore/net_crypto.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index a9aa77f9..3c16f0ac 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -247,7 +247,7 @@ int write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uin | |||
247 | int create_request(uint8_t *send_public_key, uint8_t *send_secret_key, uint8_t *packet, uint8_t *recv_public_key, | 247 | int create_request(uint8_t *send_public_key, uint8_t *send_secret_key, uint8_t *packet, uint8_t *recv_public_key, |
248 | uint8_t *data, uint32_t length, uint8_t request_id) | 248 | uint8_t *data, uint32_t length, uint8_t request_id) |
249 | { | 249 | { |
250 | if (MAX_DATA_SIZE < length + 1 + crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES + 1 + ENCRYPTION_PADDING) | 250 | if (MAX_DATA_SIZE < length + 1 + crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES + 1 + crypto_box_MACBYTES) |
251 | return -1; | 251 | return -1; |
252 | 252 | ||
253 | uint8_t nonce[crypto_box_NONCEBYTES]; | 253 | uint8_t nonce[crypto_box_NONCEBYTES]; |
@@ -278,7 +278,7 @@ int create_request(uint8_t *send_public_key, uint8_t *send_secret_key, uint8_t * | |||
278 | int handle_request(uint8_t *self_public_key, uint8_t *self_secret_key, uint8_t *public_key, uint8_t *data, | 278 | int handle_request(uint8_t *self_public_key, uint8_t *self_secret_key, uint8_t *public_key, uint8_t *data, |
279 | uint8_t *request_id, uint8_t *packet, uint16_t length) | 279 | uint8_t *request_id, uint8_t *packet, uint16_t length) |
280 | { | 280 | { |
281 | if (length > crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES + 1 + ENCRYPTION_PADDING && | 281 | if (length > crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES + 1 + crypto_box_MACBYTES && |
282 | length <= MAX_DATA_SIZE) { | 282 | length <= MAX_DATA_SIZE) { |
283 | if (memcmp(packet + 1, self_public_key, crypto_box_PUBLICKEYBYTES) == 0) { | 283 | if (memcmp(packet + 1, self_public_key, crypto_box_PUBLICKEYBYTES) == 0) { |
284 | memcpy(public_key, packet + 1 + crypto_box_PUBLICKEYBYTES, crypto_box_PUBLICKEYBYTES); | 284 | memcpy(public_key, packet + 1 + crypto_box_PUBLICKEYBYTES, crypto_box_PUBLICKEYBYTES); |
@@ -313,8 +313,8 @@ static int cryptopacket_handle(void *object, IP_Port source, uint8_t *packet, ui | |||
313 | DHT *dht = object; | 313 | DHT *dht = object; |
314 | 314 | ||
315 | if (packet[0] == NET_PACKET_CRYPTO) { | 315 | if (packet[0] == NET_PACKET_CRYPTO) { |
316 | if (length <= crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES + 1 + ENCRYPTION_PADDING || | 316 | if (length <= crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES + 1 + crypto_box_MACBYTES || |
317 | length > MAX_DATA_SIZE + ENCRYPTION_PADDING) | 317 | length > MAX_DATA_SIZE + crypto_box_MACBYTES) |
318 | return 1; | 318 | return 1; |
319 | 319 | ||
320 | if (memcmp(packet + 1, dht->c->self_public_key, crypto_box_PUBLICKEYBYTES) == 0) { // Check if request is for us. | 320 | if (memcmp(packet + 1, dht->c->self_public_key, crypto_box_PUBLICKEYBYTES) == 0) { // Check if request is for us. |