1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

wombat: override window.crypto.getRandomValues() with seeded random

This commit is contained in:
Ilya Kreymer 2016-03-20 18:50:45 -07:00
parent 8e90ea6576
commit 08cb02c644

View File

@ -678,6 +678,20 @@ var wombat_internal = function($wbwindow) {
Math.random = seeded_random;
}
function init_crypto_random() {
var orig_getrandom = $wbwindow.Crypto.prototype.getRandomValues;
var new_getrandom = function(array) {
for (i = 0; i < array.length; i++) {
array[i] = parseInt(Math.random() * 65535);
}
return array;
}
$wbwindow.Crypto.prototype.getRandomValues = new_getrandom;
$wbwindow.crypto.getRandomValues = new_getrandom;
}
//============================================
function override_history_func(func_name) {
if (!$wbwindow.history) {
@ -2177,6 +2191,9 @@ var wombat_internal = function($wbwindow) {
// Random
init_seeded_random(wbinfo.wombat_sec);
// Crypto Random
init_crypto_random();
// Date
init_date_override(wbinfo.wombat_sec);