From feaba594db02746a3423497a173494db08c35996 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 18 Jan 2015 10:17:53 +0100 Subject: [PATCH] || -> | spotted by Ahmad --- src/libsodium/randombytes/randombytes.c | 16 ++++++++-------- test/default/randombytes.c | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libsodium/randombytes/randombytes.c b/src/libsodium/randombytes/randombytes.c index 314e9d02..b74719b1 100644 --- a/src/libsodium/randombytes/randombytes.c +++ b/src/libsodium/randombytes/randombytes.c @@ -1,22 +1,22 @@ -#ifdef __EMSCRIPTEN__ -# include -#endif - #include #include #include #include +#ifdef __EMSCRIPTEN__ +# include +#endif + #include "randombytes.h" #include "randombytes_sysrandom.h" -#ifdef __EMSCRIPTEN__ -static const randombytes_implementation *implementation = NULL; -#else +#ifndef __EMSCRIPTEN__ static const randombytes_implementation *implementation = &randombytes_sysrandom_implementation; +#else +static const randombytes_implementation *implementation = NULL; #endif int @@ -68,7 +68,7 @@ randombytes_stir(void) var crypto = require('crypto'); var randomValueIOJS = function() { var buf = crypto.randomBytes(4); - return (buf[0] << 24 | buf[1] << 16 || buf[2] << 8 || buf[3]) >>> 0; + return (buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]) >>> 0; }; randomValueIOJS(); Module.getRandomValue = randomValueIOJS; diff --git a/test/default/randombytes.c b/test/default/randombytes.c index db406202..a518ded9 100644 --- a/test/default/randombytes.c +++ b/test/default/randombytes.c @@ -36,6 +36,7 @@ static int randombytes_tests(void) #endif randombytes(x, 1U); while (randombytes_random() <= (uint32_t) 0x7fffffff); + while (randombytes_random() >= (uint32_t) 0x128); randombytes_close(); for (i = 0; i < 256; ++i) {