diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-11-06 15:14:02 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-11-09 22:30:49 +0000 |
commit | aed24408db9cd8afe632a1d3f056669ae34f49be (patch) | |
tree | 77cb037490b3f97af949eb39dfdf2e1e513b61d1 /toxcore/onion.c | |
parent | 42dfdf73c1dfd899a4f5a44ea1584aaf3a4ed3d2 (diff) |
Remove new_nonce function in favour of random_nonce.
`new_nonce` has been an alias for `random_nonce` for a while now. Having
two names for the same operation is confusing. `random_nonce` better
expresses the intent. The documentation for `new_nonce` talks about
guaranteeing that the nonce is different from previous ones, which is
incorrect, it's just quite likely to be different.
Diffstat (limited to 'toxcore/onion.c')
-rw-r--r-- | toxcore/onion.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/toxcore/onion.c b/toxcore/onion.c index 5705c14f..06ff719b 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c | |||
@@ -375,7 +375,7 @@ int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, IP_Port | |||
375 | memcpy(data + 1 + crypto_box_NONCEBYTES, plain + SIZE_IPPORT, len - SIZE_IPPORT); | 375 | memcpy(data + 1 + crypto_box_NONCEBYTES, plain + SIZE_IPPORT, len - SIZE_IPPORT); |
376 | uint16_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT); | 376 | uint16_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT); |
377 | uint8_t *ret_part = data + data_len; | 377 | uint8_t *ret_part = data + data_len; |
378 | new_nonce(ret_part); | 378 | random_nonce(ret_part); |
379 | len = encrypt_data_symmetric(onion->secret_symmetric_key, ret_part, ip_port, SIZE_IPPORT, | 379 | len = encrypt_data_symmetric(onion->secret_symmetric_key, ret_part, ip_port, SIZE_IPPORT, |
380 | ret_part + crypto_box_NONCEBYTES); | 380 | ret_part + crypto_box_NONCEBYTES); |
381 | 381 | ||
@@ -428,7 +428,7 @@ static int handle_send_1(void *object, IP_Port source, const uint8_t *packet, ui | |||
428 | memcpy(data + 1 + crypto_box_NONCEBYTES, plain + SIZE_IPPORT, len - SIZE_IPPORT); | 428 | memcpy(data + 1 + crypto_box_NONCEBYTES, plain + SIZE_IPPORT, len - SIZE_IPPORT); |
429 | uint16_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT); | 429 | uint16_t data_len = 1 + crypto_box_NONCEBYTES + (len - SIZE_IPPORT); |
430 | uint8_t *ret_part = data + data_len; | 430 | uint8_t *ret_part = data + data_len; |
431 | new_nonce(ret_part); | 431 | random_nonce(ret_part); |
432 | uint8_t ret_data[RETURN_1 + SIZE_IPPORT]; | 432 | uint8_t ret_data[RETURN_1 + SIZE_IPPORT]; |
433 | ipport_pack(ret_data, &source); | 433 | ipport_pack(ret_data, &source); |
434 | memcpy(ret_data + SIZE_IPPORT, packet + (length - RETURN_1), RETURN_1); | 434 | memcpy(ret_data + SIZE_IPPORT, packet + (length - RETURN_1), RETURN_1); |
@@ -482,7 +482,7 @@ static int handle_send_2(void *object, IP_Port source, const uint8_t *packet, ui | |||
482 | memcpy(data, plain + SIZE_IPPORT, len - SIZE_IPPORT); | 482 | memcpy(data, plain + SIZE_IPPORT, len - SIZE_IPPORT); |
483 | uint16_t data_len = (len - SIZE_IPPORT); | 483 | uint16_t data_len = (len - SIZE_IPPORT); |
484 | uint8_t *ret_part = data + (len - SIZE_IPPORT); | 484 | uint8_t *ret_part = data + (len - SIZE_IPPORT); |
485 | new_nonce(ret_part); | 485 | random_nonce(ret_part); |
486 | uint8_t ret_data[RETURN_2 + SIZE_IPPORT]; | 486 | uint8_t ret_data[RETURN_2 + SIZE_IPPORT]; |
487 | ipport_pack(ret_data, &source); | 487 | ipport_pack(ret_data, &source); |
488 | memcpy(ret_data + SIZE_IPPORT, packet + (length - RETURN_2), RETURN_2); | 488 | memcpy(ret_data + SIZE_IPPORT, packet + (length - RETURN_2), RETURN_2); |