Thumb
This commit is contained in:
@@ -1124,10 +1124,14 @@ const encryptFile = async (
|
||||
worker,
|
||||
);
|
||||
|
||||
const encryptedThumbnail = await worker.encryptThumbnail(
|
||||
file.thumbnail,
|
||||
fileKey,
|
||||
);
|
||||
const {
|
||||
encryptedData: thumbEncryptedData,
|
||||
decryptionHeaderB64: thumbDecryptionHeader,
|
||||
} = await worker.encryptThumbnail(file.thumbnail, fileKey);
|
||||
const encryptedThumbnail = {
|
||||
encryptedData: thumbEncryptedData,
|
||||
decryptionHeader: thumbDecryptionHeader,
|
||||
};
|
||||
|
||||
const encryptedMetadata = await worker.encryptMetadata2(
|
||||
file.metadata,
|
||||
|
||||
@@ -37,6 +37,20 @@ import * as libsodium from "@ente/shared/crypto/internal/libsodium";
|
||||
*/
|
||||
export const encryptAssociatedData = libsodium.encryptChaChaOneShot;
|
||||
|
||||
/**
|
||||
* Encrypt the thumbnail for a file.
|
||||
*
|
||||
* This is just an alias for {@link encryptAssociatedData}.
|
||||
*
|
||||
* @param data The thumbnail's data.
|
||||
*
|
||||
* @param keyB64 The key associated with the file whose thumbnail this is.
|
||||
*
|
||||
* @returns The encrypted thumbnail, and the associated decryption header
|
||||
* (Base64 encoded).
|
||||
*/
|
||||
export const encryptThumbnail = encryptAssociatedData;
|
||||
|
||||
/**
|
||||
* Encrypted the embedding associated with a file using the file's key.
|
||||
*
|
||||
|
||||
@@ -32,22 +32,8 @@ export class DedicatedCryptoWorker {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt the thumbnail associated with a file.
|
||||
*
|
||||
* This defers to {@link encryptChaChaOneShot}.
|
||||
*
|
||||
* @param data The thumbnail's data.
|
||||
*
|
||||
* @param keyB64 The key associated with the file whose thumbnail this is.
|
||||
*
|
||||
* @returns The encrypted thumbnail, and the associated decryption header
|
||||
* (Base64 encoded).
|
||||
*/
|
||||
async encryptThumbnail(data: Uint8Array, keyB64: string) {
|
||||
const { encryptedData, decryptionHeaderB64: decryptionHeader } =
|
||||
await libsodium.encryptChaChaOneShot(data, keyB64);
|
||||
return { encryptedData, decryptionHeader };
|
||||
return ente.encryptThumbnail(data, keyB64);
|
||||
}
|
||||
|
||||
async encryptFile(fileData: Uint8Array) {
|
||||
|
||||
Reference in New Issue
Block a user