π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove unused libsodium sensitive KDF
Manav Rathi6500839190c2
diff --git a/web/packages/base/crypto/index.ts b/web/packages/base/crypto/index.tsindex f59b199415..8598958275 100644--- a/web/packages/base/crypto/index.ts+++ b/web/packages/base/crypto/index.ts@@ -244,11 +244,6 @@ export const deriveKey = (w.deriveKey(passphrase, salt, opsLimit, memLimit),);-export const deriveSensitiveKey = (passphrase: string): Promise<DerivedKey> =>- inWorker()- ? libsodium.deriveSensitiveKey(passphrase)- : sharedWorker().then((w) => w.deriveSensitiveKey(passphrase));-export const deriveInteractiveKey = (passphrase: string,): Promise<DerivedKey> =>diff --git a/web/packages/base/crypto/libsodium.ts b/web/packages/base/crypto/libsodium.tsindex 7902eedac0..5573b7602f 100644--- a/web/packages/base/crypto/libsodium.ts+++ b/web/packages/base/crypto/libsodium.ts@@ -2,7 +2,6 @@ import { ensureArrayBufferBacked } from "ente-base/bytes";import { mergeUint8Arrays } from "ente-utils/array";import sodium from "libsodium-wrappers-sumo";import {- deriveKeyInsufficientMemoryErrorMessage,streamEncryptionChunkSize,type BytesOrB64,type DerivedKey,@@ -393,42 +392,6 @@ export const deriveKey = async ();};-export const deriveSensitiveKey = async (- passphrase: string,-): Promise<DerivedKey> => {- await sodium.ready;-- const salt = await generateDeriveKeySalt();-- const desiredStrength =- sodium.crypto_pwhash_MEMLIMIT_SENSITIVE *- sodium.crypto_pwhash_OPSLIMIT_SENSITIVE;- // A 1 GiB memory cost can make weaker devices OOM after an account was- // created elsewhere. Preserve the same work factor with less memory.- let memLimit = sodium.crypto_pwhash_MEMLIMIT_MODERATE;- const factor = Math.floor(- sodium.crypto_pwhash_MEMLIMIT_SENSITIVE /- sodium.crypto_pwhash_MEMLIMIT_MODERATE,- );- let opsLimit = sodium.crypto_pwhash_OPSLIMIT_SENSITIVE * factor;- if (memLimit * opsLimit != desiredStrength) {- throw new Error(`Invalid mem and ops limits: ${memLimit}, ${opsLimit}`);- }-- // Museum rejects account KDFs below 128 MiB.- const minMemLimit = 128 * 1024 * 1024;- while (memLimit >= minMemLimit) {- try {- const key = await deriveKey(passphrase, salt, opsLimit, memLimit);- return { key, salt, opsLimit, memLimit };- } catch {- opsLimit *= 2;- memLimit /= 2;- }- }- throw new Error(deriveKeyInsufficientMemoryErrorMessage);-};-export const deriveInteractiveKey = async (passphrase: string,): Promise<DerivedKey> => {diff --git a/web/packages/base/crypto/types.ts b/web/packages/base/crypto/types.tsindex 1c45407844..18cf3d52f6 100644--- a/web/packages/base/crypto/types.ts+++ b/web/packages/base/crypto/types.ts@@ -7,9 +7,6 @@ export const streamEncryptionChunkSize = 4 * 1024 * 1024;// libsodium secretstream adds this many bytes per encrypted chunk.export const streamEncryptionChunkOverhead = 17;-export const deriveKeyInsufficientMemoryErrorMessage =- "Failed to derive key (insufficient memory)";-export type BytesOrB64 = Uint8Array | string;export interface EncryptedBox {diff --git a/web/packages/base/crypto/worker.ts b/web/packages/base/crypto/worker.tsindex 6d3749640e..b33ed5e855 100644--- a/web/packages/base/crypto/worker.ts+++ b/web/packages/base/crypto/worker.ts@@ -37,7 +37,6 @@ export class CryptoWorker {boxSealOpenBytes = libsodium.boxSealOpenBytes;generateDeriveKeySalt = libsodium.generateDeriveKeySalt;deriveKey = libsodium.deriveKey;- deriveSensitiveKey = libsodium.deriveSensitiveKey;deriveInteractiveKey = libsodium.deriveInteractiveKey;deriveModerateKey = libsodium.deriveModerateKey;deriveSubKeyBytes = libsodium.deriveSubKeyBytes;