1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-03-11 13:30:39 +01:00

clean up the old pin keys in more flows

- in the case that the app is updated while logged in and the user changes their pin, this will clear the old pin keys
This commit is contained in:
Jacob Fink 2023-06-08 12:25:43 -04:00
parent 62c43794e9
commit 7963d3c996
No known key found for this signature in database
GPG Key ID: C2F7ACF05859D008
3 changed files with 8 additions and 3 deletions

View File

@ -50,6 +50,7 @@ export class SetPinComponent implements OnInit {
} else {
await this.stateService.setUserSymKeyPin(pinProtectedKey);
}
await this.cryptoService.clearOldPinKeys();
this.modalRef.close(true);
}

View File

@ -73,7 +73,8 @@ export abstract class CryptoService {
makeKeyPair: (key?: SymmetricCryptoKey) => Promise<[string, EncString]>;
clearKeyPair: (memoryOnly?: boolean, userId?: string) => Promise<void[]>;
makePinKey: (pin: string, salt: string, kdf: KdfType, kdfConfig: KdfConfig) => Promise<PinKey>;
clearPinProtectedKey: () => Promise<void>;
clearPinProtectedKey: (userId?: string) => Promise<void>;
clearOldPinKeys: (userId?: string) => Promise<void>;
/**
* Decrypts the user's symmetric key with their pin
* @param pin The user's PIN

View File

@ -676,7 +676,12 @@ export class CryptoService implements CryptoServiceAbstraction {
*/
async clearPinProtectedKey(userId?: string): Promise<void> {
await this.stateService.setUserSymKeyPin(null, { userId: userId });
await this.clearOldPinKeys(userId);
}
async clearOldPinKeys(userId?: string): Promise<void> {
await this.stateService.setEncryptedPinProtected(null, { userId: userId });
await this.stateService.setDecryptedPinProtected(null, { userId: userId });
}
async decryptUserSymKeyWithPin(
@ -889,7 +894,6 @@ export class CryptoService implements CryptoServiceAbstraction {
await this.stateService.setUserSymKeyAuto(key.keyB64, { userId: userId });
} else {
await this.stateService.setUserSymKeyAuto(null, { userId: userId });
await this.stateService.setCryptoMasterKeyAuto(null, { userId: userId });
}
const storePin = await this.shouldStoreKey(KeySuffixOptions.Pin, userId);
@ -897,7 +901,6 @@ export class CryptoService implements CryptoServiceAbstraction {
await this.storePinKey(key);
} else {
await this.stateService.setUserSymKeyPin(null, { userId: userId });
await this.stateService.setEncryptedPinProtected(null, { userId: userId });
}
}