diff options
author | irungentoo <irungentoo@gmail.com> | 2014-03-05 16:54:17 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-03-05 16:54:17 -0500 |
commit | 3bcc6e2ae547ae77f14d7d140a363cc2cc01f01a (patch) | |
tree | 77d88f12335573afcb61238d74828a4e131222a6 /toxcore/onion.c | |
parent | 3a1f259cb9f939ceeb6d8794873a9bf683c2e730 (diff) |
CPU optimizations.
Use get_shared_key() in more places.
Diffstat (limited to 'toxcore/onion.c')
-rw-r--r-- | toxcore/onion.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/toxcore/onion.c b/toxcore/onion.c index 57001784..292f9309 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c | |||
@@ -173,10 +173,10 @@ static int handle_send_initial(void *object, IP_Port source, uint8_t *packet, ui | |||
173 | change_symmetric_key(onion); | 173 | change_symmetric_key(onion); |
174 | 174 | ||
175 | uint8_t plain[MAX_ONION_SIZE]; | 175 | uint8_t plain[MAX_ONION_SIZE]; |
176 | 176 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; | |
177 | int len = decrypt_data(packet + 1 + crypto_box_NONCEBYTES, onion->dht->self_secret_key, packet + 1, | 177 | get_shared_key(&onion->shared_keys_1, shared_key, onion->dht->self_secret_key, packet + 1 + crypto_box_NONCEBYTES); |
178 | packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, | 178 | int len = decrypt_data_fast(shared_key, packet + 1, packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, |
179 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES), plain); | 179 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES), plain); |
180 | 180 | ||
181 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES)) | 181 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES)) |
182 | return 1; | 182 | return 1; |
@@ -219,10 +219,10 @@ static int handle_send_1(void *object, IP_Port source, uint8_t *packet, uint32_t | |||
219 | change_symmetric_key(onion); | 219 | change_symmetric_key(onion); |
220 | 220 | ||
221 | uint8_t plain[MAX_ONION_SIZE]; | 221 | uint8_t plain[MAX_ONION_SIZE]; |
222 | 222 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; | |
223 | int len = decrypt_data(packet + 1 + crypto_box_NONCEBYTES, onion->dht->self_secret_key, packet + 1, | 223 | get_shared_key(&onion->shared_keys_2, shared_key, onion->dht->self_secret_key, packet + 1 + crypto_box_NONCEBYTES); |
224 | packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, | 224 | int len = decrypt_data_fast(shared_key, packet + 1, packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, |
225 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_1), plain); | 225 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_1), plain); |
226 | 226 | ||
227 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_1 + crypto_box_MACBYTES)) | 227 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_1 + crypto_box_MACBYTES)) |
228 | return 1; | 228 | return 1; |
@@ -268,10 +268,10 @@ static int handle_send_2(void *object, IP_Port source, uint8_t *packet, uint32_t | |||
268 | change_symmetric_key(onion); | 268 | change_symmetric_key(onion); |
269 | 269 | ||
270 | uint8_t plain[MAX_ONION_SIZE]; | 270 | uint8_t plain[MAX_ONION_SIZE]; |
271 | 271 | uint8_t shared_key[crypto_box_BEFORENMBYTES]; | |
272 | int len = decrypt_data(packet + 1 + crypto_box_NONCEBYTES, onion->dht->self_secret_key, packet + 1, | 272 | get_shared_key(&onion->shared_keys_3, shared_key, onion->dht->self_secret_key, packet + 1 + crypto_box_NONCEBYTES); |
273 | packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, | 273 | int len = decrypt_data_fast(shared_key, packet + 1, packet + 1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES, |
274 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_2), plain); | 274 | length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_2), plain); |
275 | 275 | ||
276 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_2 + crypto_box_MACBYTES)) | 276 | if ((uint32_t)len != length - (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + RETURN_2 + crypto_box_MACBYTES)) |
277 | return 1; | 277 | return 1; |