mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Implemented a faster algorithm for generating nonces
This commit is contained in:
parent
550725c11a
commit
c999fb6462
|
@ -138,14 +138,18 @@ void increment_nonce(uint8_t * nonce)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fill the given nonce with random bytes.
|
/* fill the given nonce with random bytes. */
|
||||||
TODO: make this more optimized */
|
|
||||||
void random_nonce(uint8_t * nonce)
|
void random_nonce(uint8_t * nonce)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i, j, r, m = crypto_box_NONCEBYTES / 3, ind = 0;
|
||||||
for(i = 0; i < crypto_box_NONCEBYTES; ++i)
|
for(i = 0; i < m; ++i)
|
||||||
{
|
{
|
||||||
nonce[i] = random_int() % 256;
|
r = ranom_int();
|
||||||
|
for (j = 0; j < 3; j++) {
|
||||||
|
nonce[ind] = r % 1000 % 256;
|
||||||
|
r /= 1000;
|
||||||
|
++ind;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user