mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
update emergency access components to use new crypto service methods
This commit is contained in:
@@ -17,7 +17,10 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
|
|||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import {
|
||||||
|
SymmetricCryptoKey,
|
||||||
|
UserSymKey,
|
||||||
|
} from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
|
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -91,9 +94,9 @@ export class EmergencyAccessTakeoverComponent
|
|||||||
);
|
);
|
||||||
|
|
||||||
const oldKeyBuffer = await this.cryptoService.rsaDecrypt(takeoverResponse.keyEncrypted);
|
const oldKeyBuffer = await this.cryptoService.rsaDecrypt(takeoverResponse.keyEncrypted);
|
||||||
const oldEncKey = new SymmetricCryptoKey(oldKeyBuffer);
|
const oldUserSymKey = new SymmetricCryptoKey(oldKeyBuffer) as UserSymKey;
|
||||||
|
|
||||||
if (oldEncKey == null) {
|
if (oldUserSymKey == null) {
|
||||||
this.platformUtilsService.showToast(
|
this.platformUtilsService.showToast(
|
||||||
"error",
|
"error",
|
||||||
this.i18nService.t("errorOccurred"),
|
this.i18nService.t("errorOccurred"),
|
||||||
@@ -102,7 +105,7 @@ export class EmergencyAccessTakeoverComponent
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const key = await this.cryptoService.makeKey(
|
const masterKey = await this.cryptoService.makeMasterKey(
|
||||||
this.masterPassword,
|
this.masterPassword,
|
||||||
this.email,
|
this.email,
|
||||||
takeoverResponse.kdf,
|
takeoverResponse.kdf,
|
||||||
@@ -112,9 +115,15 @@ export class EmergencyAccessTakeoverComponent
|
|||||||
takeoverResponse.kdfParallelism
|
takeoverResponse.kdfParallelism
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
const masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, key);
|
const masterPasswordHash = await this.cryptoService.hashPassword(
|
||||||
|
this.masterPassword,
|
||||||
|
masterKey
|
||||||
|
);
|
||||||
|
|
||||||
const encKey = await this.cryptoService.remakeEncKey(key, oldEncKey);
|
const encKey = await this.cryptoService.encryptUserSymKeyWithMasterKey(
|
||||||
|
masterKey,
|
||||||
|
oldUserSymKey
|
||||||
|
);
|
||||||
|
|
||||||
const request = new EmergencyAccessPasswordRequest();
|
const request = new EmergencyAccessPasswordRequest();
|
||||||
request.newMasterPasswordHash = masterPasswordHash;
|
request.newMasterPasswordHash = masterPasswordHash;
|
||||||
|
|||||||
@@ -300,9 +300,9 @@ export class EmergencyAccessComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encrypt the master password hash using the grantees public key, and send it to bitwarden for escrow.
|
// Encrypt the user key with the grantees public key, and send it to bitwarden for escrow.
|
||||||
private async doConfirmation(details: EmergencyAccessGranteeDetailsResponse) {
|
private async doConfirmation(details: EmergencyAccessGranteeDetailsResponse) {
|
||||||
const encKey = await this.cryptoService.getEncKey();
|
const userKey = await this.cryptoService.getUserKeyFromMemory();
|
||||||
const publicKeyResponse = await this.apiService.getUserPublicKey(details.granteeId);
|
const publicKeyResponse = await this.apiService.getUserPublicKey(details.granteeId);
|
||||||
const publicKey = Utils.fromB64ToArray(publicKeyResponse.publicKey);
|
const publicKey = Utils.fromB64ToArray(publicKeyResponse.publicKey);
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ export class EmergencyAccessComponent implements OnInit {
|
|||||||
// Ignore errors since it's just a debug message
|
// Ignore errors since it's just a debug message
|
||||||
}
|
}
|
||||||
|
|
||||||
const encryptedKey = await this.cryptoService.rsaEncrypt(encKey.key, publicKey.buffer);
|
const encryptedKey = await this.cryptoService.rsaEncrypt(userKey.key, publicKey.buffer);
|
||||||
const request = new EmergencyAccessConfirmRequest();
|
const request = new EmergencyAccessConfirmRequest();
|
||||||
request.key = encryptedKey.encryptedString;
|
request.key = encryptedKey.encryptedString;
|
||||||
await this.apiService.postEmergencyAccessConfirm(details.id, request);
|
await this.apiService.postEmergencyAccessConfirm(details.id, request);
|
||||||
|
|||||||
Reference in New Issue
Block a user