mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-20 10:37:24 -07:00
Call randombytes_salsa20_random_stir_if_needed() only when we don't have
anything in stock, and reduce the number of required getpid() calls.
This commit is contained in:
parent
81d604c70c
commit
e68b08a4ff
@ -205,6 +205,7 @@ randombytes_salsa20_random_getword(void)
|
|||||||
COMPILER_ASSERT(sizeof stream.rnd32 >= sizeof val);
|
COMPILER_ASSERT(sizeof stream.rnd32 >= sizeof val);
|
||||||
COMPILER_ASSERT(sizeof stream.rnd32 % sizeof val == (size_t) 0U);
|
COMPILER_ASSERT(sizeof stream.rnd32 % sizeof val == (size_t) 0U);
|
||||||
if (stream.rnd32_outleft <= (size_t) 0U) {
|
if (stream.rnd32_outleft <= (size_t) 0U) {
|
||||||
|
randombytes_salsa20_random_stir_if_needed();
|
||||||
COMPILER_ASSERT(sizeof stream.nonce == crypto_stream_salsa20_NONCEBYTES);
|
COMPILER_ASSERT(sizeof stream.nonce == crypto_stream_salsa20_NONCEBYTES);
|
||||||
ret = crypto_stream_salsa20((unsigned char *) stream.rnd32,
|
ret = crypto_stream_salsa20((unsigned char *) stream.rnd32,
|
||||||
(unsigned long long) sizeof stream.rnd32,
|
(unsigned long long) sizeof stream.rnd32,
|
||||||
@ -245,8 +246,6 @@ randombytes_salsa20_random_close(void)
|
|||||||
uint32_t
|
uint32_t
|
||||||
randombytes_salsa20_random(void)
|
randombytes_salsa20_random(void)
|
||||||
{
|
{
|
||||||
randombytes_salsa20_random_stir_if_needed();
|
|
||||||
|
|
||||||
return randombytes_salsa20_random_getword();
|
return randombytes_salsa20_random_getword();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user