mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
Move asymmetric crypto functions out of crypto service (#10903)
This commit is contained in:
@@ -124,8 +124,8 @@ describe("OrganizationAuthRequestService", () => {
|
||||
);
|
||||
|
||||
const encryptedUserKey = new EncString("encryptedUserKey");
|
||||
cryptoService.rsaDecrypt.mockResolvedValue(new Uint8Array(32));
|
||||
cryptoService.rsaEncrypt.mockResolvedValue(encryptedUserKey);
|
||||
encryptService.rsaDecrypt.mockResolvedValue(new Uint8Array(32));
|
||||
encryptService.rsaEncrypt.mockResolvedValue(encryptedUserKey);
|
||||
|
||||
const mockPendingAuthRequest = new PendingAuthRequestView();
|
||||
mockPendingAuthRequest.id = "requestId1";
|
||||
@@ -166,8 +166,8 @@ describe("OrganizationAuthRequestService", () => {
|
||||
);
|
||||
|
||||
const encryptedUserKey = new EncString("encryptedUserKey");
|
||||
cryptoService.rsaDecrypt.mockResolvedValue(new Uint8Array(32));
|
||||
cryptoService.rsaEncrypt.mockResolvedValue(encryptedUserKey);
|
||||
encryptService.rsaDecrypt.mockResolvedValue(new Uint8Array(32));
|
||||
encryptService.rsaEncrypt.mockResolvedValue(encryptedUserKey);
|
||||
|
||||
const mockPendingAuthRequest = new PendingAuthRequestView();
|
||||
mockPendingAuthRequest.id = "requestId1";
|
||||
|
||||
@@ -117,10 +117,13 @@ export class OrganizationAuthRequestService {
|
||||
);
|
||||
|
||||
// Decrypt user key with decrypted org private key
|
||||
const decValue = await this.cryptoService.rsaDecrypt(encryptedUserKey, decOrgPrivateKey);
|
||||
const decValue = await this.encryptService.rsaDecrypt(
|
||||
new EncString(encryptedUserKey),
|
||||
decOrgPrivateKey,
|
||||
);
|
||||
const userKey = new SymmetricCryptoKey(decValue);
|
||||
|
||||
// Re-encrypt user Key with the Device Public Key
|
||||
return await this.cryptoService.rsaEncrypt(userKey.key, devicePubKey);
|
||||
return await this.encryptService.rsaEncrypt(userKey.key, devicePubKey);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user