Commit 0981fb39 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Use 256 bits of window.crypto to initialize sjcl.random

parent 87f1e4dd
...@@ -5,12 +5,12 @@ function init_prng () { ...@@ -5,12 +5,12 @@ function init_prng () {
// Seed from window.crypto if present // Seed from window.crypto if present
var cryptoObj = window.crypto || window.msCrypto; // for IE 11 var cryptoObj = window.crypto || window.msCrypto; // for IE 11
if (cryptoObj) { if (cryptoObj) {
var bytes = new Uint32Array(4); var n = 8;
var bytes = new Uint32Array(n);
cryptoObj.getRandomValues(bytes); cryptoObj.getRandomValues(bytes);
sjcl.random.addEntropy(bytes[0], 32); for (var i = 0; i < n; i++) {
sjcl.random.addEntropy(bytes[1], 32); sjcl.random.addEntropy(bytes[i], 32);
sjcl.random.addEntropy(bytes[2], 32); }
sjcl.random.addEntropy(bytes[3], 32);
if (console) { if (console) {
console.log("PRNG successfully initialized using crypto object"); console.log("PRNG successfully initialized using crypto object");
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment