2
0
Эх сурвалжийг харах

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
JC Brand 2 жил өмнө
parent
commit
40024f4599

+ 1 - 0
CHANGES.md

@@ -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)

+ 4 - 3
src/plugins/omemo/utils.js

@@ -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);