From 388baa5380fc550dabda1d9ca0f07d7ea39f18c8 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 18 Jan 2015 10:34:31 +0100 Subject: [PATCH] Add an extra test for randombytes --- test/default/randombytes.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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) {