memory stored pinProtectedKey

This commit is contained in:
Kyle Spearrin 2019-08-29 09:41:04 -04:00
parent 530d0d2594
commit eb0bc6a01c
3 changed files with 10 additions and 10 deletions

2
jslib

@ -1 +1 @@
Subproject commit 99d56d936fdebc99994ce5089e8f063729a2e0ec
Subproject commit b74ee7b3ee823a820854623cc32c8522a09e9f4d

View File

@ -307,7 +307,6 @@ export default class MainBackground {
this.lockService.clear(),
]);
this.lockService.pinLocked = false;
this.searchService.clearIndex();
this.messagingService.send('doneLoggingOut', { expired: expired });

View File

@ -142,16 +142,17 @@ export class SettingsComponent implements OnInit {
masterPassOnRestart = (document.getElementById('master-pass-restart') as HTMLInputElement).checked;
}
if (pin != null && pin.trim() !== '') {
const kdf = await this.userService.getKdf();
const kdfIterations = await this.userService.getKdfIterations();
const email = await this.userService.getEmail();
const pinKey = await this.cryptoService.makePinKey(pin, email, kdf, kdfIterations);
const key = await this.cryptoService.getKey();
const pinProtectedKey = await this.cryptoService.encrypt(key.key, pinKey);
if (masterPassOnRestart) {
const encPin = await this.cryptoService.encrypt(pin);
await this.storageService.save(ConstantsService.protectedPin, encPin.encryptedString);
this.lockService.pinProtectedKey = pinProtectedKey;
} else {
const kdf = await this.userService.getKdf();
const kdfIterations = await this.userService.getKdfIterations();
const email = await this.userService.getEmail();
const pinKey = await this.cryptoService.makePinKey(pin, email, kdf, kdfIterations);
const key = await this.cryptoService.getKey();
const pinProtectedKey = await this.cryptoService.encrypt(key.key, pinKey);
await this.storageService.save(ConstantsService.pinProtectedKey, pinProtectedKey.encryptedString);
}
} else {
@ -159,8 +160,8 @@ export class SettingsComponent implements OnInit {
}
}
if (!this.pin) {
await this.storageService.remove(ConstantsService.pinProtectedKey);
await this.storageService.remove(ConstantsService.protectedPin);
await this.cryptoService.clearPinProtectedKey();
await this.lockService.clear();
}
}