summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2014-06-21 08:50:00 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2014-06-21 09:20:16 (UTC)
commit6dd16d9359e3a4dc306802588b09acd43947a606 (patch) (unidiff)
treef3ab7778e037e42cb47c810f9d435d40de5adf15 /frontend/beta/js/Clipperz
parenta6852c93138f3c4596fb4df8bce5b7d19ef50478 (diff)
downloadclipperz-6dd16d9359e3a4dc306802588b09acd43947a606.zip
clipperz-6dd16d9359e3a4dc306802588b09acd43947a606.tar.gz
clipperz-6dd16d9359e3a4dc306802588b09acd43947a606.tar.bz2
Inproved PRNG configuration
Diffstat (limited to 'frontend/beta/js/Clipperz') (more/less context) (show whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/Crypto/PRNG.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/frontend/beta/js/Clipperz/Crypto/PRNG.js b/frontend/beta/js/Clipperz/Crypto/PRNG.js
index 92966d0..6fdeca4 100644
--- a/frontend/beta/js/Clipperz/Crypto/PRNG.js
+++ b/frontend/beta/js/Clipperz/Crypto/PRNG.js
@@ -271,99 +271,99 @@ Clipperz.Crypto.PRNG.MouseRandomnessSource.prototype = MochiKit.Base.update(new
271 271
272 mask = 0xffffffff >>> (32 - this.numberOfBitsToCollectAtEachEvent()); 272 mask = 0xffffffff >>> (32 - this.numberOfBitsToCollectAtEachEvent());
273 273
274 mouseLocation = anEvent.mouse().client; 274 mouseLocation = anEvent.mouse().client;
275 randomBit = ((mouseLocation.x ^ mouseLocation.y) & mask); 275 randomBit = ((mouseLocation.x ^ mouseLocation.y) & mask);
276 this.appendRandomBitsToRandomBitsCollector(randomBit) 276 this.appendRandomBitsToRandomBitsCollector(randomBit)
277 }, 277 },
278 278
279 //------------------------------------------------------------------------- 279 //-------------------------------------------------------------------------
280 280
281 'numberOfRandomBits': function() { 281 'numberOfRandomBits': function() {
282 return 1; 282 return 1;
283 }, 283 },
284 284
285 //------------------------------------------------------------------------- 285 //-------------------------------------------------------------------------
286 __syntaxFix__: "syntax fix" 286 __syntaxFix__: "syntax fix"
287}); 287});
288 288
289//***************************************************************************** 289//*****************************************************************************
290 290
291Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource = function(args) { 291Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource = function(args) {
292 args = args || {}; 292 args = args || {};
293 293
294 this._intervalTime = args.intervalTime || 1000; 294 this._intervalTime = args.intervalTime || 1000;
295 this._browserCrypto = args.browserCrypto; 295 this._browserCrypto = args.browserCrypto;
296 296
297 Clipperz.Crypto.PRNG.RandomnessSource.call(this, args); 297 Clipperz.Crypto.PRNG.RandomnessSource.call(this, args);
298 298
299 this.collectEntropy(); 299 this.collectEntropy();
300 return this; 300 return this;
301} 301}
302 302
303Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, { 303Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, {
304 304
305 'intervalTime': function() { 305 'intervalTime': function() {
306 return this._intervalTime; 306 return this._intervalTime;
307 }, 307 },
308 308
309 'browserCrypto': function () { 309 'browserCrypto': function () {
310 return this._browserCrypto; 310 return this._browserCrypto;
311 }, 311 },
312 312
313 //------------------------------------------------------------------------- 313 //-------------------------------------------------------------------------
314 314
315 'collectEntropy': function() { 315 'collectEntropy': function() {
316 varbytesToCollect; 316 varbytesToCollect;
317 317
318 if (this.boostMode() == true) { 318 if (this.boostMode() == true) {
319 bytesToCollect = 8; 319 bytesToCollect = 64;
320 } else { 320 } else {
321 bytesToCollect = 32; 321 bytesToCollect = 8;
322 } 322 }
323 323
324 var randomValuesArray = new Uint8Array(bytesToCollect); 324 var randomValuesArray = new Uint8Array(bytesToCollect);
325 this.browserCrypto().getRandomValues(randomValuesArray); 325 this.browserCrypto().getRandomValues(randomValuesArray);
326 for (var i = 0; i < randomValuesArray.length; i++) { 326 for (var i = 0; i < randomValuesArray.length; i++) {
327 this.updateGeneratorWithValue(randomValuesArray[i]); 327 this.updateGeneratorWithValue(randomValuesArray[i]);
328 } 328 }
329 329
330 setTimeout(this.collectEntropy, this.intervalTime()); 330 setTimeout(this.collectEntropy, this.intervalTime());
331 }, 331 },
332 332
333 //------------------------------------------------------------------------- 333 //-------------------------------------------------------------------------
334 __syntaxFix__: "syntax fix" 334 __syntaxFix__: "syntax fix"
335}); 335});
336 336
337//############################################################################# 337//#############################################################################
338 338
339Clipperz.Crypto.PRNG.Fortuna = function(args) { 339Clipperz.Crypto.PRNG.Fortuna = function(args) {
340 vari,c; 340 vari,c;
341 341
342 args = args || {}; 342 args = args || {};
343 343
344 this._key = args.seed || null; 344 this._key = args.seed || null;
345 if (this._key == null) { 345 if (this._key == null) {
346 this._counter = 0; 346 this._counter = 0;
347 this._key = new Clipperz.ByteArray(); 347 this._key = new Clipperz.ByteArray();
348 } else { 348 } else {
349 this._counter = 1; 349 this._counter = 1;
350 } 350 }
351 351
352 this._aesKey = null; 352 this._aesKey = null;
353 353
354 this._firstPoolReseedLevel = args.firstPoolReseedLevel || 32 || 64; 354 this._firstPoolReseedLevel = args.firstPoolReseedLevel || 32 || 64;
355 this._numberOfEntropyAccumulators = args.numberOfEntropyAccumulators || 32; 355 this._numberOfEntropyAccumulators = args.numberOfEntropyAccumulators || 32;
356 356
357 this._accumulators = []; 357 this._accumulators = [];
358 c = this.numberOfEntropyAccumulators(); 358 c = this.numberOfEntropyAccumulators();
359 for (i=0; i<c; i++) { 359 for (i=0; i<c; i++) {
360 this._accumulators.push(new Clipperz.Crypto.PRNG.EntropyAccumulator()); 360 this._accumulators.push(new Clipperz.Crypto.PRNG.EntropyAccumulator());
361 } 361 }
362 362
363 this._randomnessSources = []; 363 this._randomnessSources = [];
364 this._reseedCounter = 0; 364 this._reseedCounter = 0;
365 365
366 return this; 366 return this;
367} 367}
368 368
369Clipperz.Crypto.PRNG.Fortuna.prototype = MochiKit.Base.update(null, { 369Clipperz.Crypto.PRNG.Fortuna.prototype = MochiKit.Base.update(null, {