Skip to content

armgit / ente

Public Imported from GitHub
0

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

Trim

Manav Rathi4d985abd07b2
diff --git a/web/packages/accounts/pages/two-factor/recover.tsx b/web/packages/accounts/pages/two-factor/recover.tsx
index 21593f30e7..54f6e6a079 100644
--- a/web/packages/accounts/pages/two-factor/recover.tsx
+++ b/web/packages/accounts/pages/two-factor/recover.tsx
@@ -19,7 +19,6 @@ import {
} from "ente-base/components/SingleInputForm";
import { useBaseContext } from "ente-base/context";
import { decryptBox } from "ente-base/crypto";
-import type { B64EncryptionResult } from "ente-base/crypto/libsodium";
import log from "ente-base/log";
import { ApiError } from "ente-shared/error";
import { getData, setData, setLSUser } from "ente-shared/storage/localStorage";
@@ -35,8 +34,10 @@ export interface RecoverPageProps {
const Page: React.FC<RecoverPageProps> = ({ twoFactorType }) => {
const { logout, showMiniDialog } = useBaseContext();
- const [encryptedTwoFactorSecret, setEncryptedTwoFactorSecret] =
- useState<Omit<B64EncryptionResult, "key"> | null>(null);
+ const [encryptedTwoFactorSecret, setEncryptedTwoFactorSecret] = useState<{
+ encryptedData: string;
+ nonce: string;
+ } | null>(null);
const [sessionID, setSessionID] = useState<string | null>(null);
const [doesHaveEncryptedRecoveryKey, setDoesHaveEncryptedRecoveryKey] =
useState(false);
diff --git a/web/packages/base/crypto/libsodium.ts b/web/packages/base/crypto/libsodium.ts
index 9f4d52e71d..2e125ba093 100644
--- a/web/packages/base/crypto/libsodium.ts
+++ b/web/packages/base/crypto/libsodium.ts
@@ -638,29 +638,6 @@ export const decryptStreamChunk = async (
return pullResult.message;
};
-export interface B64EncryptionResult {
- encryptedData: string;
- key: string;
- nonce: string;
-}
-
-/** Deprecated, use {@link encryptBox} instead */
-async function encryptToB64(data: string, keyB64: string) {
- await sodium.ready;
- const encrypted = await encryptBox(data, keyB64);
- return {
- encryptedData: encrypted.encryptedData,
- key: keyB64,
- nonce: encrypted.nonce,
- } as B64EncryptionResult;
-}
-
-export async function generateKeyAndEncryptToB64(data: string) {
- await sodium.ready;
- const key = sodium.crypto_secretbox_keygen();
- return await encryptToB64(data, await toB64(key));
-}
-
/**
* Initialize and return new state that can be used to hash the chunks of data
* in a streaming manner.
diff --git a/web/packages/base/crypto/worker.ts b/web/packages/base/crypto/worker.ts
index 4214855b3c..982b66b1ee 100644
--- a/web/packages/base/crypto/worker.ts
+++ b/web/packages/base/crypto/worker.ts
@@ -1,7 +1,6 @@
import { expose } from "comlink";
import { logUnhandledErrorsAndRejectionsInWorker } from "ente-base/log-web";
import * as ei from "./ente-impl";
-import * as libsodium from "./libsodium";
/**
* A web worker that exposes some of the functions defined in either the Ente
@@ -47,12 +46,6 @@ export class CryptoWorker {
deriveSensitiveKey = ei._deriveSensitiveKey;
deriveInteractiveKey = ei._deriveInteractiveKey;
deriveSubKeyBytes = ei._deriveSubKeyBytes;
-
- // TODO: -- AUDIT BELOW --
-
- async generateKeyAndEncryptToB64(data: string) {
- return libsodium.generateKeyAndEncryptToB64(data);
- }
}
expose(CryptoWorker);