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

fix crypto calls for key connector and vault timeout settings

This commit is contained in:
Jacob Fink
2023-06-08 16:13:25 -04:00
parent 9a12cb099a
commit 2aa303d17e
2 changed files with 10 additions and 9 deletions

View File

@@ -45,8 +45,8 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
async migrateUser() { async migrateUser() {
const organization = await this.getManagingOrganization(); const organization = await this.getManagingOrganization();
const key = await this.cryptoService.getKey(); const masterKey = await this.cryptoService.getMasterKey();
const keyConnectorRequest = new KeyConnectorUserKeyRequest(key.encKeyB64); const keyConnectorRequest = new KeyConnectorUserKeyRequest(masterKey.encKeyB64);
try { try {
await this.apiService.postUserKeyToKeyConnector( await this.apiService.postUserKeyToKeyConnector(
@@ -88,17 +88,18 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
const password = await this.cryptoFunctionService.randomBytes(64); const password = await this.cryptoFunctionService.randomBytes(64);
const kdfConfig = new KdfConfig(kdfIterations, kdfMemory, kdfParallelism); const kdfConfig = new KdfConfig(kdfIterations, kdfMemory, kdfParallelism);
const k = await this.cryptoService.makeKey( const masterKey = await this.cryptoService.makeMasterKey(
Utils.fromBufferToB64(password), Utils.fromBufferToB64(password),
await this.tokenService.getEmail(), await this.tokenService.getEmail(),
kdf, kdf,
kdfConfig kdfConfig
); );
const keyConnectorRequest = new KeyConnectorUserKeyRequest(k.encKeyB64); const keyConnectorRequest = new KeyConnectorUserKeyRequest(masterKey.encKeyB64);
await this.cryptoService.setKey(k); await this.cryptoService.setMasterKey(masterKey);
const encKey = await this.cryptoService.makeEncKey(k); const userKey = await this.cryptoService.makeUserSymKey(masterKey);
await this.cryptoService.setEncKey(encKey[1].encryptedString); await this.cryptoService.setUserKey(userKey[0]);
await this.cryptoService.setUserSymKeyMasterKey(userKey[1].encryptedString);
const [pubKey, privKey] = await this.cryptoService.makeKeyPair(); const [pubKey, privKey] = await this.cryptoService.makeKeyPair();
@@ -110,7 +111,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
const keys = new KeysRequest(pubKey, privKey.encryptedString); const keys = new KeysRequest(pubKey, privKey.encryptedString);
const setPasswordRequest = new SetKeyConnectorKeyRequest( const setPasswordRequest = new SetKeyConnectorKeyRequest(
encKey[1].encryptedString, userKey[1].encryptedString,
kdf, kdf,
kdfConfig, kdfConfig,
orgId, orgId,

View File

@@ -113,6 +113,6 @@ export class VaultTimeoutSettingsService implements VaultTimeoutSettingsServiceA
await this.stateService.setEverBeenUnlocked(false, { userId: userId }); await this.stateService.setEverBeenUnlocked(false, { userId: userId });
await this.stateService.setUserSymKeyPinEphemeral(null, { userId: userId }); await this.stateService.setUserSymKeyPinEphemeral(null, { userId: userId });
await this.stateService.setProtectedPin(null, { userId: userId }); await this.stateService.setProtectedPin(null, { userId: userId });
await this.stateService.setDecryptedPinProtected(null, { userId: userId }); await this.cryptoService.clearOldPinKeys(userId);
} }
} }