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 { ApiService } from 'jslib/abstractions/api.service';
import { AuthService } from 'jslib/abstractions/auth.service';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
@ -22,15 +23,15 @@ export class RecoverTwoFactorComponent {
constructor(private router: Router, private apiService: ApiService,
private analytics: Angulartics2, private toasterService: ToasterService,
private i18nService: I18nService, private cryptoService: CryptoService) {
}
private i18nService: I18nService, private cryptoService: CryptoService,
private authService: AuthService) { }
async submit() {
try {
const request = new TwoFactorRecoveryRequest();
request.recoveryCode = this.recoveryCode.replace(/\s/g, '').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);
this.formPromise = this.apiService.postTwoFactorRecover(request);
await this.formPromise;

View File

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

View File

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

View File

@ -54,7 +54,9 @@ export class ChangePasswordComponent {
const request = new PasswordRequest();
request.masterPasswordHash = await this.cryptoService.hashPassword(this.currentMasterPassword, null);
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);
const encKey = await this.cryptoService.getEncKey();
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 { I18nService } from 'jslib/abstractions/i18n.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';
@ -17,10 +16,9 @@ import { ExportComponent as BaseExportComponent } from 'jslib/angular/components
})
export class ExportComponent extends BaseExportComponent {
constructor(analytics: Angulartics2, toasterService: ToasterService,
cryptoService: CryptoService, userService: UserService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
exportService: ExportService) {
super(analytics, toasterService, cryptoService, userService, i18nService, platformUtilsService,
cryptoService: CryptoService, i18nService: I18nService,
platformUtilsService: PlatformUtilsService, exportService: ExportService) {
super(analytics, toasterService, cryptoService, i18nService, platformUtilsService,
exportService, window);
}