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