From d9930978ba7a54da2d4cdc0c8303007df96c4c5f Mon Sep 17 00:00:00 2001 From: Sebastien SAUVAGE Date: Sun, 24 Feb 2013 21:59:10 +0100 Subject: [PATCH] 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. (cherry picked from commit c6e98045aa833dff824f892eb3392744c03a59f7) --- js/zerobin.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/zerobin.js b/js/zerobin.js index 96ed235..8e5fe73 100644 --- a/js/zerobin.js +++ b/js/zerobin.js @@ -161,7 +161,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,"\n
")); } @@ -306,6 +306,7 @@ function send_comment(parentid) { }); } + /** * Send a new paste to server */ @@ -314,7 +315,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,