From 5b6c8c3480e594c160e434f5674617be5aecac69 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 5 Jun 2017 16:01:29 -0400 Subject: [PATCH] clear private key from memory only when locked --- src/services/cryptoService.js | 11 ++++++++--- src/services/lockService.js | 7 +++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/services/cryptoService.js b/src/services/cryptoService.js index ba25834e73..3d0e94abc5 100644 --- a/src/services/cryptoService.js +++ b/src/services/cryptoService.js @@ -285,13 +285,18 @@ function initCryptoService(constantsService) { return deferred.promise; }; - CryptoService.prototype.clearPrivateKey = function () { + CryptoService.prototype.clearPrivateKey = function (memoryOnly) { var deferred = Q.defer(); _privateKey = null; - chrome.storage.local.remove('encPrivateKey', function () { + if (memoryOnly) { deferred.resolve(); - }); + } + else { + chrome.storage.local.remove('encPrivateKey', function () { + deferred.resolve(); + }); + } return deferred.promise; }; diff --git a/src/services/lockService.js b/src/services/lockService.js index bdfe06458a..e87101d3f8 100644 --- a/src/services/lockService.js +++ b/src/services/lockService.js @@ -68,8 +68,11 @@ function initLockService(self) { } LockService.prototype.lock = function () { - Q.all([self.cryptoService.clearKey(), self.cryptoService.clearOrgKeys(true)]).then(function () { - self.cryptoService.clearPrivateKey(); + Q.all([ + self.cryptoService.clearKey(), + self.cryptoService.clearOrgKeys(true), + self.cryptoService.clearPrivateKey(true) + ]).then(function () { self.setIcon(); self.folderService.clearCache(); self.loginService.clearCache();