Varialbe name changes.

This commit is contained in:
ricmoo 2016-07-27 03:02:30 -04:00
parent 60732f8243
commit b5e6ac7db9

@ -8,31 +8,31 @@ var utils = require('./utils.js');
function Randomish() {
if (!(this instanceof Randomish)) { throw new Error('missing new'); }
var bits = 0;
var weak = (randomBytes._weakCrypto || false);
var entropyBits = (weak ? 0: ((32 + 16) * 8));
Object.defineProperty(this, 'entropy', {
enumerable: true,
get: function() { return bits; }
get: function() { return entropyBits; }
});
var weak = !!(randomBytes._weakCrypto);
var entropy = new aes.ModeOfOperation.cbc(
Randomish.randomishBytes(32),
Randomish.randomishBytes(16)
);
if (!weak) { bits += (32 + 16) * 8; }
utils.defineProperty(this, 'feedEntropy', function(data, expectedBits) {
utils.defineProperty(this, 'feedEntropy', function(data, expectedEntropyBits) {
if (!data) { data = ''; }
if (!expectedBits) { expectedBits = 0; }
if (!expectedEntropyBits) { expectedEntropyBits = 0; }
if (parseInt(expectedBits) != expectedBits) { throw new Error('invalid expectedBits'); }
if (parseInt(expectedEntropyBits) != expectedBits) {
throw new Error('invalid expectedBits');
}
data = (new Date()).getTime() + '-' + JSON.stringify(data) + '-' + data.toString();
var hashed = utils.sha3(new Buffer(data, 'utf8'));
bits += expectedBits + (weak ? 0: ((32) * 8));
entropyBits += expectedEntropyBits + (weak ? 0: ((32) * 8));
// Feed the hashed data and random data to the mode of operation
entropy.encrypt(hashed.slice(0, 16));