diff --git a/test/default/randombytes.c b/test/default/randombytes.c index a518ded9..231a29bd 100644 --- a/test/default/randombytes.c +++ b/test/default/randombytes.c @@ -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) {