diff --git a/libs/common/src/platform/abstractions/crypto.service.ts b/libs/common/src/platform/abstractions/crypto.service.ts index b60c414880..42cd9543e4 100644 --- a/libs/common/src/platform/abstractions/crypto.service.ts +++ b/libs/common/src/platform/abstractions/crypto.service.ts @@ -119,5 +119,4 @@ export abstract class CryptoService { decryptToBytes: (encString: EncString, key?: SymmetricCryptoKey) => Promise; decryptToUtf8: (encString: EncString, key?: SymmetricCryptoKey) => Promise; decryptFromBytes: (encBuffer: EncArrayBuffer, key: SymmetricCryptoKey) => Promise; - clearEncKey: (memoryOnly?: boolean, userId?: string) => Promise; } diff --git a/libs/common/src/platform/services/crypto.service.ts b/libs/common/src/platform/services/crypto.service.ts index b591b0cbe8..626f63b51b 100644 --- a/libs/common/src/platform/services/crypto.service.ts +++ b/libs/common/src/platform/services/crypto.service.ts @@ -1072,45 +1072,6 @@ export class CryptoService implements CryptoServiceAbstraction { return new SymmetricCryptoKey(key); } - /** - * @deprecated the UserSymKey is always stored decrypted - */ - private async getEncKeyHelper(key: SymmetricCryptoKey = null): Promise { - const inMemoryKey = await this.stateService.getDecryptedCryptoSymmetricKey(); - if (inMemoryKey != null) { - return inMemoryKey; - } - - const encKey = await this.stateService.getEncryptedCryptoSymmetricKey(); - if (encKey == null) { - return null; - } - - if (key == null) { - key = await this.getUserKey(); - } - if (key == null) { - return null; - } - - let decEncKey: ArrayBuffer; - const encKeyCipher = new EncString(encKey); - if (encKeyCipher.encryptionType === EncryptionType.AesCbc256_B64) { - decEncKey = await this.decryptToBytes(encKeyCipher, key); - } else if (encKeyCipher.encryptionType === EncryptionType.AesCbc256_HmacSha256_B64) { - const newKey = await this.stretchKey(key); - decEncKey = await this.decryptToBytes(encKeyCipher, newKey); - } else { - throw new Error("Unsupported encKey type."); - } - if (decEncKey == null) { - return null; - } - const symmetricCryptoKey = new SymmetricCryptoKey(decEncKey); - await this.stateService.setDecryptedCryptoSymmetricKey(symmetricCryptoKey); - return symmetricCryptoKey; - } - /** * @deprecated July 25 2022: Get the key you need from CryptoService (getKeyForUserEncryption or getOrgKey) * and then call encryptService.encrypt @@ -1160,14 +1121,4 @@ export class CryptoService implements CryptoServiceAbstraction { return this.encryptService.decryptToBytes(encBuffer, key); } - - /** - * @deprecated use clearKey instead - */ - async clearEncKey(memoryOnly?: boolean, userId?: string): Promise { - await this.stateService.setDecryptedCryptoSymmetricKey(null, { userId: userId }); - if (!memoryOnly) { - await this.stateService.setEncryptedCryptoSymmetricKey(null, { userId: userId }); - } - } }