Skip to content

Commit

Permalink
Make sure there is enough entropy.
Browse files Browse the repository at this point in the history
This patch will improve key randomness by requiring the user to move the
mouse if there is not enough entropy.
  • Loading branch information
sebsauvage committed Feb 24, 2013
1 parent 7a8cbee commit c6e9804
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion js/zerobin.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function pasteID() {
function setElementText(element, text) {
// For IE<10.
if ($('div#oldienotice').is(":visible")) {
// IE<10 do not support white-space:pre-wrap; so we have to do this BIG UGLY STINKING THING.
// IE<10 does not support white-space:pre-wrap; so we have to do this BIG UGLY STINKING THING.
element.text(text.replace(/\n/ig,'{BIG_UGLY_STINKING_THING__OH_GOD_I_HATE_IE}'));
element.html(element.text().replace(/{BIG_UGLY_STINKING_THING__OH_GOD_I_HATE_IE}/ig,"\r\n<br>"));
}
Expand Down Expand Up @@ -317,6 +317,7 @@ function send_comment(parentid) {
});
}


/**
* Send a new paste to server
*/
Expand All @@ -325,7 +326,17 @@ function send_data() {
if ($('textarea#message').val().length == 0) {
return;
}

// If sjcl has not collected enough entropy yet, display a message.
if (!sjcl.random.isReady())
{
showStatus('Sending paste (Please move your mouse for more entropy)...', spin=true);
sjcl.random.addEventListener('seeded', function(){ send_data(); });
return;
}

showStatus('Sending paste...', spin=true);

var randomkey = sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
var cipherdata = zeroCipher(randomkey, $('textarea#message').val());
var data_to_send = { data: cipherdata,
Expand Down

0 comments on commit c6e9804

Please sign in to comment.