mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-23 20:15:19 -07:00
Add an extra test for randombytes
This commit is contained in:
parent
e2a24e69ec
commit
388baa5380
@ -27,7 +27,9 @@ static int compat_tests(void)
|
||||
|
||||
static int randombytes_tests(void)
|
||||
{
|
||||
unsigned int f = 0U;
|
||||
unsigned int i;
|
||||
uint32_t n;
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
assert(strcmp(randombytes_implementation_name(), "sysrandom"));
|
||||
@ -35,8 +37,14 @@ static int randombytes_tests(void)
|
||||
assert(strcmp(randombytes_implementation_name(), "js"));
|
||||
#endif
|
||||
randombytes(x, 1U);
|
||||
while (randombytes_random() <= (uint32_t) 0x7fffffff);
|
||||
while (randombytes_random() >= (uint32_t) 0x128);
|
||||
do {
|
||||
n = randombytes_random();
|
||||
f |= ((n >> 24) > 1);
|
||||
f |= ((n >> 16) > 1) << 1;
|
||||
f |= ((n >> 8) > 1) << 2;
|
||||
f |= ((n ) > 1) << 3;
|
||||
f |= (n > 0x7fffffff) << 4;
|
||||
} while (f != 0x1f);
|
||||
randombytes_close();
|
||||
|
||||
for (i = 0; i < 256; ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user