Varialbe name changes.
This commit is contained in:
parent
60732f8243
commit
b5e6ac7db9
@ -8,31 +8,31 @@ var utils = require('./utils.js');
|
|||||||
function Randomish() {
|
function Randomish() {
|
||||||
if (!(this instanceof Randomish)) { throw new Error('missing new'); }
|
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', {
|
Object.defineProperty(this, 'entropy', {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
get: function() { return bits; }
|
get: function() { return entropyBits; }
|
||||||
});
|
});
|
||||||
|
|
||||||
var weak = !!(randomBytes._weakCrypto);
|
|
||||||
|
|
||||||
var entropy = new aes.ModeOfOperation.cbc(
|
var entropy = new aes.ModeOfOperation.cbc(
|
||||||
Randomish.randomishBytes(32),
|
Randomish.randomishBytes(32),
|
||||||
Randomish.randomishBytes(16)
|
Randomish.randomishBytes(16)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!weak) { bits += (32 + 16) * 8; }
|
utils.defineProperty(this, 'feedEntropy', function(data, expectedEntropyBits) {
|
||||||
|
|
||||||
utils.defineProperty(this, 'feedEntropy', function(data, expectedBits) {
|
|
||||||
if (!data) { data = ''; }
|
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();
|
data = (new Date()).getTime() + '-' + JSON.stringify(data) + '-' + data.toString();
|
||||||
var hashed = utils.sha3(new Buffer(data, 'utf8'));
|
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
|
// Feed the hashed data and random data to the mode of operation
|
||||||
entropy.encrypt(hashed.slice(0, 16));
|
entropy.encrypt(hashed.slice(0, 16));
|
||||||
|
Loading…
Reference in New Issue
Block a user