summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorNick ODell <nickodell@gmail.com>2013-08-02 16:35:41 -0600
committerNick ODell <nickodell@gmail.com>2013-08-02 16:35:41 -0600
commit9c039cfd2a11ba6dc7c3c5bfca376b0f955ff7d3 (patch)
treeac618262ce44cf7576d8c650673f63c55e68d207 /core
parent8d1f7753f679b12a8e57f8b5c4b529bb627ba6c5 (diff)
Replace ZEROBYTES - BOXZEROBYTES with MACBYTES
Diffstat (limited to 'core')
-rw-r--r--core/net_crypto.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/net_crypto.c b/core/net_crypto.c
index 3233d875..3b5b67f4 100644
--- a/core/net_crypto.c
+++ b/core/net_crypto.c
@@ -66,7 +66,7 @@ static int incoming_connections[MAX_INCOMING];
66int encrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce, 66int encrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce,
67 uint8_t *plain, uint32_t length, uint8_t *encrypted) 67 uint8_t *plain, uint32_t length, uint8_t *encrypted)
68{ 68{
69 if (length - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES > MAX_DATA_SIZE || length == 0) 69 if (length + crypto_box_MACBYTES > MAX_DATA_SIZE || length == 0)
70 return -1; 70 return -1;
71 71
72 uint8_t temp_plain[MAX_DATA_SIZE + crypto_box_BOXZEROBYTES] = {0}; 72 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,
87 return -1; 87 return -1;
88 88
89 /* unpad the encrypted message */ 89 /* unpad the encrypted message */
90 memcpy(encrypted, temp_encrypted + crypto_box_BOXZEROBYTES, length - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES); 90 memcpy(encrypted, temp_encrypted + crypto_box_BOXZEROBYTES, length + crypto_box_MACBYTES);
91 return length - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES; 91 return length - crypto_box_BOXZEROBYTES + crypto_box_ZEROBYTES;
92} 92}
93 93
@@ -121,7 +121,7 @@ int decrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce,
121 return -1; 121 return -1;
122 122
123 /* unpad the plain message */ 123 /* unpad the plain message */
124 memcpy(plain, temp_plain + crypto_box_ZEROBYTES, length - crypto_box_ZEROBYTES + crypto_box_BOXZEROBYTES); 124 memcpy(plain, temp_plain + crypto_box_ZEROBYTES, length - crypto_box_MACBYTES);
125 return length - crypto_box_ZEROBYTES + crypto_box_BOXZEROBYTES; 125 return length - crypto_box_ZEROBYTES + crypto_box_BOXZEROBYTES;
126} 126}
127 127