mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-20 02:25:14 -07:00
getentropy() only returns 0 or -1 and is atomic
This commit is contained in:
parent
0299203305
commit
015dfe9978
@ -178,14 +178,11 @@ randombytes_internal_random_init(void)
|
|||||||
static int
|
static int
|
||||||
_randombytes_getentropy(void * const buf, const size_t size)
|
_randombytes_getentropy(void * const buf, const size_t size)
|
||||||
{
|
{
|
||||||
int readnb;
|
|
||||||
|
|
||||||
assert(size <= 256U);
|
assert(size <= 256U);
|
||||||
do {
|
if (getentropy(buf, size) != 0) {
|
||||||
readnb = getentropy(buf, size);
|
return -1;
|
||||||
} while (readnb < 0 && (errno == EINTR || errno == EAGAIN));
|
}
|
||||||
|
return 0;
|
||||||
return (readnb == (int) size) - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user