1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

use master key for device approvals still

This commit is contained in:
Jacob Fink
2023-06-20 11:18:12 -04:00
parent a8f1e7858d
commit 8f225bf541
2 changed files with 6 additions and 6 deletions

View File

@@ -296,13 +296,14 @@ export class AuthService implements AuthServiceAbstraction {
key: string, key: string,
requestApproved: boolean requestApproved: boolean
): Promise<AuthRequestResponse> { ): Promise<AuthRequestResponse> {
// TODO: This currently depends on always having the Master Key and MP Hash
// We need to change this to using a different method (possibly server auth code + user sym key)
const pubKey = Utils.fromB64ToArray(key); const pubKey = Utils.fromB64ToArray(key);
// TODO(Jake): Do we need to support old encryption model here? const masterKey = await this.cryptoService.getMasterKey();
const userSymKey = await this.cryptoService.getUserKeyFromMemory(); if (!masterKey) {
if (!userSymKey) { throw new Error("Master key not found");
throw new Error("User key not found");
} }
const encryptedKey = await this.cryptoService.rsaEncrypt(userSymKey.encKey, pubKey.buffer); const encryptedKey = await this.cryptoService.rsaEncrypt(masterKey.encKey, pubKey.buffer);
const encryptedMasterPasswordHash = await this.cryptoService.rsaEncrypt( const encryptedMasterPasswordHash = await this.cryptoService.rsaEncrypt(
Utils.fromUtf8ToArray(await this.stateService.getKeyHash()), Utils.fromUtf8ToArray(await this.stateService.getKeyHash()),
pubKey.buffer pubKey.buffer

View File

@@ -4,7 +4,6 @@ import { Utils } from "../../misc/utils";
import { AccountKeys, EncryptionPair } from "./account"; import { AccountKeys, EncryptionPair } from "./account";
import { SymmetricCryptoKey } from "./symmetric-crypto-key"; import { SymmetricCryptoKey } from "./symmetric-crypto-key";
//TODO(Jake): Fix tests
describe("AccountKeys", () => { describe("AccountKeys", () => {
describe("toJSON", () => { describe("toJSON", () => {
it("should serialize itself", () => { it("should serialize itself", () => {