Merge pull request #6 from bip32JP/addmouse

Capture mouse movements for extra entropy
This commit is contained in:
OutCast3k 2014-12-31 14:13:19 +00:00
commit 18b27cdb34
3 changed files with 30 additions and 2 deletions

View file

@ -643,5 +643,6 @@
</div>
<!-- qrcode modal -->
<div class="hidden" id="entropybucket"></div>
</body>
</html>

View file

@ -43,7 +43,7 @@
var x = window.location;
x += (window.screen.height * window.screen.width * window.screen.colorDepth);
x += coinjs.random(64);
x += (window.screen.availHeight * window.screen.availWidth * window.screen.pixelDepth);
x += (window.screen.availHeight * window.screen.availWidth * window.screen.pixelDepth);
x += navigator.language;
x += window.history.length;
x += coinjs.random(64);
@ -54,9 +54,10 @@
var dateObj = new Date();
x += dateObj.getTimezoneOffset();
x += coinjs.random(64);
x += $("#entropybucket").html();
x += x+''+x;
var r = x;
for(i=0;i<(x).length/16;i++){
for(i=0;i<(x).length/25;i++){
r = Crypto.SHA256(r.concat(x));
}
return r;

View file

@ -813,4 +813,30 @@ $(document).ready(function() {
$("#newKeysBtn").click();
validateOutputAmount();
/* capture mouse movement to add entropy */
var IE = document.all?true:false // Boolean, is browser IE?
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
function getMouseXY(e) {
var tempX = 0;
var tempY = 0;
if (IE) { // If browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
} else {
tempX = e.pageX;
tempY = e.pageY;
};
if (tempX < 0){tempX = 0};
if (tempY < 0){tempY = 0};
var xEnt = Crypto.util.bytesToHex([tempX]);
var yEnt = Crypto.util.bytesToHex([tempY]);
var addEnt = xEnt.concat(yEnt);
if ($("#entropybucket").html().indexOf(xEnt) == -1 && $("#entropybucket").html().indexOf(yEnt) == -1) {
$("#entropybucket").html(addEnt + $("#entropybucket").html());
};
if ($("#entropybucket").html().length > 128) {$("#entropybucket").html($("#entropybucket").html().slice(0, 128))};
return true;
};
});