summaryrefslogtreecommitdiff
path: root/frontend/beta
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2014-06-19 10:32:07 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2014-06-19 10:51:21 (UTC)
commita6852c93138f3c4596fb4df8bce5b7d19ef50478 (patch) (unidiff)
tree6a8cfda52d54ae8990a0c51447980d06408ac6cc /frontend/beta
parent0422224521f62da210d1ae6ee15ecdf09f47f1f8 (diff)
downloadclipperz-a6852c93138f3c4596fb4df8bce5b7d19ef50478.zip
clipperz-a6852c93138f3c4596fb4df8bce5b7d19ef50478.tar.gz
clipperz-a6852c93138f3c4596fb4df8bce5b7d19ef50478.tar.bz2
Mitigation for vulnerability CLP-01-018
Diffstat (limited to 'frontend/beta') (more/less context) (show whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/Crypto/PRNG.js126
1 files changed, 41 insertions, 85 deletions
diff --git a/frontend/beta/js/Clipperz/Crypto/PRNG.js b/frontend/beta/js/Clipperz/Crypto/PRNG.js
index b5c3f8a..92966d0 100644
--- a/frontend/beta/js/Clipperz/Crypto/PRNG.js
+++ b/frontend/beta/js/Clipperz/Crypto/PRNG.js
@@ -176,227 +176,179 @@ Clipperz.Crypto.PRNG.TimeRandomnessSource.prototype = MochiKit.Base.update(new C
176 176
177 'collectEntropy': function() { 177 'collectEntropy': function() {
178 varnow; 178 varnow;
179 varentropyByte; 179 varentropyByte;
180 var intervalTime; 180 var intervalTime;
181 now = new Date(); 181 now = new Date();
182 entropyByte = (now.getTime() & 0xff); 182 entropyByte = (now.getTime() & 0xff);
183 183
184 intervalTime = this.intervalTime(); 184 intervalTime = this.intervalTime();
185 if (this.boostMode() == true) { 185 if (this.boostMode() == true) {
186 intervalTime = intervalTime / 9; 186 intervalTime = intervalTime / 9;
187 } 187 }
188 188
189 this.updateGeneratorWithValue(entropyByte); 189 this.updateGeneratorWithValue(entropyByte);
190 setTimeout(this.collectEntropy, intervalTime); 190 setTimeout(this.collectEntropy, intervalTime);
191 }, 191 },
192 192
193 //------------------------------------------------------------------------- 193 //-------------------------------------------------------------------------
194 194
195 'numberOfRandomBits': function() { 195 'numberOfRandomBits': function() {
196 return 5; 196 return 5;
197 }, 197 },
198 198
199 //------------------------------------------------------------------------- 199 //-------------------------------------------------------------------------
200
201 'pollingFrequency': function() {
202 return 10;
203 },
204
205 //-------------------------------------------------------------------------
206 __syntaxFix__: "syntax fix" 200 __syntaxFix__: "syntax fix"
207}); 201});
208 202
209//***************************************************************************** 203//*****************************************************************************
210 204
211Clipperz.Crypto.PRNG.MouseRandomnessSource = function(args) { 205Clipperz.Crypto.PRNG.MouseRandomnessSource = function(args) {
212 args = args || {}; 206 args = args || {};
213 207
214 Clipperz.Crypto.PRNG.RandomnessSource.call(this, args); 208 Clipperz.Crypto.PRNG.RandomnessSource.call(this, args);
215 209
216 this._numberOfBitsToCollectAtEachEvent = 4; 210 this._numberOfBitsToCollectAtEachEvent = 4;
217 this._randomBitsCollector = 0; 211 this._randomBitsCollector = 0;
218 this._numberOfRandomBitsCollected = 0; 212 this._numberOfRandomBitsCollected = 0;
219 213
220 MochiKit.Signal.connect(document, 'onmousemove', this, 'collectEntropy'); 214 MochiKit.Signal.connect(document, 'onmousemove', this, 'collectEntropy');
221 215
222 return this; 216 return this;
223} 217}
224 218
225Clipperz.Crypto.PRNG.MouseRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, { 219Clipperz.Crypto.PRNG.MouseRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, {
226 220
227 //------------------------------------------------------------------------- 221 //-------------------------------------------------------------------------
228 222
229 'numberOfBitsToCollectAtEachEvent': function() { 223 'numberOfBitsToCollectAtEachEvent': function() {
230 return this._numberOfBitsToCollectAtEachEvent; 224 return this._numberOfBitsToCollectAtEachEvent;
231 }, 225 },
232 226
233 //------------------------------------------------------------------------- 227 //-------------------------------------------------------------------------
234 228
235 'randomBitsCollector': function() { 229 'randomBitsCollector': function() {
236 return this._randomBitsCollector; 230 return this._randomBitsCollector;
237 }, 231 },
238 232
239 'setRandomBitsCollector': function(aValue) { 233 'setRandomBitsCollector': function(aValue) {
240 this._randomBitsCollector = aValue; 234 this._randomBitsCollector = aValue;
241 }, 235 },
242 236
243 'appendRandomBitsToRandomBitsCollector': function(aValue) { 237 'appendRandomBitsToRandomBitsCollector': function(aValue) {
244 var collectedBits; 238 var collectedBits;
245 var numberOfRandomBitsCollected; 239 var numberOfRandomBitsCollected;
246 240
247 numberOfRandomBitsCollected = this.numberOfRandomBitsCollected(); 241 numberOfRandomBitsCollected = this.numberOfRandomBitsCollected();
248 collectetBits = this.randomBitsCollector() | (aValue << numberOfRandomBitsCollected); 242 collectedBits = this.randomBitsCollector() | (aValue << numberOfRandomBitsCollected);
249 this.setRandomBitsCollector(collectetBits); 243 this.setRandomBitsCollector(collectedBits);
250 numberOfRandomBitsCollected += this.numberOfBitsToCollectAtEachEvent(); 244 numberOfRandomBitsCollected += this.numberOfBitsToCollectAtEachEvent();
251 245
252 if (numberOfRandomBitsCollected == 8) { 246 if (numberOfRandomBitsCollected == 8) {
253 this.updateGeneratorWithValue(collectetBits); 247 this.updateGeneratorWithValue(collectedBits);
254 numberOfRandomBitsCollected = 0; 248 numberOfRandomBitsCollected = 0;
255 this.setRandomBitsCollector(0); 249 this.setRandomBitsCollector(0);
256 } 250 }
257 251
258 this.setNumberOfRandomBitsCollected(numberOfRandomBitsCollected) 252 this.setNumberOfRandomBitsCollected(numberOfRandomBitsCollected)
259 }, 253 },
260 254
261 //------------------------------------------------------------------------- 255 //-------------------------------------------------------------------------
262 256
263 'numberOfRandomBitsCollected': function() { 257 'numberOfRandomBitsCollected': function() {
264 return this._numberOfRandomBitsCollected; 258 return this._numberOfRandomBitsCollected;
265 }, 259 },
266 260
267 'setNumberOfRandomBitsCollected': function(aValue) { 261 'setNumberOfRandomBitsCollected': function(aValue) {
268 this._numberOfRandomBitsCollected = aValue; 262 this._numberOfRandomBitsCollected = aValue;
269 }, 263 },
270 264
271 //------------------------------------------------------------------------- 265 //-------------------------------------------------------------------------
272 266
273 'collectEntropy': function(anEvent) { 267 'collectEntropy': function(anEvent) {
274 var mouseLocation; 268 var mouseLocation;
275 var randomBit; 269 var randomBit;
276 var mask; 270 var mask;
277 271
278 mask = 0xffffffff >>> (32 - this.numberOfBitsToCollectAtEachEvent()); 272 mask = 0xffffffff >>> (32 - this.numberOfBitsToCollectAtEachEvent());
279 273
280 mouseLocation = anEvent.mouse().client; 274 mouseLocation = anEvent.mouse().client;
281 randomBit = ((mouseLocation.x ^ mouseLocation.y) & mask); 275 randomBit = ((mouseLocation.x ^ mouseLocation.y) & mask);
282 this.appendRandomBitsToRandomBitsCollector(randomBit) 276 this.appendRandomBitsToRandomBitsCollector(randomBit)
283 }, 277 },
284 278
285 //------------------------------------------------------------------------- 279 //-------------------------------------------------------------------------
286 280
287 'numberOfRandomBits': function() { 281 'numberOfRandomBits': function() {
288 return 1; 282 return 1;
289 }, 283 },
290 284
291 //------------------------------------------------------------------------- 285 //-------------------------------------------------------------------------
292
293 'pollingFrequency': function() {
294 return 10;
295 },
296
297 //-------------------------------------------------------------------------
298 __syntaxFix__: "syntax fix" 286 __syntaxFix__: "syntax fix"
299}); 287});
300 288
301//***************************************************************************** 289//*****************************************************************************
302 290
303Clipperz.Crypto.PRNG.KeyboardRandomnessSource = function(args) { 291Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource = function(args) {
304 args = args || {}; 292 args = args || {};
305 Clipperz.Crypto.PRNG.RandomnessSource.call(this, args);
306 293
307 this._randomBitsCollector = 0; 294 this._intervalTime = args.intervalTime || 1000;
308 this._numberOfRandomBitsCollected = 0; 295 this._browserCrypto = args.browserCrypto;
309 296
310 MochiKit.Signal.connect(document, 'onkeypress', this, 'collectEntropy'); 297 Clipperz.Crypto.PRNG.RandomnessSource.call(this, args);
311 298
299 this.collectEntropy();
312 return this; 300 return this;
313} 301}
314 302
315Clipperz.Crypto.PRNG.KeyboardRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, { 303Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, {
316
317 //-------------------------------------------------------------------------
318
319 'randomBitsCollector': function() {
320 return this._randomBitsCollector;
321 },
322
323 'setRandomBitsCollector': function(aValue) {
324 this._randomBitsCollector = aValue;
325 },
326
327 'appendRandomBitToRandomBitsCollector': function(aValue) {
328 var collectedBits;
329 var numberOfRandomBitsCollected;
330
331 numberOfRandomBitsCollected = this.numberOfRandomBitsCollected();
332 collectetBits = this.randomBitsCollector() | (aValue << numberOfRandomBitsCollected);
333 this.setRandomBitsCollector(collectetBits);
334 numberOfRandomBitsCollected ++;
335
336 if (numberOfRandomBitsCollected == 8) {
337 this.updateGeneratorWithValue(collectetBits);
338 numberOfRandomBitsCollected = 0;
339 this.setRandomBitsCollector(0);
340 }
341
342 this.setNumberOfRandomBitsCollected(numberOfRandomBitsCollected)
343 },
344
345 //-------------------------------------------------------------------------
346 304
347 'numberOfRandomBitsCollected': function() { 305 'intervalTime': function() {
348 return this._numberOfRandomBitsCollected; 306 return this._intervalTime;
349 }, 307 },
350 308
351 'setNumberOfRandomBitsCollected': function(aValue) { 309 'browserCrypto': function () {
352 this._numberOfRandomBitsCollected = aValue; 310 return this._browserCrypto;
353 }, 311 },
354 312
355 //------------------------------------------------------------------------- 313 //-------------------------------------------------------------------------
356 314
357 'collectEntropy': function(anEvent) { 315 'collectEntropy': function() {
358/* 316 varbytesToCollect;
359 var mouseLocation;
360 var randomBit;
361
362 mouseLocation = anEvent.mouse().client;
363
364 randomBit = ((mouseLocation.x ^ mouseLocation.y) & 0x1);
365 this.appendRandomBitToRandomBitsCollector(randomBit);
366*/
367 },
368
369 //-------------------------------------------------------------------------
370 317
371 'numberOfRandomBits': function() { 318 if (this.boostMode() == true) {
372 return 1; 319 bytesToCollect = 8;
373 }, 320 } else {
321 bytesToCollect = 32;
322 }
374 323
375 //------------------------------------------------------------------------- 324 var randomValuesArray = new Uint8Array(bytesToCollect);
325 this.browserCrypto().getRandomValues(randomValuesArray);
326 for (var i = 0; i < randomValuesArray.length; i++) {
327 this.updateGeneratorWithValue(randomValuesArray[i]);
328 }
376 329
377 'pollingFrequency': function() { 330 setTimeout(this.collectEntropy, this.intervalTime());
378 return 10;
379 }, 331 },
380 332
381 //------------------------------------------------------------------------- 333 //-------------------------------------------------------------------------
382 __syntaxFix__: "syntax fix" 334 __syntaxFix__: "syntax fix"
383}); 335});
384 336
385//############################################################################# 337//#############################################################################
386 338
387Clipperz.Crypto.PRNG.Fortuna = function(args) { 339Clipperz.Crypto.PRNG.Fortuna = function(args) {
388 vari,c; 340 vari,c;
389 341
390 args = args || {}; 342 args = args || {};
391 343
392 this._key = args.seed || null; 344 this._key = args.seed || null;
393 if (this._key == null) { 345 if (this._key == null) {
394 this._counter = 0; 346 this._counter = 0;
395 this._key = new Clipperz.ByteArray(); 347 this._key = new Clipperz.ByteArray();
396 } else { 348 } else {
397 this._counter = 1; 349 this._counter = 1;
398 } 350 }
399 351
400 this._aesKey = null; 352 this._aesKey = null;
401 353
402 this._firstPoolReseedLevel = args.firstPoolReseedLevel || 32 || 64; 354 this._firstPoolReseedLevel = args.firstPoolReseedLevel || 32 || 64;
@@ -586,85 +538,79 @@ MochiKit.Logging.logWarning("Fortuna generator has not enough entropy, yet!");
586 return this._numberOfEntropyAccumulators; 538 return this._numberOfEntropyAccumulators;
587 }, 539 },
588 540
589 //------------------------------------------------------------------------- 541 //-------------------------------------------------------------------------
590 542
591 'randomnessSources': function() { 543 'randomnessSources': function() {
592 return this._randomnessSources; 544 return this._randomnessSources;
593 }, 545 },
594 546
595 'addRandomnessSource': function(aRandomnessSource) { 547 'addRandomnessSource': function(aRandomnessSource) {
596 aRandomnessSource.setGenerator(this); 548 aRandomnessSource.setGenerator(this);
597 aRandomnessSource.setSourceId(this.randomnessSources().length); 549 aRandomnessSource.setSourceId(this.randomnessSources().length);
598 this.randomnessSources().push(aRandomnessSource); 550 this.randomnessSources().push(aRandomnessSource);
599 551
600 if (this.isReadyToGenerateRandomValues() == false) { 552 if (this.isReadyToGenerateRandomValues() == false) {
601 aRandomnessSource.setBoostMode(true); 553 aRandomnessSource.setBoostMode(true);
602 } 554 }
603 }, 555 },
604 556
605 //------------------------------------------------------------------------- 557 //-------------------------------------------------------------------------
606 558
607 'deferredEntropyCollection': function(aValue) { 559 'deferredEntropyCollection': function(aValue) {
608 var result; 560 var result;
609 561
610//MochiKit.Logging.logDebug(">>> PRNG.deferredEntropyCollection");
611 562
612 if (this.isReadyToGenerateRandomValues()) { 563 if (this.isReadyToGenerateRandomValues()) {
613//MochiKit.Logging.logDebug("--- PRNG.deferredEntropyCollection - 1");
614 result = aValue; 564 result = aValue;
615 } else { 565 } else {
616//MochiKit.Logging.logDebug("--- PRNG.deferredEntropyCollection - 2");
617 var deferredResult; 566 var deferredResult;
618 567
619 Clipperz.NotificationCenter.notify(this, 'updatedProgressState', 'collectingEntropy', true); 568 Clipperz.NotificationCenter.notify(this, 'updatedProgressState', 'collectingEntropy', true);
620 569
621 deferredResult = new MochiKit.Async.Deferred(); 570 deferredResult = new MochiKit.Async.Deferred();
622 // deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.1 - PRNG.deferredEntropyCollection - 1: " + res); return res;});
623 deferredResult.addCallback(MochiKit.Base.partial(MochiKit.Async.succeed, aValue)); 571 deferredResult.addCallback(MochiKit.Base.partial(MochiKit.Async.succeed, aValue));
624 // deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.2.2 - PRNG.deferredEntropyCollection - 2: " + res); return res;});
625 MochiKit.Signal.connect(this, 572 MochiKit.Signal.connect(this,
626 'readyToGenerateRandomBytes', 573 'readyToGenerateRandomBytes',
627 deferredResult, 574 deferredResult,
628 'callback'); 575 'callback');
629 576
630 result = deferredResult; 577 result = deferredResult;
631 } 578 }
632//MochiKit.Logging.logDebug("<<< PRNG.deferredEntropyCollection - result: " + result);
633 579
634 return result; 580 return result;
635 }, 581 },
636 582
637 //------------------------------------------------------------------------- 583 //-------------------------------------------------------------------------
638 584
639 'fastEntropyAccumulationForTestingPurpose': function() { 585 'fastEntropyAccumulationForTestingPurpose': function() {
640 while (! this.isReadyToGenerateRandomValues()) { 586 while (! this.isReadyToGenerateRandomValues()) {
641 this.addRandomByte(Math.floor(Math.random() * 32), Math.floor(Math.random() * 32), Math.floor(Math.random() * 256)); 587 this.addRandomByte(Math.floor(Math.random() * 32), Math.floor(Math.random() * 32), Math.floor(Math.random() * 256));
642 } 588 }
643 }, 589 },
644 590
645 //------------------------------------------------------------------------- 591 //-------------------------------------------------------------------------
646 592/*
647 'dump': function(appendToDoc) { 593 'dump': function(appendToDoc) {
648 var tbl; 594 var tbl;
649 var i,c; 595 var i,c;
650 596
651 tbl = document.createElement("table"); 597 tbl = document.createElement("table");
652 tbl.border = 0; 598 tbl.border = 0;
653 with (tbl.style) { 599 with (tbl.style) {
654 border = "1px solid lightgrey"; 600 border = "1px solid lightgrey";
655 fontFamily = 'Helvetica, Arial, sans-serif'; 601 fontFamily = 'Helvetica, Arial, sans-serif';
656 fontSize = '8pt'; 602 fontSize = '8pt';
657 //borderCollapse = "collapse"; 603 //borderCollapse = "collapse";
658 } 604 }
659 var hdr = tbl.createTHead(); 605 var hdr = tbl.createTHead();
660 var hdrtr = hdr.insertRow(0); 606 var hdrtr = hdr.insertRow(0);
661 // document.createElement("tr"); 607 // document.createElement("tr");
662 { 608 {
663 var ntd; 609 var ntd;
664 610
665 ntd = hdrtr.insertCell(0); 611 ntd = hdrtr.insertCell(0);
666 ntd.style.borderBottom = "1px solid lightgrey"; 612 ntd.style.borderBottom = "1px solid lightgrey";
667 ntd.style.borderRight = "1px solid lightgrey"; 613 ntd.style.borderRight = "1px solid lightgrey";
668 ntd.appendChild(document.createTextNode("#")); 614 ntd.appendChild(document.createTextNode("#"));
669 615
670 ntd = hdrtr.insertCell(1); 616 ntd = hdrtr.insertCell(1);
@@ -728,49 +674,49 @@ MochiKit.Logging.logWarning("Fortuna generator has not enough entropy, yet!");
728 674
729 } 675 }
730 676
731 677
732 if (appendToDoc) { 678 if (appendToDoc) {
733 var ne = document.createElement("div"); 679 var ne = document.createElement("div");
734 ne.id = "entropyGeneratorStatus"; 680 ne.id = "entropyGeneratorStatus";
735 with (ne.style) { 681 with (ne.style) {
736 fontFamily = "Courier New, monospace"; 682 fontFamily = "Courier New, monospace";
737 fontSize = "12px"; 683 fontSize = "12px";
738 lineHeight = "16px"; 684 lineHeight = "16px";
739 borderTop = "1px solid black"; 685 borderTop = "1px solid black";
740 padding = "10px"; 686 padding = "10px";
741 } 687 }
742 if (document.getElementById(ne.id)) { 688 if (document.getElementById(ne.id)) {
743 MochiKit.DOM.swapDOM(ne.id, ne); 689 MochiKit.DOM.swapDOM(ne.id, ne);
744 } else { 690 } else {
745 document.body.appendChild(ne); 691 document.body.appendChild(ne);
746 } 692 }
747 ne.appendChild(tbl); 693 ne.appendChild(tbl);
748 } 694 }
749 695
750 return tbl; 696 return tbl;
751 }, 697 },
752 698*/
753 //----------------------------------------------------------------------------- 699 //-----------------------------------------------------------------------------
754 __syntaxFix__: "syntax fix" 700 __syntaxFix__: "syntax fix"
755}); 701});
756 702
757//############################################################################# 703//#############################################################################
758 704
759Clipperz.Crypto.PRNG.Random = function(args) { 705Clipperz.Crypto.PRNG.Random = function(args) {
760 args = args || {}; 706 args = args || {};
761 //MochiKit.Base.bindMethods(this); 707 //MochiKit.Base.bindMethods(this);
762 708
763 return this; 709 return this;
764} 710}
765 711
766Clipperz.Crypto.PRNG.Random.prototype = MochiKit.Base.update(null, { 712Clipperz.Crypto.PRNG.Random.prototype = MochiKit.Base.update(null, {
767 713
768 'toString': function() { 714 'toString': function() {
769 return "Clipperz.Crypto.PRNG.Random"; 715 return "Clipperz.Crypto.PRNG.Random";
770 }, 716 },
771 717
772 //------------------------------------------------------------------------- 718 //-------------------------------------------------------------------------
773 719
774 'getRandomBytes': function(aSize) { 720 'getRandomBytes': function(aSize) {
775//Clipperz.Profile.start("Clipperz.Crypto.PRNG.Random.getRandomBytes"); 721//Clipperz.Profile.start("Clipperz.Crypto.PRNG.Random.getRandomBytes");
776 varresult; 722 varresult;
@@ -803,47 +749,57 @@ Clipperz.Crypto.PRNG.defaultRandomGenerator = function() {
803 // TimeRandomnessSource 749 // TimeRandomnessSource
804 // 750 //
805 //............................................................. 751 //.............................................................
806 { 752 {
807 var newRandomnessSource; 753 var newRandomnessSource;
808 754
809 newRandomnessSource = new Clipperz.Crypto.PRNG.TimeRandomnessSource({intervalTime:111}); 755 newRandomnessSource = new Clipperz.Crypto.PRNG.TimeRandomnessSource({intervalTime:111});
810 _clipperz_crypt_prng_defaultPRNG.addRandomnessSource(newRandomnessSource); 756 _clipperz_crypt_prng_defaultPRNG.addRandomnessSource(newRandomnessSource);
811 } 757 }
812 758
813 //............................................................. 759 //.............................................................
814 // 760 //
815 // MouseRandomnessSource 761 // MouseRandomnessSource
816 // 762 //
817 //............................................................. 763 //.............................................................
818 { 764 {
819 varnewRandomnessSource; 765 varnewRandomnessSource;
820 766
821 newRandomnessSource = new Clipperz.Crypto.PRNG.MouseRandomnessSource(); 767 newRandomnessSource = new Clipperz.Crypto.PRNG.MouseRandomnessSource();
822 _clipperz_crypt_prng_defaultPRNG.addRandomnessSource(newRandomnessSource); 768 _clipperz_crypt_prng_defaultPRNG.addRandomnessSource(newRandomnessSource);
823 } 769 }
824 770
825 //............................................................. 771 //.............................................................
826 // 772 //
827 // KeyboardRandomnessSource 773 // CryptoRandomRandomnessSource
828 // 774 //
829 //............................................................. 775 //.............................................................
830 { 776 {
831 varnewRandomnessSource; 777 varnewRandomnessSource;
778 varbrowserCrypto;
832 779
833 newRandomnessSource = new Clipperz.Crypto.PRNG.KeyboardRandomnessSource(); 780 if (window.crypto && window.crypto.getRandomValues) {
834 _clipperz_crypt_prng_defaultPRNG.addRandomnessSource(newRandomnessSource); 781 browserCrypto = window.crypto;
782 } else if (window.msCrypto && window.msCrypto.getRandomValues) {
783 browserCrypto = window.msCrypto;
784 } else {
785 browserCrypto = null;
835 } 786 }
836 787
788 if (browserCrypto != null) {
789 newRandomnessSource = new Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource({'browserCrypto':browserCrypto});
790 _clipperz_crypt_prng_defaultPRNG.addRandomnessSource(newRandomnessSource);
791 }
792 }
837 } 793 }
838 794
839 return _clipperz_crypt_prng_defaultPRNG; 795 return _clipperz_crypt_prng_defaultPRNG;
840}; 796};
841 797
842//############################################################################# 798//#############################################################################
843 799
844Clipperz.Crypto.PRNG.exception = { 800Clipperz.Crypto.PRNG.exception = {
845 NotEnoughEntropy: new MochiKit.Base.NamedError("Clipperz.Crypto.PRNG.exception.NotEnoughEntropy") 801 NotEnoughEntropy: new MochiKit.Base.NamedError("Clipperz.Crypto.PRNG.exception.NotEnoughEntropy")
846}; 802};
847 803
848 804
849MochiKit.DOM.addLoadEvent(Clipperz.Crypto.PRNG.defaultRandomGenerator); 805MochiKit.DOM.addLoadEvent(Clipperz.Crypto.PRNG.defaultRandomGenerator);