-rw-r--r-- | frontend/beta/js/Clipperz/Crypto/PRNG.js | 4 | ||||
-rw-r--r-- | frontend/delta/js/Clipperz/Crypto/PRNG.js | 4 | ||||
-rw-r--r-- | frontend/gamma/js/Clipperz/Crypto/PRNG.js | 4 |
3 files changed, 6 insertions, 6 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 | |||
@@ -255,131 +255,131 @@ Clipperz.Crypto.PRNG.MouseRandomnessSource.prototype = MochiKit.Base.update(new | |||
255 | //------------------------------------------------------------------------- | 255 | //------------------------------------------------------------------------- |
256 | 256 | ||
257 | 'numberOfRandomBitsCollected': function() { | 257 | 'numberOfRandomBitsCollected': function() { |
258 | return this._numberOfRandomBitsCollected; | 258 | return this._numberOfRandomBitsCollected; |
259 | }, | 259 | }, |
260 | 260 | ||
261 | 'setNumberOfRandomBitsCollected': function(aValue) { | 261 | 'setNumberOfRandomBitsCollected': function(aValue) { |
262 | this._numberOfRandomBitsCollected = aValue; | 262 | this._numberOfRandomBitsCollected = aValue; |
263 | }, | 263 | }, |
264 | 264 | ||
265 | //------------------------------------------------------------------------- | 265 | //------------------------------------------------------------------------- |
266 | 266 | ||
267 | 'collectEntropy': function(anEvent) { | 267 | 'collectEntropy': function(anEvent) { |
268 | var mouseLocation; | 268 | var mouseLocation; |
269 | var randomBit; | 269 | var randomBit; |
270 | var mask; | 270 | var mask; |
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 | ||
291 | Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource = function(args) { | 291 | Clipperz.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 | ||
303 | Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, { | 303 | Clipperz.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 | ||
339 | Clipperz.Crypto.PRNG.Fortuna = function(args) { | 339 | Clipperz.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 | ||
369 | Clipperz.Crypto.PRNG.Fortuna.prototype = MochiKit.Base.update(null, { | 369 | Clipperz.Crypto.PRNG.Fortuna.prototype = MochiKit.Base.update(null, { |
370 | 370 | ||
371 | 'toString': function() { | 371 | 'toString': function() { |
372 | return "Clipperz.Crypto.PRNG.Fortuna"; | 372 | return "Clipperz.Crypto.PRNG.Fortuna"; |
373 | }, | 373 | }, |
374 | 374 | ||
375 | //------------------------------------------------------------------------- | 375 | //------------------------------------------------------------------------- |
376 | 376 | ||
377 | 'key': function() { | 377 | 'key': function() { |
378 | return this._key; | 378 | return this._key; |
379 | }, | 379 | }, |
380 | 380 | ||
381 | 'setKey': function(aValue) { | 381 | 'setKey': function(aValue) { |
382 | this._key = aValue; | 382 | this._key = aValue; |
383 | this._aesKey = null; | 383 | this._aesKey = null; |
384 | }, | 384 | }, |
385 | 385 | ||
diff --git a/frontend/delta/js/Clipperz/Crypto/PRNG.js b/frontend/delta/js/Clipperz/Crypto/PRNG.js index 7885429..80d972f 100644 --- a/frontend/delta/js/Clipperz/Crypto/PRNG.js +++ b/frontend/delta/js/Clipperz/Crypto/PRNG.js | |||
@@ -257,131 +257,131 @@ Clipperz.Crypto.PRNG.MouseRandomnessSource.prototype = MochiKit.Base.update(new | |||
257 | //------------------------------------------------------------------------- | 257 | //------------------------------------------------------------------------- |
258 | 258 | ||
259 | 'numberOfRandomBitsCollected': function() { | 259 | 'numberOfRandomBitsCollected': function() { |
260 | return this._numberOfRandomBitsCollected; | 260 | return this._numberOfRandomBitsCollected; |
261 | }, | 261 | }, |
262 | 262 | ||
263 | 'setNumberOfRandomBitsCollected': function(aValue) { | 263 | 'setNumberOfRandomBitsCollected': function(aValue) { |
264 | this._numberOfRandomBitsCollected = aValue; | 264 | this._numberOfRandomBitsCollected = aValue; |
265 | }, | 265 | }, |
266 | 266 | ||
267 | //------------------------------------------------------------------------- | 267 | //------------------------------------------------------------------------- |
268 | 268 | ||
269 | 'collectEntropy': function(anEvent) { | 269 | 'collectEntropy': function(anEvent) { |
270 | var mouseLocation; | 270 | var mouseLocation; |
271 | var randomBit; | 271 | var randomBit; |
272 | var mask; | 272 | var mask; |
273 | 273 | ||
274 | mask = 0xffffffff >>> (32 - this.numberOfBitsToCollectAtEachEvent()); | 274 | mask = 0xffffffff >>> (32 - this.numberOfBitsToCollectAtEachEvent()); |
275 | 275 | ||
276 | mouseLocation = anEvent.mouse().client; | 276 | mouseLocation = anEvent.mouse().client; |
277 | randomBit = ((mouseLocation.x ^ mouseLocation.y) & mask); | 277 | randomBit = ((mouseLocation.x ^ mouseLocation.y) & mask); |
278 | this.appendRandomBitsToRandomBitsCollector(randomBit) | 278 | this.appendRandomBitsToRandomBitsCollector(randomBit) |
279 | }, | 279 | }, |
280 | 280 | ||
281 | //------------------------------------------------------------------------- | 281 | //------------------------------------------------------------------------- |
282 | 282 | ||
283 | 'numberOfRandomBits': function() { | 283 | 'numberOfRandomBits': function() { |
284 | return 1; | 284 | return 1; |
285 | }, | 285 | }, |
286 | 286 | ||
287 | //------------------------------------------------------------------------- | 287 | //------------------------------------------------------------------------- |
288 | __syntaxFix__: "syntax fix" | 288 | __syntaxFix__: "syntax fix" |
289 | }); | 289 | }); |
290 | 290 | ||
291 | //***************************************************************************** | 291 | //***************************************************************************** |
292 | 292 | ||
293 | Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource = function(args) { | 293 | Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource = function(args) { |
294 | args = args || {}; | 294 | args = args || {}; |
295 | 295 | ||
296 | this._intervalTime = args.intervalTime || 1000; | 296 | this._intervalTime = args.intervalTime || 1000; |
297 | this._browserCrypto = args.browserCrypto; | 297 | this._browserCrypto = args.browserCrypto; |
298 | 298 | ||
299 | Clipperz.Crypto.PRNG.RandomnessSource.call(this, args); | 299 | Clipperz.Crypto.PRNG.RandomnessSource.call(this, args); |
300 | 300 | ||
301 | this.collectEntropy(); | 301 | this.collectEntropy(); |
302 | return this; | 302 | return this; |
303 | } | 303 | } |
304 | 304 | ||
305 | Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, { | 305 | Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, { |
306 | 306 | ||
307 | 'intervalTime': function() { | 307 | 'intervalTime': function() { |
308 | return this._intervalTime; | 308 | return this._intervalTime; |
309 | }, | 309 | }, |
310 | 310 | ||
311 | 'browserCrypto': function () { | 311 | 'browserCrypto': function () { |
312 | return this._browserCrypto; | 312 | return this._browserCrypto; |
313 | }, | 313 | }, |
314 | 314 | ||
315 | //------------------------------------------------------------------------- | 315 | //------------------------------------------------------------------------- |
316 | 316 | ||
317 | 'collectEntropy': function() { | 317 | 'collectEntropy': function() { |
318 | varbytesToCollect; | 318 | varbytesToCollect; |
319 | 319 | ||
320 | if (this.boostMode() == true) { | 320 | if (this.boostMode() == true) { |
321 | bytesToCollect = 8; | 321 | bytesToCollect = 64; |
322 | } else { | 322 | } else { |
323 | bytesToCollect = 32; | 323 | bytesToCollect = 8; |
324 | } | 324 | } |
325 | 325 | ||
326 | var randomValuesArray = new Uint8Array(bytesToCollect); | 326 | var randomValuesArray = new Uint8Array(bytesToCollect); |
327 | this.browserCrypto().getRandomValues(randomValuesArray); | 327 | this.browserCrypto().getRandomValues(randomValuesArray); |
328 | for (var i = 0; i < randomValuesArray.length; i++) { | 328 | for (var i = 0; i < randomValuesArray.length; i++) { |
329 | this.updateGeneratorWithValue(randomValuesArray[i]); | 329 | this.updateGeneratorWithValue(randomValuesArray[i]); |
330 | } | 330 | } |
331 | 331 | ||
332 | setTimeout(this.collectEntropy, this.intervalTime()); | 332 | setTimeout(this.collectEntropy, this.intervalTime()); |
333 | }, | 333 | }, |
334 | 334 | ||
335 | //------------------------------------------------------------------------- | 335 | //------------------------------------------------------------------------- |
336 | __syntaxFix__: "syntax fix" | 336 | __syntaxFix__: "syntax fix" |
337 | }); | 337 | }); |
338 | 338 | ||
339 | //############################################################################# | 339 | //############################################################################# |
340 | 340 | ||
341 | Clipperz.Crypto.PRNG.Fortuna = function(args) { | 341 | Clipperz.Crypto.PRNG.Fortuna = function(args) { |
342 | vari,c; | 342 | vari,c; |
343 | 343 | ||
344 | args = args || {}; | 344 | args = args || {}; |
345 | 345 | ||
346 | this._key = args.seed || null; | 346 | this._key = args.seed || null; |
347 | if (this._key == null) { | 347 | if (this._key == null) { |
348 | this._counter = 0; | 348 | this._counter = 0; |
349 | this._key = new Clipperz.ByteArray(); | 349 | this._key = new Clipperz.ByteArray(); |
350 | } else { | 350 | } else { |
351 | this._counter = 1; | 351 | this._counter = 1; |
352 | } | 352 | } |
353 | 353 | ||
354 | this._aesKey = null; | 354 | this._aesKey = null; |
355 | 355 | ||
356 | this._firstPoolReseedLevel = args.firstPoolReseedLevel || 32 || 64; | 356 | this._firstPoolReseedLevel = args.firstPoolReseedLevel || 32 || 64; |
357 | this._numberOfEntropyAccumulators = args.numberOfEntropyAccumulators || 32; | 357 | this._numberOfEntropyAccumulators = args.numberOfEntropyAccumulators || 32; |
358 | 358 | ||
359 | this._accumulators = []; | 359 | this._accumulators = []; |
360 | c = this.numberOfEntropyAccumulators(); | 360 | c = this.numberOfEntropyAccumulators(); |
361 | for (i=0; i<c; i++) { | 361 | for (i=0; i<c; i++) { |
362 | this._accumulators.push(new Clipperz.Crypto.PRNG.EntropyAccumulator()); | 362 | this._accumulators.push(new Clipperz.Crypto.PRNG.EntropyAccumulator()); |
363 | } | 363 | } |
364 | 364 | ||
365 | this._randomnessSources = []; | 365 | this._randomnessSources = []; |
366 | this._reseedCounter = 0; | 366 | this._reseedCounter = 0; |
367 | 367 | ||
368 | return this; | 368 | return this; |
369 | } | 369 | } |
370 | 370 | ||
371 | Clipperz.Crypto.PRNG.Fortuna.prototype = MochiKit.Base.update(null, { | 371 | Clipperz.Crypto.PRNG.Fortuna.prototype = MochiKit.Base.update(null, { |
372 | 372 | ||
373 | 'toString': function() { | 373 | 'toString': function() { |
374 | return "Clipperz.Crypto.PRNG.Fortuna"; | 374 | return "Clipperz.Crypto.PRNG.Fortuna"; |
375 | }, | 375 | }, |
376 | 376 | ||
377 | //------------------------------------------------------------------------- | 377 | //------------------------------------------------------------------------- |
378 | 378 | ||
379 | 'key': function() { | 379 | 'key': function() { |
380 | return this._key; | 380 | return this._key; |
381 | }, | 381 | }, |
382 | 382 | ||
383 | 'setKey': function(aValue) { | 383 | 'setKey': function(aValue) { |
384 | this._key = aValue; | 384 | this._key = aValue; |
385 | this._aesKey = null; | 385 | this._aesKey = null; |
386 | }, | 386 | }, |
387 | 387 | ||
diff --git a/frontend/gamma/js/Clipperz/Crypto/PRNG.js b/frontend/gamma/js/Clipperz/Crypto/PRNG.js index 7885429..80d972f 100644 --- a/frontend/gamma/js/Clipperz/Crypto/PRNG.js +++ b/frontend/gamma/js/Clipperz/Crypto/PRNG.js | |||
@@ -257,131 +257,131 @@ Clipperz.Crypto.PRNG.MouseRandomnessSource.prototype = MochiKit.Base.update(new | |||
257 | //------------------------------------------------------------------------- | 257 | //------------------------------------------------------------------------- |
258 | 258 | ||
259 | 'numberOfRandomBitsCollected': function() { | 259 | 'numberOfRandomBitsCollected': function() { |
260 | return this._numberOfRandomBitsCollected; | 260 | return this._numberOfRandomBitsCollected; |
261 | }, | 261 | }, |
262 | 262 | ||
263 | 'setNumberOfRandomBitsCollected': function(aValue) { | 263 | 'setNumberOfRandomBitsCollected': function(aValue) { |
264 | this._numberOfRandomBitsCollected = aValue; | 264 | this._numberOfRandomBitsCollected = aValue; |
265 | }, | 265 | }, |
266 | 266 | ||
267 | //------------------------------------------------------------------------- | 267 | //------------------------------------------------------------------------- |
268 | 268 | ||
269 | 'collectEntropy': function(anEvent) { | 269 | 'collectEntropy': function(anEvent) { |
270 | var mouseLocation; | 270 | var mouseLocation; |
271 | var randomBit; | 271 | var randomBit; |
272 | var mask; | 272 | var mask; |
273 | 273 | ||
274 | mask = 0xffffffff >>> (32 - this.numberOfBitsToCollectAtEachEvent()); | 274 | mask = 0xffffffff >>> (32 - this.numberOfBitsToCollectAtEachEvent()); |
275 | 275 | ||
276 | mouseLocation = anEvent.mouse().client; | 276 | mouseLocation = anEvent.mouse().client; |
277 | randomBit = ((mouseLocation.x ^ mouseLocation.y) & mask); | 277 | randomBit = ((mouseLocation.x ^ mouseLocation.y) & mask); |
278 | this.appendRandomBitsToRandomBitsCollector(randomBit) | 278 | this.appendRandomBitsToRandomBitsCollector(randomBit) |
279 | }, | 279 | }, |
280 | 280 | ||
281 | //------------------------------------------------------------------------- | 281 | //------------------------------------------------------------------------- |
282 | 282 | ||
283 | 'numberOfRandomBits': function() { | 283 | 'numberOfRandomBits': function() { |
284 | return 1; | 284 | return 1; |
285 | }, | 285 | }, |
286 | 286 | ||
287 | //------------------------------------------------------------------------- | 287 | //------------------------------------------------------------------------- |
288 | __syntaxFix__: "syntax fix" | 288 | __syntaxFix__: "syntax fix" |
289 | }); | 289 | }); |
290 | 290 | ||
291 | //***************************************************************************** | 291 | //***************************************************************************** |
292 | 292 | ||
293 | Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource = function(args) { | 293 | Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource = function(args) { |
294 | args = args || {}; | 294 | args = args || {}; |
295 | 295 | ||
296 | this._intervalTime = args.intervalTime || 1000; | 296 | this._intervalTime = args.intervalTime || 1000; |
297 | this._browserCrypto = args.browserCrypto; | 297 | this._browserCrypto = args.browserCrypto; |
298 | 298 | ||
299 | Clipperz.Crypto.PRNG.RandomnessSource.call(this, args); | 299 | Clipperz.Crypto.PRNG.RandomnessSource.call(this, args); |
300 | 300 | ||
301 | this.collectEntropy(); | 301 | this.collectEntropy(); |
302 | return this; | 302 | return this; |
303 | } | 303 | } |
304 | 304 | ||
305 | Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, { | 305 | Clipperz.Crypto.PRNG.CryptoRandomRandomnessSource.prototype = MochiKit.Base.update(new Clipperz.Crypto.PRNG.RandomnessSource, { |
306 | 306 | ||
307 | 'intervalTime': function() { | 307 | 'intervalTime': function() { |
308 | return this._intervalTime; | 308 | return this._intervalTime; |
309 | }, | 309 | }, |
310 | 310 | ||
311 | 'browserCrypto': function () { | 311 | 'browserCrypto': function () { |
312 | return this._browserCrypto; | 312 | return this._browserCrypto; |
313 | }, | 313 | }, |
314 | 314 | ||
315 | //------------------------------------------------------------------------- | 315 | //------------------------------------------------------------------------- |
316 | 316 | ||
317 | 'collectEntropy': function() { | 317 | 'collectEntropy': function() { |
318 | varbytesToCollect; | 318 | varbytesToCollect; |
319 | 319 | ||
320 | if (this.boostMode() == true) { | 320 | if (this.boostMode() == true) { |
321 | bytesToCollect = 8; | 321 | bytesToCollect = 64; |
322 | } else { | 322 | } else { |
323 | bytesToCollect = 32; | 323 | bytesToCollect = 8; |
324 | } | 324 | } |
325 | 325 | ||
326 | var randomValuesArray = new Uint8Array(bytesToCollect); | 326 | var randomValuesArray = new Uint8Array(bytesToCollect); |
327 | this.browserCrypto().getRandomValues(randomValuesArray); | 327 | this.browserCrypto().getRandomValues(randomValuesArray); |
328 | for (var i = 0; i < randomValuesArray.length; i++) { | 328 | for (var i = 0; i < randomValuesArray.length; i++) { |
329 | this.updateGeneratorWithValue(randomValuesArray[i]); | 329 | this.updateGeneratorWithValue(randomValuesArray[i]); |
330 | } | 330 | } |
331 | 331 | ||
332 | setTimeout(this.collectEntropy, this.intervalTime()); | 332 | setTimeout(this.collectEntropy, this.intervalTime()); |
333 | }, | 333 | }, |
334 | 334 | ||
335 | //------------------------------------------------------------------------- | 335 | //------------------------------------------------------------------------- |
336 | __syntaxFix__: "syntax fix" | 336 | __syntaxFix__: "syntax fix" |
337 | }); | 337 | }); |
338 | 338 | ||
339 | //############################################################################# | 339 | //############################################################################# |
340 | 340 | ||
341 | Clipperz.Crypto.PRNG.Fortuna = function(args) { | 341 | Clipperz.Crypto.PRNG.Fortuna = function(args) { |
342 | vari,c; | 342 | vari,c; |
343 | 343 | ||
344 | args = args || {}; | 344 | args = args || {}; |
345 | 345 | ||
346 | this._key = args.seed || null; | 346 | this._key = args.seed || null; |
347 | if (this._key == null) { | 347 | if (this._key == null) { |
348 | this._counter = 0; | 348 | this._counter = 0; |
349 | this._key = new Clipperz.ByteArray(); | 349 | this._key = new Clipperz.ByteArray(); |
350 | } else { | 350 | } else { |
351 | this._counter = 1; | 351 | this._counter = 1; |
352 | } | 352 | } |
353 | 353 | ||
354 | this._aesKey = null; | 354 | this._aesKey = null; |
355 | 355 | ||
356 | this._firstPoolReseedLevel = args.firstPoolReseedLevel || 32 || 64; | 356 | this._firstPoolReseedLevel = args.firstPoolReseedLevel || 32 || 64; |
357 | this._numberOfEntropyAccumulators = args.numberOfEntropyAccumulators || 32; | 357 | this._numberOfEntropyAccumulators = args.numberOfEntropyAccumulators || 32; |
358 | 358 | ||
359 | this._accumulators = []; | 359 | this._accumulators = []; |
360 | c = this.numberOfEntropyAccumulators(); | 360 | c = this.numberOfEntropyAccumulators(); |
361 | for (i=0; i<c; i++) { | 361 | for (i=0; i<c; i++) { |
362 | this._accumulators.push(new Clipperz.Crypto.PRNG.EntropyAccumulator()); | 362 | this._accumulators.push(new Clipperz.Crypto.PRNG.EntropyAccumulator()); |
363 | } | 363 | } |
364 | 364 | ||
365 | this._randomnessSources = []; | 365 | this._randomnessSources = []; |
366 | this._reseedCounter = 0; | 366 | this._reseedCounter = 0; |
367 | 367 | ||
368 | return this; | 368 | return this; |
369 | } | 369 | } |
370 | 370 | ||
371 | Clipperz.Crypto.PRNG.Fortuna.prototype = MochiKit.Base.update(null, { | 371 | Clipperz.Crypto.PRNG.Fortuna.prototype = MochiKit.Base.update(null, { |
372 | 372 | ||
373 | 'toString': function() { | 373 | 'toString': function() { |
374 | return "Clipperz.Crypto.PRNG.Fortuna"; | 374 | return "Clipperz.Crypto.PRNG.Fortuna"; |
375 | }, | 375 | }, |
376 | 376 | ||
377 | //------------------------------------------------------------------------- | 377 | //------------------------------------------------------------------------- |
378 | 378 | ||
379 | 'key': function() { | 379 | 'key': function() { |
380 | return this._key; | 380 | return this._key; |
381 | }, | 381 | }, |
382 | 382 | ||
383 | 'setKey': function(aValue) { | 383 | 'setKey': function(aValue) { |
384 | this._key = aValue; | 384 | this._key = aValue; |
385 | this._aesKey = null; | 385 | this._aesKey = null; |
386 | }, | 386 | }, |
387 | 387 | ||