SecureRandom: /!\ throw an alert if the PRNG is used is initialized when the entropy collection using the mouse is not done.

This commit is contained in:
Michael Muré 2014-07-02 21:23:39 +02:00
parent 125d9d8997
commit 5b3cae1f32
3 changed files with 23 additions and 5 deletions

View file

@ -1543,6 +1543,11 @@ if (typeof Crypto == "undefined" || !Crypto.util) {
}
sr.getByte = function () {
if(!ninja.seeder.isDone()) {
alert("Premature initialisation of the random generator. Something is really wrong, do not generate wallets.");
return NaN;
}
if (sr.state == null) {
sr.seedTime();
sr.state = sr.ArcFour(); // Plug in your RNG constructor here
@ -10703,6 +10708,10 @@ ninja.publicKey = {
lastInputTime: new Date().getTime(),
seedPoints: [],
isDone: function() {
return ninja.seeder.seedCount >= ninja.seeder.seedLimit;
},
// seed function exists to wait for mouse movement to add more entropy before generating an address
seed: function (evt) {
if (!evt) var evt = window.event;

View file

@ -13,14 +13,18 @@
lastInputTime: new Date().getTime(),
seedPoints: [],
isDone: function() {
return ninja.seeder.seedCount >= ninja.seeder.seedLimit;
},
// seed function exists to wait for mouse movement to add more entropy before generating an address
seed: function (evt) {
if (!evt) var evt = window.event;
var timeStamp = new Date().getTime();
// seeding is over now we generate and display the address
// seeding is over now we generate and display the address
if (ninja.seeder.seedCount == ninja.seeder.seedLimit) {
ninja.seeder.seedCount++;
ninja.wallets.singlewallet.open();
ninja.wallets.singlewallet.open();
document.getElementById("generate").style.display = "none";
document.getElementById("menu").style.visibility = "visible";
ninja.seeder.removePoints();
@ -42,7 +46,7 @@
// seeding is over now we generate and display the address
if (ninja.seeder.seedCount == ninja.seeder.seedLimit) {
ninja.seeder.seedCount++;
ninja.wallets.singlewallet.open();
ninja.wallets.singlewallet.open();
document.getElementById("generate").style.display = "none";
document.getElementById("menu").style.visibility = "visible";
ninja.seeder.removePoints();
@ -63,8 +67,8 @@
showPool: function () {
var poolHex = Crypto.util.bytesToHex(SecureRandom.pool);
document.getElementById("seedpool").innerHTML = poolHex;
document.getElementById("seedpooldisplay").innerHTML = poolHex;
document.getElementById("seedpool").innerHTML = poolHex;
document.getElementById("seedpooldisplay").innerHTML = poolHex;
document.getElementById("mousemovelimit").innerHTML = (ninja.seeder.seedLimit - ninja.seeder.seedCount);
},

View file

@ -52,6 +52,11 @@
}
sr.getByte = function () {
if(!ninja.seeder.isDone()) {
alert("Premature initialisation of the random generator. Something is really wrong, do not generate wallets.");
return NaN;
}
if (sr.state == null) {
sr.seedTime();
sr.state = sr.ArcFour(); // Plug in your RNG constructor here