|| -> | spotted by Ahmad

This commit is contained in:
Frank Denis 2015-01-18 10:17:53 +01:00
parent 5b3d8a4bf9
commit feaba594db
2 changed files with 9 additions and 8 deletions

View File

@ -1,22 +1,22 @@
#ifdef __EMSCRIPTEN__
# include <emscripten.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <assert.h> #include <assert.h>
#include <limits.h> #include <limits.h>
#include <stdint.h> #include <stdint.h>
#ifdef __EMSCRIPTEN__
# include <emscripten.h>
#endif
#include "randombytes.h" #include "randombytes.h"
#include "randombytes_sysrandom.h" #include "randombytes_sysrandom.h"
#ifdef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
static const randombytes_implementation *implementation = NULL;
#else
static const randombytes_implementation *implementation = static const randombytes_implementation *implementation =
&randombytes_sysrandom_implementation; &randombytes_sysrandom_implementation;
#else
static const randombytes_implementation *implementation = NULL;
#endif #endif
int int
@ -68,7 +68,7 @@ randombytes_stir(void)
var crypto = require('crypto'); var crypto = require('crypto');
var randomValueIOJS = function() { var randomValueIOJS = function() {
var buf = crypto.randomBytes(4); 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(); randomValueIOJS();
Module.getRandomValue = randomValueIOJS; Module.getRandomValue = randomValueIOJS;

View File

@ -36,6 +36,7 @@ static int randombytes_tests(void)
#endif #endif
randombytes(x, 1U); randombytes(x, 1U);
while (randombytes_random() <= (uint32_t) 0x7fffffff); while (randombytes_random() <= (uint32_t) 0x7fffffff);
while (randombytes_random() >= (uint32_t) 0x128);
randombytes_close(); randombytes_close();
for (i = 0; i < 256; ++i) { for (i = 0; i < 256; ++i) {