Fixes #3028 Encrypted media not properly decrypting

Turns out that older versions Quicksy/Conversations use an IV of 16 bytes although the spec states 12
This commit is contained in:
JC Brand 2022-10-25 15:49:20 +02:00
parent 18d8b69f00
commit 40024f4599
2 changed files with 5 additions and 3 deletions

View File

@ -23,6 +23,7 @@
- #3005: Fix MUC messages with a fallback body not rendering.
- #3007: Fix links becoming text when a message is edited
- #3018: Fix MUC icons not functioning.
- #3028: Fix encrypted media from Conversations/Quicksy not properly decrypting
## 9.1.1 (2022-05-05)

View File

@ -166,7 +166,6 @@ async function downloadFile(url) {
}
async function getAndDecryptFile (uri) {
const hash = uri.hash().slice(1);
const protocol = (window.location.hostname === 'localhost' && uri.domain() === 'localhost') ? 'http' : 'https';
const http_url = uri.toString().replace(/^aesgcm/, protocol);
const cipher = await downloadFile(http_url);
@ -174,8 +173,10 @@ async function getAndDecryptFile (uri) {
log.error(`Could not decrypt a received encrypted file ${uri.toString()} since it could not be downloaded`);
return new Error(__('Error: could not decrypt a received encrypted file, because it could not be downloaded'));
}
const iv = hash.slice(0, 24);
const key = hash.slice(24);
const hash = uri.hash().slice(1);
const key = hash.substring(hash.length-64);
const iv = hash.replace(key, '');
let content;
try {
content = await decryptFile(iv, key, cipher);