From 3ee9b1bba18226ed47e486068c334f9249fbb304 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 4 Aug 2017 15:29:23 -0400 Subject: [PATCH] makeEncKey to use UInt8Array --- .../accounts/accountsRegisterController.js | 24 +++++++++---------- src/services/cryptoService.js | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/popup/app/accounts/accountsRegisterController.js b/src/popup/app/accounts/accountsRegisterController.js index 36de3fa2..71669fdb 100644 --- a/src/popup/app/accounts/accountsRegisterController.js +++ b/src/popup/app/accounts/accountsRegisterController.js @@ -44,19 +44,19 @@ }; function registerPromise(key, masterPassword, email, hint) { - return $q(function (resolve, reject) { - cryptoService.makeEncKey(key).then(function (encKey) { - cryptoService.hashPassword(masterPassword, key, function (hashedPassword) { - var request = new RegisterRequest(email, hashedPassword, hint, encKey.encryptedString); - apiService.postRegister(request, - function () { - resolve(); - }, - function (error) { - reject(error); - }); - }); + var deferred = $q.defer(); + cryptoService.makeEncKey(key).then(function (encKey) { + cryptoService.hashPassword(masterPassword, key, function (hashedPassword) { + var request = new RegisterRequest(email, hashedPassword, hint, encKey.encryptedString); + apiService.postRegister(request, + function () { + deferred.resolve(); + }, + function (error) { + deferred.reject(error); + }); }); }); + return deferred.promise; } }); diff --git a/src/services/cryptoService.js b/src/services/cryptoService.js index 77aac6dc..fb854958 100644 --- a/src/services/cryptoService.js +++ b/src/services/cryptoService.js @@ -399,7 +399,8 @@ function initCryptoService(constantsService) { }; CryptoService.prototype.makeEncKey = function (key) { - var bytes = forge.random.getBytesSync(512 / 8); + var bytes = new Uint8Array(512 / 8); + _crypto.getRandomValues(bytes); return this.encrypt(bytes, key, 'raw'); };