mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
return blob from encryptAttachment
This commit is contained in:
parent
32b7b1f064
commit
c289bcd097
@ -57,13 +57,15 @@ export async function decryptAttachment(crypto, ciphertextBuffer, info) {
|
|||||||
return decryptedBuffer;
|
return decryptedBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function encryptAttachment(crypto, data) {
|
export async function encryptAttachment(platform, blob) {
|
||||||
|
const {crypto} = platform;
|
||||||
const iv = await crypto.aes.generateIV();
|
const iv = await crypto.aes.generateIV();
|
||||||
const key = await crypto.aes.generateKey("jwk", 256);
|
const key = await crypto.aes.generateKey("jwk", 256);
|
||||||
const ciphertext = await crypto.aes.encryptCTR({key, iv, data});
|
const buffer = await blob.readAsBuffer();
|
||||||
|
const ciphertext = await crypto.aes.encryptCTR({key, iv, data: buffer});
|
||||||
const digest = await crypto.digest("SHA-256", ciphertext);
|
const digest = await crypto.digest("SHA-256", ciphertext);
|
||||||
return {
|
return {
|
||||||
data: ciphertext,
|
blob: platform.createBlob(ciphertext, blob.mimeType),
|
||||||
info: {
|
info: {
|
||||||
v: "v2",
|
v: "v2",
|
||||||
key,
|
key,
|
||||||
|
Loading…
Reference in New Issue
Block a user