1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

makeEncKey to use UInt8Array

This commit is contained in:
Kyle Spearrin 2017-08-04 15:29:23 -04:00
parent 8947cafa4e
commit 3ee9b1bba1
2 changed files with 14 additions and 13 deletions

View File

@ -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;
}
});

View File

@ -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');
};