1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

memory stored pinProtectedKey

This commit is contained in:
Kyle Spearrin 2019-08-29 10:01:59 -04:00
parent 8ebed21017
commit a519ed2580
3 changed files with 10 additions and 10 deletions

2
jslib

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

View File

@ -149,16 +149,17 @@ export class SettingsComponent implements OnInit {
masterPassOnRestart = (document.getElementById('master-pass-restart') as HTMLInputElement).checked; masterPassOnRestart = (document.getElementById('master-pass-restart') as HTMLInputElement).checked;
} }
if (pin != null && pin.trim() !== '') { 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) { if (masterPassOnRestart) {
const encPin = await this.cryptoService.encrypt(pin); const encPin = await this.cryptoService.encrypt(pin);
await this.storageService.save(ConstantsService.protectedPin, encPin.encryptedString); await this.storageService.save(ConstantsService.protectedPin, encPin.encryptedString);
this.lockService.pinProtectedKey = pinProtectedKey;
} else { } 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); await this.storageService.save(ConstantsService.pinProtectedKey, pinProtectedKey.encryptedString);
} }
} else { } else {
@ -166,8 +167,8 @@ export class SettingsComponent implements OnInit {
} }
} }
if (!this.pin) { if (!this.pin) {
await this.storageService.remove(ConstantsService.pinProtectedKey); await this.cryptoService.clearPinProtectedKey();
await this.storageService.remove(ConstantsService.protectedPin); await this.lockService.clear();
} }
} }

View File

@ -228,7 +228,6 @@ export class AppComponent implements OnInit {
this.stateService.purge(), this.stateService.purge(),
]); ]);
this.lockService.pinLocked = false;
this.searchService.clearIndex(); this.searchService.clearIndex();
this.authService.logOut(async () => { this.authService.logOut(async () => {
this.analytics.eventTrack.next({ action: 'Logged Out' }); this.analytics.eventTrack.next({ action: 'Logged Out' });