Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Doc

Manav Rathi7a11547a1488
diff --git a/web/packages/accounts/pages/credentials.tsx b/web/packages/accounts/pages/credentials.tsx
index 99b99127d9..184098319c 100644
--- a/web/packages/accounts/pages/credentials.tsx
+++ b/web/packages/accounts/pages/credentials.tsx
@@ -29,11 +29,12 @@ import {
getSRPAttributes,
loginViaSRP,
} from "ente-accounts/services/srp";
-import { generateAndSaveInteractiveKeyAttributes, type KeyAttributes, type User } from "ente-accounts/services/user";
import {
- decryptAndStoreToken,
- generateAndSaveIntermediateKeyAttributes,
-} from "ente-accounts/utils/helpers";
+ generateAndSaveInteractiveKeyAttributes,
+ type KeyAttributes,
+ type User,
+} from "ente-accounts/services/user";
+import { decryptAndStoreToken } from "ente-accounts/utils/helpers";
import { LinkButton } from "ente-base/components/LinkButton";
import { LoadingIndicator } from "ente-base/components/loaders";
import { useBaseContext } from "ente-base/context";
diff --git a/web/packages/accounts/services/user.ts b/web/packages/accounts/services/user.ts
index fc12947ee8..09bd4f9d0c 100644
--- a/web/packages/accounts/services/user.ts
+++ b/web/packages/accounts/services/user.ts
@@ -571,13 +571,29 @@ export const remoteLogoutIfNeeded = async () => {
};
/**
- * Encrypt the user's masterKey with an intermediate kek (key encryption key)
- * derived from the passphrase (with interactive mem and ops limits) to avoid
- * saving it to local storage in plain text.
- *
- * This means that on the web user will always have to enter their passphrase to
+ * Generate a new local-only kek (key encryption key) suitable for interactive
+ * use and update the locally saved key attributes to reflect it.
+ *
+ * See {@link deriveInteractiveKey} for more details. In brief, after the
+ * initial passphrase verification, we create a new kek derived from the same
+ * passphrase as the original kek, but with so called interactive mem and ops
+ * limits which result in a noticeably faster key derivation.
+ *
+ * We then overwrite the KEK tuple (See: [Note: KEK three tuple]) in the locally
+ * persisted {@link KeyAttributes} so that these interactive parameters get used
+ * subsequent reauthentication. These never leave the device, and are meant to
+ * be local only "intermediate" key attributes which are more ergonomic for the
+ * user, especially on the web app where they need to enter their passphrase to
* access their masterKey when repopening the app in a new tab (on desktop we
* can use OS storage, see [Note: Safe storage and interactive KEK attributes]).
+ *
+ * @param passphrase The user's passphrase.
+ *
+ * @param keyAttributes The existing "original" key attributes, which we
+ * might've generated locally (new signup) or fetched from remote (existing
+ * login).
+ *
+ * @param masterKey The user's master key (base64 encoded).
*/
export async function generateAndSaveInteractiveKeyAttributes(
passphrase: string,
diff --git a/web/packages/accounts/utils/helpers.ts b/web/packages/accounts/utils/helpers.ts
index b00d1ec663..f165453d70 100644
--- a/web/packages/accounts/utils/helpers.ts
+++ b/web/packages/accounts/utils/helpers.ts
@@ -1,13 +1,8 @@
// TODO: Audit this file, this can be better. e.g. do we need the Object.assign?
import { type KeyAttributes } from "ente-accounts/services/user";
-import {
- boxSealOpenBytes,
- decryptBox,
- sharedCryptoWorker,
- toB64URLSafe,
-} from "ente-base/crypto";
-import { getData, setData, setLSUser } from "ente-shared/storage/localStorage";
+import { boxSealOpenBytes, decryptBox, toB64URLSafe } from "ente-base/crypto";
+import { getData, setLSUser } from "ente-shared/storage/localStorage";
export async function decryptAndStoreToken(
keyAttributes: KeyAttributes,
@@ -38,4 +33,3 @@ export async function decryptAndStoreToken(
});
}
}
-