From 358767f238970ffb4ab4e397e46eca2a812bdef0 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 6 Jan 2019 04:31:44 +0100 Subject: [PATCH] Set nonce in randombytes_salsa20_random_stir() instead of random_init() --- .../randombytes/salsa20/randombytes_salsa20_random.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c index 8858713c..64c4cec5 100644 --- a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +++ b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c @@ -163,8 +163,6 @@ sodium_hrtime(void) static void randombytes_salsa20_random_init(void) { - stream.nonce = sodium_hrtime(); - assert(stream.nonce != (uint64_t) 0U); global.rdrand_available = sodium_runtime_has_rdrand(); } @@ -304,9 +302,7 @@ randombytes_salsa20_random_init(void) { const int errno_save = errno; - stream.nonce = sodium_hrtime(); global.rdrand_available = sodium_runtime_has_rdrand(); - assert(stream.nonce != (uint64_t) 0U); # ifdef HAVE_SAFE_ARC4RANDOM errno = errno_save; @@ -342,6 +338,8 @@ randombytes_salsa20_random_init(void) static void randombytes_salsa20_random_stir(void) { + stream.nonce = sodium_hrtime(); + assert(stream.nonce != (uint64_t) 0U); memset(stream.rnd32, 0, sizeof stream.rnd32); stream.rnd32_outleft = (size_t) 0U; if (global.initialized == 0) {