From 125d9d899750e39c2f1560a716415d9818fd80fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Wed, 2 Jul 2014 21:14:21 +0200 Subject: [PATCH] SecureRandom: remove the weird copy of the entropy pool --- index.html | 14 +------------- src/ninja.misc.js | 10 +--------- src/securerandom.js | 4 ---- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/index.html b/index.html index 56705a2..56e5012 100644 --- a/index.html +++ b/index.html @@ -1508,7 +1508,6 @@ if (typeof Crypto == "undefined" || !Crypto.util) { sr.state; sr.pool; sr.pptr; - sr.poolCopyOnInit; // Pool size must be a multiple of 4 and greater than 32. // An array of bytes the size of the pool will be passed to init() @@ -1548,9 +1547,6 @@ if (typeof Crypto == "undefined" || !Crypto.util) { sr.seedTime(); sr.state = sr.ArcFour(); // Plug in your RNG constructor here sr.state.init(sr.pool); - sr.poolCopyOnInit = []; - for (sr.pptr = 0; sr.pptr < sr.pool.length; ++sr.pptr) - sr.poolCopyOnInit[sr.pptr] = sr.pool[sr.pptr]; sr.pptr = 0; } // TODO: allow reseeding after first request @@ -10756,17 +10752,9 @@ ninja.publicKey = { }, showPool: function () { - var poolHex; - if (SecureRandom.poolCopyOnInit != null) { - poolHex = Crypto.util.bytesToHex(SecureRandom.poolCopyOnInit); + var poolHex = Crypto.util.bytesToHex(SecureRandom.pool); document.getElementById("seedpool").innerHTML = poolHex; document.getElementById("seedpooldisplay").innerHTML = poolHex; - } - else { - poolHex = Crypto.util.bytesToHex(SecureRandom.pool); - document.getElementById("seedpool").innerHTML = poolHex; - document.getElementById("seedpooldisplay").innerHTML = poolHex; - } document.getElementById("mousemovelimit").innerHTML = (ninja.seeder.seedLimit - ninja.seeder.seedCount); }, diff --git a/src/ninja.misc.js b/src/ninja.misc.js index 040757b..7aeeba1 100644 --- a/src/ninja.misc.js +++ b/src/ninja.misc.js @@ -62,17 +62,9 @@ }, showPool: function () { - var poolHex; - if (SecureRandom.poolCopyOnInit != null) { - poolHex = Crypto.util.bytesToHex(SecureRandom.poolCopyOnInit); + var poolHex = Crypto.util.bytesToHex(SecureRandom.pool); document.getElementById("seedpool").innerHTML = poolHex; document.getElementById("seedpooldisplay").innerHTML = poolHex; - } - else { - poolHex = Crypto.util.bytesToHex(SecureRandom.pool); - document.getElementById("seedpool").innerHTML = poolHex; - document.getElementById("seedpooldisplay").innerHTML = poolHex; - } document.getElementById("mousemovelimit").innerHTML = (ninja.seeder.seedLimit - ninja.seeder.seedCount); }, diff --git a/src/securerandom.js b/src/securerandom.js index 91f1991..3b6f172 100644 --- a/src/securerandom.js +++ b/src/securerandom.js @@ -17,7 +17,6 @@ sr.state; sr.pool; sr.pptr; - sr.poolCopyOnInit; // Pool size must be a multiple of 4 and greater than 32. // An array of bytes the size of the pool will be passed to init() @@ -57,9 +56,6 @@ sr.seedTime(); sr.state = sr.ArcFour(); // Plug in your RNG constructor here sr.state.init(sr.pool); - sr.poolCopyOnInit = []; - for (sr.pptr = 0; sr.pptr < sr.pool.length; ++sr.pptr) - sr.poolCopyOnInit[sr.pptr] = sr.pool[sr.pptr]; sr.pptr = 0; } // TODO: allow reseeding after first request