Skip to content

Commit c6e9804

Browse files
committed
Make sure there is enough entropy.
This patch will improve key randomness by requiring the user to move the mouse if there is not enough entropy.
1 parent 7a8cbee commit c6e9804

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

js/zerobin.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function pasteID() {
156156
function setElementText(element, text) {
157157
// For IE<10.
158158
if ($('div#oldienotice').is(":visible")) {
159-
// IE<10 do not support white-space:pre-wrap; so we have to do this BIG UGLY STINKING THING.
159+
// IE<10 does not support white-space:pre-wrap; so we have to do this BIG UGLY STINKING THING.
160160
element.text(text.replace(/\n/ig,'{BIG_UGLY_STINKING_THING__OH_GOD_I_HATE_IE}'));
161161
element.html(element.text().replace(/{BIG_UGLY_STINKING_THING__OH_GOD_I_HATE_IE}/ig,"\r\n<br>"));
162162
}
@@ -317,6 +317,7 @@ function send_comment(parentid) {
317317
});
318318
}
319319

320+
320321
/**
321322
* Send a new paste to server
322323
*/
@@ -325,7 +326,17 @@ function send_data() {
325326
if ($('textarea#message').val().length == 0) {
326327
return;
327328
}
329+
330+
// If sjcl has not collected enough entropy yet, display a message.
331+
if (!sjcl.random.isReady())
332+
{
333+
showStatus('Sending paste (Please move your mouse for more entropy)...', spin=true);
334+
sjcl.random.addEventListener('seeded', function(){ send_data(); });
335+
return;
336+
}
337+
328338
showStatus('Sending paste...', spin=true);
339+
329340
var randomkey = sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
330341
var cipherdata = zeroCipher(randomkey, $('textarea#message').val());
331342
var data_to_send = { data: cipherdata,

0 commit comments

Comments
 (0)