mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
Do not use a zero nonce in randombytes_buf_deterministic()
This can mitigate implications of reusing the same key across different functions.
This commit is contained in:
@@ -165,7 +165,9 @@ void
|
||||
randombytes_buf_deterministic(void * const buf, const size_t size,
|
||||
const unsigned char seed[randombytes_SEEDBYTES])
|
||||
{
|
||||
static const unsigned char zero[crypto_stream_chacha20_ietf_NONCEBYTES] = { 0 };
|
||||
static const unsigned char nonce[crypto_stream_chacha20_ietf_NONCEBYTES] = {
|
||||
'L', 'i', 'b', 's', 'o', 'd', 'i', 'u', 'm', 'D', 'R', 'G'
|
||||
};
|
||||
|
||||
COMPILER_ASSERT(randombytes_SEEDBYTES == crypto_stream_chacha20_ietf_KEYBYTES);
|
||||
#if SIZE_MAX > 0x4000000000ULL
|
||||
@@ -174,7 +176,7 @@ randombytes_buf_deterministic(void * const buf, const size_t size,
|
||||
}
|
||||
#endif
|
||||
crypto_stream_chacha20_ietf((unsigned char *) buf, (unsigned long long) size,
|
||||
zero, seed);
|
||||
nonce, seed);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
39fd2b7dd9c5196a8dbd0377b8dc4a498a35d86fbcde6accb2cc7d4cd8ea24922b23cce7a26023ab3f0eef693ac87f64258235eab1f7a32dc22762a0485b410c18b84231ade6a6d113615c61af434e27f8b1f3f5e1ad5b5cecf8fc122a35755c7208086d (deterministic)
|
||||
0d8e6cc68715648926732e7ea73250cfaf2d58422083904c841a8ba33b986111f346ba50723a68ae283524a6bded09f83be6b80595856f72e25b86918e8b114bafb94bc8abedd73daab454576b7c5833eb0bf982a1bb4587a5c970ff0810ca3b791d7e12 (deterministic)
|
||||
OK
|
||||
|
||||
Reference in New Issue
Block a user