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:
parent
125d9d8997
commit
5b3cae1f32
3 changed files with 23 additions and 5 deletions
|
@ -1543,6 +1543,11 @@ if (typeof Crypto == "undefined" || !Crypto.util) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sr.getByte = function () {
|
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) {
|
if (sr.state == null) {
|
||||||
sr.seedTime();
|
sr.seedTime();
|
||||||
sr.state = sr.ArcFour(); // Plug in your RNG constructor here
|
sr.state = sr.ArcFour(); // Plug in your RNG constructor here
|
||||||
|
@ -10703,6 +10708,10 @@ ninja.publicKey = {
|
||||||
lastInputTime: new Date().getTime(),
|
lastInputTime: new Date().getTime(),
|
||||||
seedPoints: [],
|
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 exists to wait for mouse movement to add more entropy before generating an address
|
||||||
seed: function (evt) {
|
seed: function (evt) {
|
||||||
if (!evt) var evt = window.event;
|
if (!evt) var evt = window.event;
|
||||||
|
|
|
@ -13,14 +13,18 @@
|
||||||
lastInputTime: new Date().getTime(),
|
lastInputTime: new Date().getTime(),
|
||||||
seedPoints: [],
|
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 exists to wait for mouse movement to add more entropy before generating an address
|
||||||
seed: function (evt) {
|
seed: function (evt) {
|
||||||
if (!evt) var evt = window.event;
|
if (!evt) var evt = window.event;
|
||||||
var timeStamp = new Date().getTime();
|
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) {
|
if (ninja.seeder.seedCount == ninja.seeder.seedLimit) {
|
||||||
ninja.seeder.seedCount++;
|
ninja.seeder.seedCount++;
|
||||||
ninja.wallets.singlewallet.open();
|
ninja.wallets.singlewallet.open();
|
||||||
document.getElementById("generate").style.display = "none";
|
document.getElementById("generate").style.display = "none";
|
||||||
document.getElementById("menu").style.visibility = "visible";
|
document.getElementById("menu").style.visibility = "visible";
|
||||||
ninja.seeder.removePoints();
|
ninja.seeder.removePoints();
|
||||||
|
@ -42,7 +46,7 @@
|
||||||
// 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) {
|
if (ninja.seeder.seedCount == ninja.seeder.seedLimit) {
|
||||||
ninja.seeder.seedCount++;
|
ninja.seeder.seedCount++;
|
||||||
ninja.wallets.singlewallet.open();
|
ninja.wallets.singlewallet.open();
|
||||||
document.getElementById("generate").style.display = "none";
|
document.getElementById("generate").style.display = "none";
|
||||||
document.getElementById("menu").style.visibility = "visible";
|
document.getElementById("menu").style.visibility = "visible";
|
||||||
ninja.seeder.removePoints();
|
ninja.seeder.removePoints();
|
||||||
|
@ -63,8 +67,8 @@
|
||||||
|
|
||||||
showPool: function () {
|
showPool: function () {
|
||||||
var poolHex = Crypto.util.bytesToHex(SecureRandom.pool);
|
var poolHex = Crypto.util.bytesToHex(SecureRandom.pool);
|
||||||
document.getElementById("seedpool").innerHTML = poolHex;
|
document.getElementById("seedpool").innerHTML = poolHex;
|
||||||
document.getElementById("seedpooldisplay").innerHTML = poolHex;
|
document.getElementById("seedpooldisplay").innerHTML = poolHex;
|
||||||
document.getElementById("mousemovelimit").innerHTML = (ninja.seeder.seedLimit - ninja.seeder.seedCount);
|
document.getElementById("mousemovelimit").innerHTML = (ninja.seeder.seedLimit - ninja.seeder.seedCount);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
sr.getByte = function () {
|
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) {
|
if (sr.state == null) {
|
||||||
sr.seedTime();
|
sr.seedTime();
|
||||||
sr.state = sr.ArcFour(); // Plug in your RNG constructor here
|
sr.state = sr.ArcFour(); // Plug in your RNG constructor here
|
||||||
|
|
Loading…
Add table
Reference in a new issue