mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
Transparent but handrolled proxy
This commit is contained in:
parent
5044a0c33f
commit
a029b16851
@ -17,7 +17,11 @@
|
|||||||
* 2. internal/libsodium.ts (wrappers over libsodium)
|
* 2. internal/libsodium.ts (wrappers over libsodium)
|
||||||
* 3. libsodium (JS bindings).
|
* 3. libsodium (JS bindings).
|
||||||
*/
|
*/
|
||||||
|
import ComlinkCryptoWorker from "@ente/shared/crypto";
|
||||||
import * as libsodium from "@ente/shared/crypto/internal/libsodium";
|
import * as libsodium from "@ente/shared/crypto/internal/libsodium";
|
||||||
|
import { inWorker } from "../env";
|
||||||
|
|
||||||
|
const cryptoWorker = () => ComlinkCryptoWorker.getInstance();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt arbitrary data associated with an Ente object (file, collection,
|
* Encrypt arbitrary data associated with an Ente object (file, collection,
|
||||||
@ -200,7 +204,22 @@ export const decryptMetadata = async (
|
|||||||
* decrypted data as a JSON string and instead just returns the raw decrypted
|
* decrypted data as a JSON string and instead just returns the raw decrypted
|
||||||
* bytes that we got.
|
* bytes that we got.
|
||||||
*/
|
*/
|
||||||
export const decryptMetadataBytes = async (
|
export const decryptMetadataBytes = (
|
||||||
|
encryptedDataB64: string,
|
||||||
|
decryptionHeaderB64: string,
|
||||||
|
keyB64: string,
|
||||||
|
) =>
|
||||||
|
inWorker()
|
||||||
|
? decryptMetadataBytesI(encryptedDataB64, decryptionHeaderB64, keyB64)
|
||||||
|
: cryptoWorker().then((cw) =>
|
||||||
|
cw.decryptMetadataBytes(
|
||||||
|
encryptedDataB64,
|
||||||
|
decryptionHeaderB64,
|
||||||
|
keyB64,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
export const decryptMetadataBytesI = async (
|
||||||
encryptedDataB64: string,
|
encryptedDataB64: string,
|
||||||
decryptionHeaderB64: string,
|
decryptionHeaderB64: string,
|
||||||
keyB64: string,
|
keyB64: string,
|
||||||
|
@ -40,6 +40,10 @@ export class DedicatedCryptoWorker {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async decryptMetadataBytes(a: string, b: string, c: string) {
|
||||||
|
return ente.decryptMetadataBytesI(a, b, c);
|
||||||
|
}
|
||||||
|
|
||||||
async decryptFile(fileData: Uint8Array, header: Uint8Array, key: string) {
|
async decryptFile(fileData: Uint8Array, header: Uint8Array, key: string) {
|
||||||
return libsodium.decryptChaCha(fileData, header, key);
|
return libsodium.decryptChaCha(fileData, header, key);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user