Skip to content

armgit / ente

Public Imported from GitHub
0

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

Prune

Manav Rathide3943e69cbb
diff --git a/web/packages/base/crypto/libsodium.ts b/web/packages/base/crypto/libsodium.ts
index f1972de6be..6bcd0f2e87 100644
--- a/web/packages/base/crypto/libsodium.ts
+++ b/web/packages/base/crypto/libsodium.ts
@@ -13,13 +13,11 @@ import { CustomError } from "@ente/shared/error";
import sodium, { type StateAddress } from "libsodium-wrappers";
import type {
BytesOrB64,
- EncryptBytes,
EncryptedBlob_2,
EncryptedBlobB64_2,
EncryptedBlobBytes_2,
EncryptedBox2,
EncryptedBoxB64,
- EncryptedBoxBytes,
} from "./types";
/**
@@ -243,10 +241,16 @@ export const encryptBoxB64 = async (
};
/** deprecated + needs rename */
-const encryptBox = async ({
+const encryptBox_Deprecated = async ({
data,
keyB64,
-}: EncryptBytes): Promise<EncryptedBoxBytes> => {
+}: {
+ data: Uint8Array;
+ keyB64: string;
+}): Promise<{
+ encryptedData: Uint8Array;
+ nonceB64: string;
+}> => {
await sodium.ready;
const nonce = sodium.randombytes_buf(sodium.crypto_secretbox_NONCEBYTES);
const encryptedData = sodium.crypto_secretbox_easy(
@@ -385,7 +389,7 @@ export async function encryptFileChunk(
}
/**
- * Decrypt the result of {@link encryptBox}.
+ * Decrypt the result of {@link encryptBox_Deprecated}.
*/
const decryptBox_Deprecated = async ({
encryptedData,
@@ -533,7 +537,10 @@ export interface B64EncryptionResult {
export async function encryptToB64(data: string, keyB64: string) {
await sodium.ready;
- const encrypted = await encryptBox({ data: await fromB64(data), keyB64 });
+ const encrypted = await encryptBox_Deprecated({
+ data: await fromB64(data),
+ keyB64,
+ });
return {
encryptedData: await toB64(encrypted.encryptedData),
diff --git a/web/packages/base/crypto/types.ts b/web/packages/base/crypto/types.ts
index ea35e23f49..ba0c80c395 100644
--- a/web/packages/base/crypto/types.ts
+++ b/web/packages/base/crypto/types.ts
@@ -4,19 +4,6 @@
*/
export type BytesOrB64 = Uint8Array | string;
-/**
- * Deprecated.
- */
-export interface EncryptBytes {
- /**
- * A {@link Uint8Array} containing the bytes to encrypt.
- */
- data: Uint8Array;
- /**
- * A base64 string containing the encryption key.
- */
- keyB64: string;
-}
/**
* Deprecated.
@@ -139,29 +126,6 @@ export interface EncryptedBlobB64_2 {
decryptionHeader: string;
}
-/**
- * The result of encryption using the secretbox APIs.
- *
- * It contains the encrypted data (bytes) and nonce (base64 encoded string)
- * pair. Both these values are needed to decrypt the data. The nonce does not
- * need to be secret.
- *
- * See: [Note: 3 forms of encryption (Box | Blob | Stream)].
- */
-export interface EncryptedBoxBytes {
- /**
- * A {@link Uint8Array} containing the encrypted data.
- */
- encryptedData: Uint8Array;
- /**
- * A base64 string containing the nonce used during encryption.
- *
- * A randomly generated nonce for this encryption. It does not need to be
- * confidential, but it will be required to decrypt the data.
- */
- nonceB64: string;
-}
-
/**
* Deprecated.
*