1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

support for prelogin kdf info

This commit is contained in:
Kyle Spearrin
2018-08-14 15:12:10 -04:00
parent a7bbdf9c93
commit 9f26f9f377
15 changed files with 140 additions and 31 deletions

View File

@@ -10,7 +10,6 @@ import { CryptoService } from '../../abstractions/crypto.service';
import { ExportService } from '../../abstractions/export.service';
import { I18nService } from '../../abstractions/i18n.service';
import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
import { UserService } from '../../abstractions/user.service';
export class ExportComponent {
@Output() onSaved = new EventEmitter();
@@ -20,9 +19,9 @@ export class ExportComponent {
showPassword = false;
constructor(protected analytics: Angulartics2, protected toasterService: ToasterService,
protected cryptoService: CryptoService, protected userService: UserService,
protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
protected exportService: ExportService, protected win: Window) { }
protected cryptoService: CryptoService, protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService, protected exportService: ExportService,
protected win: Window) { }
async submit() {
if (this.masterPassword == null || this.masterPassword === '') {
@@ -31,11 +30,8 @@ export class ExportComponent {
return;
}
const email = await this.userService.getEmail();
const key = await this.cryptoService.makeKey(this.masterPassword, email);
const keyHash = await this.cryptoService.hashPassword(this.masterPassword, key);
const keyHash = await this.cryptoService.hashPassword(this.masterPassword, null);
const storedKeyHash = await this.cryptoService.getKeyHash();
if (storedKeyHash != null && keyHash != null && storedKeyHash === keyHash) {
try {
this.formPromise = this.getExportData();

View File

@@ -28,7 +28,9 @@ export class LockComponent {
}
const email = await this.userService.getEmail();
const key = await this.cryptoService.makeKey(this.masterPassword, email);
const kdf = await this.userService.getKdf();
const kdfIterations = await this.userService.getKdfIterations();
const key = await this.cryptoService.makeKey(this.masterPassword, email, kdf, kdfIterations);
const keyHash = await this.cryptoService.hashPassword(this.masterPassword, key);
const storedKeyHash = await this.cryptoService.getKeyHash();

View File

@@ -12,6 +12,8 @@ import { CryptoService } from '../../abstractions/crypto.service';
import { I18nService } from '../../abstractions/i18n.service';
import { StateService } from '../../abstractions/state.service';
import { KdfType } from '../../enums/kdfType';
export class RegisterComponent {
name: string = '';
email: string = '';
@@ -57,12 +59,14 @@ export class RegisterComponent {
this.name = this.name === '' ? null : this.name;
this.email = this.email.toLowerCase();
const key = await this.cryptoService.makeKey(this.masterPassword, this.email);
const kdf = KdfType.PBKDF2;
const kdfIterations = 5000;
const key = await this.cryptoService.makeKey(this.masterPassword, this.email, kdf, kdfIterations);
const encKey = await this.cryptoService.makeEncKey(key);
const hashedPassword = await this.cryptoService.hashPassword(this.masterPassword, key);
const keys = await this.cryptoService.makeKeyPair(encKey[0]);
const request = new RegisterRequest(this.email, this.name, hashedPassword,
this.hint, encKey[1].encryptedString);
this.hint, encKey[1].encryptedString, kdf, kdfIterations);
request.keys = new KeysRequest(keys[0], keys[1].encryptedString);
const orgInvite = await this.stateService.get<any>('orgInvitation');
if (orgInvite != null && orgInvite.token != null && orgInvite.organizationUserId != null) {