From 488f7a9dfdcbe5314ff0b4625c9fc8e3d2a24b54 Mon Sep 17 00:00:00 2001 From: Jacob Fink Date: Fri, 23 Jun 2023 12:08:16 -0400 Subject: [PATCH] updated EncKey to UserKey where applicable --- apps/cli/src/auth/commands/login.command.ts | 16 ++++------------ .../components/reset-password.component.ts | 2 +- .../emergency-access-view.component.ts | 9 ++++++--- .../app/settings/change-password.component.html | 10 +++++----- .../app/settings/change-password.component.ts | 14 +++++++------- .../src/app/settings/update-key.component.html | 4 ++-- 6 files changed, 25 insertions(+), 30 deletions(-) diff --git a/apps/cli/src/auth/commands/login.command.ts b/apps/cli/src/auth/commands/login.command.ts index a9afe5fc0f..0f53d9795c 100644 --- a/apps/cli/src/auth/commands/login.command.ts +++ b/apps/cli/src/auth/commands/login.command.ts @@ -406,11 +406,7 @@ export class LoginCommand { } try { - const { - newPasswordHash, - newUserKey: newEncKey, - hint, - } = await this.collectNewMasterPasswordDetails( + const { newPasswordHash, newUserKey, hint } = await this.collectNewMasterPasswordDetails( "Your master password does not meet one or more of your organization policies. In order to access the vault, you must update your master password now." ); @@ -418,7 +414,7 @@ export class LoginCommand { request.masterPasswordHash = await this.cryptoService.hashPassword(currentPassword, null); request.masterPasswordHint = hint; request.newMasterPasswordHash = newPasswordHash; - request.key = newEncKey[1].encryptedString; + request.key = newUserKey[1].encryptedString; await this.apiService.postPassword(request); @@ -448,16 +444,12 @@ export class LoginCommand { } try { - const { - newPasswordHash, - newUserKey: newEncKey, - hint, - } = await this.collectNewMasterPasswordDetails( + const { newPasswordHash, newUserKey, hint } = await this.collectNewMasterPasswordDetails( "An organization administrator recently changed your master password. In order to access the vault, you must update your master password now." ); const request = new UpdateTempPasswordRequest(); - request.key = newEncKey[1].encryptedString; + request.key = newUserKey[1].encryptedString; request.newMasterPasswordHash = newPasswordHash; request.masterPasswordHint = hint; diff --git a/apps/web/src/app/admin-console/organizations/members/components/reset-password.component.ts b/apps/web/src/app/admin-console/organizations/members/components/reset-password.component.ts index f388ec3a00..ce6d3e37f7 100644 --- a/apps/web/src/app/admin-console/organizations/members/components/reset-password.component.ts +++ b/apps/web/src/app/admin-console/organizations/members/components/reset-password.component.ts @@ -174,7 +174,7 @@ export class ResetPasswordComponent implements OnInit, OnDestroy { orgSymKey ); - // Decrypt User's Reset Password Key to get EncKey + // Decrypt User's Reset Password Key to get UserKey const decValue = await this.cryptoService.rsaDecrypt(resetPasswordKey, decPrivateKey); const existingUserKey = new SymmetricCryptoKey(decValue) as UserKey; diff --git a/apps/web/src/app/auth/settings/emergency-access/emergency-access-view.component.ts b/apps/web/src/app/auth/settings/emergency-access/emergency-access-view.component.ts index 9507980248..f7936d361b 100644 --- a/apps/web/src/app/auth/settings/emergency-access/emergency-access-view.component.ts +++ b/apps/web/src/app/auth/settings/emergency-access/emergency-access-view.component.ts @@ -5,7 +5,10 @@ import { ModalService } from "@bitwarden/angular/services/modal.service"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { EmergencyAccessViewResponse } from "@bitwarden/common/auth/models/response/emergency-access.response"; import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service"; -import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; +import { + SymmetricCryptoKey, + UserKey, +} from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherData } from "@bitwarden/common/vault/models/data/cipher.data"; import { Cipher } from "@bitwarden/common/vault/models/domain/cipher"; @@ -87,13 +90,13 @@ export class EmergencyAccessViewComponent implements OnInit { const decCiphers: CipherView[] = []; const oldKeyBuffer = await this.cryptoService.rsaDecrypt(response.keyEncrypted); - const oldEncKey = new SymmetricCryptoKey(oldKeyBuffer); + const oldUserKey = new SymmetricCryptoKey(oldKeyBuffer) as UserKey; const promises: any[] = []; ciphers.forEach((cipherResponse) => { const cipherData = new CipherData(cipherResponse); const cipher = new Cipher(cipherData); - promises.push(cipher.decrypt(oldEncKey).then((c) => decCiphers.push(c))); + promises.push(cipher.decrypt(oldUserKey).then((c) => decCiphers.push(c))); }); await Promise.all(promises); diff --git a/apps/web/src/app/settings/change-password.component.html b/apps/web/src/app/settings/change-password.component.html index 3321b8f9df..7088cb5a68 100644 --- a/apps/web/src/app/settings/change-password.component.html +++ b/apps/web/src/app/settings/change-password.component.html @@ -89,12 +89,12 @@ -