1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 02:03:39 +00:00

support for unlocking with PIN code

This commit is contained in:
Kyle Spearrin
2019-02-12 23:52:50 -05:00
parent 647b254a71
commit 7a1e7b5474
6 changed files with 72 additions and 8 deletions

View File

@@ -266,6 +266,10 @@ export class CryptoService implements CryptoServiceAbstraction {
return this.storageService.remove(Keys.encOrgKeys);
}
clearPinProtectedKey(): Promise<any> {
return this.storageService.remove(ConstantsService.pinProtectedKey);
}
clearKeys(): Promise<any> {
return Promise.all([
this.clearKey(),
@@ -273,6 +277,7 @@ export class CryptoService implements CryptoServiceAbstraction {
this.clearOrgKeys(),
this.clearEncKey(),
this.clearKeyPair(),
this.clearPinProtectedKey(),
]);
}
@@ -319,6 +324,11 @@ export class CryptoService implements CryptoServiceAbstraction {
return [publicB64, privateEnc];
}
async makePinKey(pin: string, salt: string): Promise<SymmetricCryptoKey> {
const pinKey = await this.makeKey(pin, salt, KdfType.PBKDF2_SHA256, 100000);
return await this.stretchKey(pinKey);
}
async hashPassword(password: string, key: SymmetricCryptoKey): Promise<string> {
if (key == null) {
key = await this.getKey();