wallet: start using crypto.cleanse.
This commit is contained in:
parent
9e00fc6360
commit
0d2391be14
@ -121,7 +121,7 @@ Mnemonic.prototype.destroy = function destroy() {
|
||||
this.bits = constants.hd.MIN_ENTROPY;
|
||||
this.language = 'english';
|
||||
if (this.entropy) {
|
||||
this.entropy.fill(0);
|
||||
crypto.cleanse(this.entropy);
|
||||
this.entropy = null;
|
||||
}
|
||||
this.phrase = null;
|
||||
|
||||
@ -155,14 +155,15 @@ HDPrivateKey.prototype.__defineGetter__('xpubkey', function() {
|
||||
|
||||
HDPrivateKey.prototype.destroy = function destroy(pub) {
|
||||
this.depth = 0;
|
||||
this.parentFingerPrint.fill(0);
|
||||
this.childIndex = 0;
|
||||
this.chainCode.fill(0);
|
||||
this.privateKey.fill(0);
|
||||
this.publicKey.fill(0);
|
||||
|
||||
crypto.cleanse(this.parentFingerPrint);
|
||||
crypto.cleanse(this.chainCode);
|
||||
crypto.cleanse(this.privateKey);
|
||||
crypto.cleanse(this.publicKey);
|
||||
|
||||
if (this.fingerPrint) {
|
||||
this.fingerPrint.fill(0);
|
||||
crypto.cleanse(this.fingerPrint);
|
||||
this.fingerPrint = null;
|
||||
}
|
||||
|
||||
|
||||
@ -118,13 +118,14 @@ HDPublicKey.prototype.__defineGetter__('xpubkey', function() {
|
||||
|
||||
HDPublicKey.prototype.destroy = function destroy() {
|
||||
this.depth = 0;
|
||||
this.parentFingerPrint.fill(0);
|
||||
this.childIndex = 0;
|
||||
this.chainCode.fill(0);
|
||||
this.publicKey.fill(0);
|
||||
|
||||
crypto.cleanse(this.parentFingerPrint);
|
||||
crypto.cleanse(this.chainCode);
|
||||
crypto.cleanse(this.publicKey);
|
||||
|
||||
if (this.fingerPrint) {
|
||||
this.fingerPrint.fill(0);
|
||||
crypto.cleanse(this.fingerPrint);
|
||||
this.fingerPrint = null;
|
||||
}
|
||||
|
||||
|
||||
@ -315,7 +315,7 @@ MasterKey.prototype._lock = function lock() {
|
||||
}
|
||||
|
||||
if (this.aesKey) {
|
||||
this.aesKey.fill(0);
|
||||
crypto.cleanse(this.aesKey);
|
||||
this.aesKey = null;
|
||||
}
|
||||
};
|
||||
@ -371,7 +371,7 @@ MasterKey.prototype._decrypt = co(function* decrypt(passphrase, aes) {
|
||||
this.ciphertext = null;
|
||||
|
||||
if (!aes) {
|
||||
key.fill(0);
|
||||
crypto.cleanse(key);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -423,7 +423,7 @@ MasterKey.prototype._encrypt = co(function* encrypt(passphrase, aes) {
|
||||
this.ciphertext = data;
|
||||
|
||||
if (!aes) {
|
||||
key.fill(0);
|
||||
crypto.cleanse(key);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -405,12 +405,12 @@ Wallet.prototype._encrypt = co(function* encrypt(passphrase) {
|
||||
try {
|
||||
yield this.db.encryptKeys(this, key);
|
||||
} catch (e) {
|
||||
key.fill(0);
|
||||
crypto.cleanse(key);
|
||||
this.drop();
|
||||
throw e;
|
||||
}
|
||||
|
||||
key.fill(0);
|
||||
crypto.cleanse(key);
|
||||
|
||||
this.save();
|
||||
|
||||
@ -447,12 +447,12 @@ Wallet.prototype._decrypt = co(function* decrypt(passphrase) {
|
||||
try {
|
||||
yield this.db.decryptKeys(this, key);
|
||||
} catch (e) {
|
||||
key.fill(0);
|
||||
crypto.cleanse(key);
|
||||
this.drop();
|
||||
throw e;
|
||||
}
|
||||
|
||||
key.fill(0);
|
||||
crypto.cleanse(key);
|
||||
|
||||
this.save();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user