mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Replace ZEROBYTES - BOXZEROBYTES with MACBYTES
This commit is contained in:
parent
8d1f7753f6
commit
9c039cfd2a
|
@ -66,7 +66,7 @@ static int incoming_connections[MAX_INCOMING];
|
|||
int encrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce,
|
||||
uint8_t *plain, uint32_t length, uint8_t *encrypted)
|
||||
{
|
||||
if (length - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES > MAX_DATA_SIZE || length == 0)
|
||||
if (length + crypto_box_MACBYTES > MAX_DATA_SIZE || length == 0)
|
||||
return -1;
|
||||
|
||||
uint8_t temp_plain[MAX_DATA_SIZE + crypto_box_BOXZEROBYTES] = {0};
|
||||
|
@ -87,7 +87,7 @@ int encrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce,
|
|||
return -1;
|
||||
|
||||
/* unpad the encrypted message */
|
||||
memcpy(encrypted, temp_encrypted + crypto_box_BOXZEROBYTES, length - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES);
|
||||
memcpy(encrypted, temp_encrypted + crypto_box_BOXZEROBYTES, length + crypto_box_MACBYTES);
|
||||
return length - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES;
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ int decrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce,
|
|||
return -1;
|
||||
|
||||
/* unpad the plain message */
|
||||
memcpy(plain, temp_plain + crypto_box_ZEROBYTES, length - crypto_box_ZEROBYTES + crypto_box_BOXZEROBYTES);
|
||||
memcpy(plain, temp_plain + crypto_box_ZEROBYTES, length - crypto_box_MACBYTES);
|
||||
return length - crypto_box_ZEROBYTES + crypto_box_BOXZEROBYTES;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user