1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-24 12:06:15 +01:00

prelogin kdf info

This commit is contained in:
Kyle Spearrin 2018-08-14 15:14:04 -04:00
parent 662c229de1
commit 147b3ff993
6 changed files with 21 additions and 18 deletions

2
jslib

@ -1 +1 @@
Subproject commit a7bbdf9c9391c8d58fee0231e1d4cfe34af55cdb Subproject commit 9f26f9f37771f8f450b380b4c05ffd5d9164f099

View File

@ -5,6 +5,7 @@ import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2'; import { Angulartics2 } from 'angulartics2';
import { ApiService } from 'jslib/abstractions/api.service'; import { ApiService } from 'jslib/abstractions/api.service';
import { AuthService } from 'jslib/abstractions/auth.service';
import { CryptoService } from 'jslib/abstractions/crypto.service'; import { CryptoService } from 'jslib/abstractions/crypto.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
@ -22,15 +23,15 @@ export class RecoverTwoFactorComponent {
constructor(private router: Router, private apiService: ApiService, constructor(private router: Router, private apiService: ApiService,
private analytics: Angulartics2, private toasterService: ToasterService, private analytics: Angulartics2, private toasterService: ToasterService,
private i18nService: I18nService, private cryptoService: CryptoService) { private i18nService: I18nService, private cryptoService: CryptoService,
} private authService: AuthService) { }
async submit() { async submit() {
try { try {
const request = new TwoFactorRecoveryRequest(); const request = new TwoFactorRecoveryRequest();
request.recoveryCode = this.recoveryCode.replace(/\s/g, '').toLowerCase(); request.recoveryCode = this.recoveryCode.replace(/\s/g, '').toLowerCase();
request.email = this.email.toLowerCase(); request.email = this.email.toLowerCase();
const key = await this.cryptoService.makeKey(this.masterPassword, request.email); const key = await this.authService.makePreloginKey(this.masterPassword, request.email);
request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, key); request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, key);
this.formPromise = this.apiService.postTwoFactorRecover(request); this.formPromise = this.apiService.postTwoFactorRecover(request);
await this.formPromise; await this.formPromise;

View File

@ -8,7 +8,6 @@ import { CryptoService } from 'jslib/abstractions/crypto.service';
import { ExportService } from 'jslib/abstractions/export.service'; import { ExportService } from 'jslib/abstractions/export.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { UserService } from 'jslib/abstractions/user.service';
import { ExportComponent as BaseExportComponent } from '../../tools/export.component'; import { ExportComponent as BaseExportComponent } from '../../tools/export.component';
@ -20,11 +19,10 @@ export class ExportComponent extends BaseExportComponent {
organizationId: string; organizationId: string;
constructor(analytics: Angulartics2, toasterService: ToasterService, constructor(analytics: Angulartics2, toasterService: ToasterService,
cryptoService: CryptoService, userService: UserService, cryptoService: CryptoService, i18nService: I18nService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService, platformUtilsService: PlatformUtilsService, exportService: ExportService,
exportService: ExportService, private route: ActivatedRoute) { private route: ActivatedRoute) {
super(analytics, toasterService, cryptoService, userService, i18nService, platformUtilsService, super(analytics, toasterService, cryptoService, i18nService, platformUtilsService, exportService);
exportService);
} }
ngOnInit() { ngOnInit() {

View File

@ -9,6 +9,7 @@ import { ApiService } from 'jslib/abstractions/api.service';
import { CryptoService } from 'jslib/abstractions/crypto.service'; import { CryptoService } from 'jslib/abstractions/crypto.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { MessagingService } from 'jslib/abstractions/messaging.service'; import { MessagingService } from 'jslib/abstractions/messaging.service';
import { UserService } from 'jslib/abstractions/user.service';
import { EmailRequest } from 'jslib/models/request/emailRequest'; import { EmailRequest } from 'jslib/models/request/emailRequest';
import { EmailTokenRequest } from 'jslib/models/request/emailTokenRequest'; import { EmailTokenRequest } from 'jslib/models/request/emailTokenRequest';
@ -27,7 +28,8 @@ export class ChangeEmailComponent {
constructor(private apiService: ApiService, private i18nService: I18nService, constructor(private apiService: ApiService, private i18nService: I18nService,
private analytics: Angulartics2, private toasterService: ToasterService, private analytics: Angulartics2, private toasterService: ToasterService,
private cryptoService: CryptoService, private messagingService: MessagingService) { } private cryptoService: CryptoService, private messagingService: MessagingService,
private userService: UserService) { }
async submit() { async submit() {
const hasEncKey = await this.cryptoService.hasEncKey(); const hasEncKey = await this.cryptoService.hasEncKey();
@ -51,7 +53,9 @@ export class ChangeEmailComponent {
request.token = this.token; request.token = this.token;
request.newEmail = this.newEmail; request.newEmail = this.newEmail;
request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, null); request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, null);
const newKey = await this.cryptoService.makeKey(this.masterPassword, this.newEmail); const kdf = await this.userService.getKdf();
const kdfIterations = await this.userService.getKdfIterations();
const newKey = await this.cryptoService.makeKey(this.masterPassword, this.newEmail, kdf, kdfIterations);
request.newMasterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, newKey); request.newMasterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, newKey);
const encKey = await this.cryptoService.getEncKey(); const encKey = await this.cryptoService.getEncKey();
const newEncKey = await this.cryptoService.encrypt(encKey.key, newKey); const newEncKey = await this.cryptoService.encrypt(encKey.key, newKey);

View File

@ -54,7 +54,9 @@ export class ChangePasswordComponent {
const request = new PasswordRequest(); const request = new PasswordRequest();
request.masterPasswordHash = await this.cryptoService.hashPassword(this.currentMasterPassword, null); request.masterPasswordHash = await this.cryptoService.hashPassword(this.currentMasterPassword, null);
const email = await this.userService.getEmail(); const email = await this.userService.getEmail();
const newKey = await this.cryptoService.makeKey(this.newMasterPassword, email); const kdf = await this.userService.getKdf();
const kdfIterations = await this.userService.getKdfIterations();
const newKey = await this.cryptoService.makeKey(this.newMasterPassword, email, kdf, kdfIterations);
request.newMasterPasswordHash = await this.cryptoService.hashPassword(this.newMasterPassword, newKey); request.newMasterPasswordHash = await this.cryptoService.hashPassword(this.newMasterPassword, newKey);
const encKey = await this.cryptoService.getEncKey(); const encKey = await this.cryptoService.getEncKey();
const newEncKey = await this.cryptoService.encrypt(encKey.key, newKey); const newEncKey = await this.cryptoService.encrypt(encKey.key, newKey);

View File

@ -7,7 +7,6 @@ import { CryptoService } from 'jslib/abstractions/crypto.service';
import { ExportService } from 'jslib/abstractions/export.service'; import { ExportService } from 'jslib/abstractions/export.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { UserService } from 'jslib/abstractions/user.service';
import { ExportComponent as BaseExportComponent } from 'jslib/angular/components/export.component'; import { ExportComponent as BaseExportComponent } from 'jslib/angular/components/export.component';
@ -17,10 +16,9 @@ import { ExportComponent as BaseExportComponent } from 'jslib/angular/components
}) })
export class ExportComponent extends BaseExportComponent { export class ExportComponent extends BaseExportComponent {
constructor(analytics: Angulartics2, toasterService: ToasterService, constructor(analytics: Angulartics2, toasterService: ToasterService,
cryptoService: CryptoService, userService: UserService, cryptoService: CryptoService, i18nService: I18nService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService, platformUtilsService: PlatformUtilsService, exportService: ExportService) {
exportService: ExportService) { super(analytics, toasterService, cryptoService, i18nService, platformUtilsService,
super(analytics, toasterService, cryptoService, userService, i18nService, platformUtilsService,
exportService, window); exportService, window);
} }