mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
update assortment of leftover old crypto service calls
This commit is contained in:
@@ -58,8 +58,8 @@ export class EnrollMasterPasswordReset {
|
|||||||
const publicKey = Utils.fromB64ToArray(orgKeys.publicKey);
|
const publicKey = Utils.fromB64ToArray(orgKeys.publicKey);
|
||||||
|
|
||||||
// RSA Encrypt user's encKey.key with organization public key
|
// RSA Encrypt user's encKey.key with organization public key
|
||||||
const encKey = await this.cryptoService.getEncKey();
|
const userKey = await this.cryptoService.getUserKeyFromMemory();
|
||||||
const encryptedKey = await this.cryptoService.rsaEncrypt(encKey.key, publicKey.buffer);
|
const encryptedKey = await this.cryptoService.rsaEncrypt(userKey.key, publicKey.buffer);
|
||||||
keyString = encryptedKey.encryptedString;
|
keyString = encryptedKey.encryptedString;
|
||||||
toastStringRef = "enrollPasswordResetSuccess";
|
toastStringRef = "enrollPasswordResetSuccess";
|
||||||
|
|
||||||
|
|||||||
@@ -141,8 +141,8 @@ export class AcceptOrganizationComponent extends BaseAcceptComponent {
|
|||||||
const publicKey = Utils.fromB64ToArray(response.publicKey);
|
const publicKey = Utils.fromB64ToArray(response.publicKey);
|
||||||
|
|
||||||
// RSA Encrypt user's encKey.key with organization public key
|
// RSA Encrypt user's encKey.key with organization public key
|
||||||
const encKey = await this.cryptoService.getEncKey();
|
const userKey = await this.cryptoService.getUserKeyFromMemory();
|
||||||
const encryptedKey = await this.cryptoService.rsaEncrypt(encKey.key, publicKey.buffer);
|
const encryptedKey = await this.cryptoService.rsaEncrypt(userKey.key, publicKey.buffer);
|
||||||
|
|
||||||
// Add reset password key to accept request
|
// Add reset password key to accept request
|
||||||
request.resetPasswordKey = encryptedKey.encryptedString;
|
request.resetPasswordKey = encryptedKey.encryptedString;
|
||||||
|
|||||||
@@ -77,15 +77,18 @@ export class ChangeKdfConfirmationComponent {
|
|||||||
request.kdfParallelism = this.kdfConfig.parallelism;
|
request.kdfParallelism = this.kdfConfig.parallelism;
|
||||||
request.masterPasswordHash = await this.cryptoService.hashPassword(masterPassword, null);
|
request.masterPasswordHash = await this.cryptoService.hashPassword(masterPassword, null);
|
||||||
const email = await this.stateService.getEmail();
|
const email = await this.stateService.getEmail();
|
||||||
const newKey = await this.cryptoService.makeKey(
|
const newMasterKey = await this.cryptoService.makeMasterKey(
|
||||||
masterPassword,
|
masterPassword,
|
||||||
email,
|
email,
|
||||||
this.kdf,
|
this.kdf,
|
||||||
this.kdfConfig
|
this.kdfConfig
|
||||||
);
|
);
|
||||||
request.newMasterPasswordHash = await this.cryptoService.hashPassword(masterPassword, newKey);
|
request.newMasterPasswordHash = await this.cryptoService.hashPassword(
|
||||||
const newEncKey = await this.cryptoService.remakeEncKey(newKey);
|
masterPassword,
|
||||||
request.key = newEncKey[1].encryptedString;
|
newMasterKey
|
||||||
|
);
|
||||||
|
const newUserSymKey = await this.cryptoService.encryptUserSymKeyWithMasterKey(newMasterKey);
|
||||||
|
request.key = newUserSymKey[1].encryptedString;
|
||||||
|
|
||||||
await this.apiService.postAccountKdf(request);
|
await this.apiService.postAccountKdf(request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ export class UpdateKeyComponent {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
const hasEncKey = await this.cryptoService.hasEncKey();
|
const hasUserKey = await this.cryptoService.hasUserKey();
|
||||||
if (hasEncKey) {
|
if (hasUserKey) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,16 +68,16 @@ export class UpdateKeyComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async makeRequest(): Promise<UpdateKeyRequest> {
|
private async makeRequest(): Promise<UpdateKeyRequest> {
|
||||||
const key = await this.cryptoService.getKey();
|
const masterKey = await this.cryptoService.getMasterKey();
|
||||||
const encKey = await this.cryptoService.makeEncKey(key);
|
const newUserKey = await this.cryptoService.makeUserSymKey(masterKey);
|
||||||
const privateKey = await this.cryptoService.getPrivateKey();
|
const privateKey = await this.cryptoService.getPrivateKey();
|
||||||
let encPrivateKey: EncString = null;
|
let encPrivateKey: EncString = null;
|
||||||
if (privateKey != null) {
|
if (privateKey != null) {
|
||||||
encPrivateKey = await this.cryptoService.encrypt(privateKey, encKey[0]);
|
encPrivateKey = await this.cryptoService.encrypt(privateKey, newUserKey[0]);
|
||||||
}
|
}
|
||||||
const request = new UpdateKeyRequest();
|
const request = new UpdateKeyRequest();
|
||||||
request.privateKey = encPrivateKey != null ? encPrivateKey.encryptedString : null;
|
request.privateKey = encPrivateKey != null ? encPrivateKey.encryptedString : null;
|
||||||
request.key = encKey[1].encryptedString;
|
request.key = newUserKey[1].encryptedString;
|
||||||
request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, null);
|
request.masterPasswordHash = await this.cryptoService.hashPassword(this.masterPassword, null);
|
||||||
|
|
||||||
await this.syncService.fullSync(true);
|
await this.syncService.fullSync(true);
|
||||||
@@ -87,7 +87,7 @@ export class UpdateKeyComponent {
|
|||||||
if (folders[i].id == null) {
|
if (folders[i].id == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const folder = await this.folderService.encrypt(folders[i], encKey[0]);
|
const folder = await this.folderService.encrypt(folders[i], newUserKey[0]);
|
||||||
request.folders.push(new FolderWithIdRequest(folder));
|
request.folders.push(new FolderWithIdRequest(folder));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ export class UpdateKeyComponent {
|
|||||||
if (ciphers[i].organizationId != null) {
|
if (ciphers[i].organizationId != null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const cipher = await this.cipherService.encrypt(ciphers[i], encKey[0]);
|
const cipher = await this.cipherService.encrypt(ciphers[i], newUserKey[0]);
|
||||||
request.ciphers.push(new CipherWithIdRequest(cipher));
|
request.ciphers.push(new CipherWithIdRequest(cipher));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
|||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import {
|
||||||
|
MasterKey,
|
||||||
|
SymmetricCryptoKey,
|
||||||
|
} 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";
|
||||||
|
|
||||||
import { CaptchaProtectedComponent } from "./captcha-protected.component";
|
import { CaptchaProtectedComponent } from "./captcha-protected.component";
|
||||||
@@ -193,19 +196,22 @@ export class LoginWithDeviceComponent
|
|||||||
requestId: string,
|
requestId: string,
|
||||||
response: AuthRequestResponse
|
response: AuthRequestResponse
|
||||||
): Promise<PasswordlessLogInCredentials> {
|
): Promise<PasswordlessLogInCredentials> {
|
||||||
const decKey = await this.cryptoService.rsaDecrypt(response.key, this.authRequestKeyPair[1]);
|
const decMasterKeyArray = await this.cryptoService.rsaDecrypt(
|
||||||
|
response.key,
|
||||||
|
this.authRequestKeyPair[1]
|
||||||
|
);
|
||||||
const decMasterPasswordHash = await this.cryptoService.rsaDecrypt(
|
const decMasterPasswordHash = await this.cryptoService.rsaDecrypt(
|
||||||
response.masterPasswordHash,
|
response.masterPasswordHash,
|
||||||
this.authRequestKeyPair[1]
|
this.authRequestKeyPair[1]
|
||||||
);
|
);
|
||||||
const key = new SymmetricCryptoKey(decKey);
|
const decMasterKey = new SymmetricCryptoKey(decMasterKeyArray) as MasterKey;
|
||||||
const localHashedPassword = Utils.fromBufferToUtf8(decMasterPasswordHash);
|
const localHashedPassword = Utils.fromBufferToUtf8(decMasterPasswordHash);
|
||||||
|
|
||||||
return new PasswordlessLogInCredentials(
|
return new PasswordlessLogInCredentials(
|
||||||
this.email,
|
this.email,
|
||||||
this.passwordlessRequest.accessCode,
|
this.passwordlessRequest.accessCode,
|
||||||
requestId,
|
requestId,
|
||||||
key,
|
decMasterKey,
|
||||||
localHashedPassword
|
localHashedPassword
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user