Skip to content
Snippets Groups Projects
Unverified Commit b453952c authored by Olivier Pereira's avatar Olivier Pereira Committed by GitHub
Browse files

Update random.js

Setting randomWords paranoia level to 6, which is the default level suggested on https://github.com/bitwiseshiftleft/sjcl/wiki/Symmetric-Crypto#generating-random-bytes
Also removing unreachable line at end of function.
parent af9214d2
No related branches found
No related tags found
No related merge requests found
...@@ -26,10 +26,9 @@ Random.getRandomInteger = function(max) { ...@@ -26,10 +26,9 @@ Random.getRandomInteger = function(max) {
var bit_length = max.bitLength(); var bit_length = max.bitLength();
Random.setupGenerator(); Random.setupGenerator();
var random; var random;
random = sjcl.random.randomWords(Math.ceil(bit_length / 32)+2, 0); random = sjcl.random.randomWords(Math.ceil(bit_length / 32) + 2, 6);
// we get a bit array instead of a BigInteger in this case // we get a bit array instead of a BigInteger in this case
var rand_bi = new BigInt(sjcl.codec.hex.fromBits(random), 16); var rand_bi = new BigInt(sjcl.codec.hex.fromBits(random), 16);
return rand_bi.mod(max); return rand_bi.mod(max);
return BigInt._from_java_object(random).mod(max);
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment