From b453952c4e253b680cdad1a9043b15abccfbf6b6 Mon Sep 17 00:00:00 2001 From: Olivier Pereira <olivier.pereira@uclouvain.be> Date: Thu, 11 Apr 2019 10:49:53 +0200 Subject: [PATCH] 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. --- heliosbooth/js/jscrypto/random.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heliosbooth/js/jscrypto/random.js b/heliosbooth/js/jscrypto/random.js index dd69f9d..8e363a6 100644 --- a/heliosbooth/js/jscrypto/random.js +++ b/heliosbooth/js/jscrypto/random.js @@ -26,10 +26,9 @@ Random.getRandomInteger = function(max) { var bit_length = max.bitLength(); Random.setupGenerator(); 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 var rand_bi = new BigInt(sjcl.codec.hex.fromBits(random), 16); return rand_bi.mod(max); - return BigInt._from_java_object(random).mod(max); }; -- GitLab