gkdr / lurch

XEP-0384: OMEMO Encryption for libpurple.
GNU General Public License v3.0
289 stars 32 forks source link

Feature request: download and decrypt aesgcm:// media urls #157

Open petermolnar opened 3 years ago

petermolnar commented 3 years ago

I'm completely new to pidgin plugins, which is why this is not a pull request yet.

Using Conversations on Android, with http upload, if a media file gets sent inside and OMEMO message, lurch will correctly decrypt the message and display the media urls like aesgcm://example.com/upload/file

The problem is that the uploaded media file is also OMEMO encrypted, therefore simply following the URL doesn't work. I also have https://github.com/EionRobb/pidgin-data-uri-image/ which pulls the actual media from normal <img> and displays it inline.

Would it be possible to add this functionality into lurch for aesgcm:// urls, as is download and decrypt the media along with the message?

gkdr commented 3 years ago

hi @petermolnar! it would definitely be possible. i swear there was an issue about it somewhere, but i can't find it. so thanks for raising the issue :slightly_smiling_face: there are several complications:

petermolnar commented 3 years ago

to the 1st point: I think the proto-xep you're looking for is https://xmpp.org/extensions/xep-0448.html

petermolnar commented 3 years ago

to the 3rd point: using it together with the pidgin-data-uri-image would need a message with <img> tags in it, so, if I understand it correctly, emitting a HTML message with the decrypted URI should do the trick for other plugins to pick it up.

It could be tied to a setting to do this or not, depending in client needs.

As in: decrypt incoming message => look for aesgcm:// => download resource => decrypt resource => identify mime type => emit a shadow (?) message, marked up in a way that other plugins could support, <img> for image, potentially simple local URLs for other media formats.

selurvedu commented 3 years ago

FYI, I used https://github.com/moparisthebest/ImageDownloader for decrypting aesgcm:// URIs and downloading files (not only images), it works just fine. It is a C rewrite of a reference Java implementation. Maybe @gkdr could make use of its code.

Upd: looks like there'a also a Rust implementation now.