Skip to content
Snippets Groups Projects
Commit aa880116 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Add encrypted file upload for windows

parent 5c510c10
No related branches found
No related tags found
No related merge requests found
...@@ -35,9 +35,8 @@ try: ...@@ -35,9 +35,8 @@ try:
except: except:
pil_available = False pil_available = False
from io import BytesIO from io import BytesIO
import base64
import binascii
import binascii
from common import gajim from common import gajim
from common import ged from common import ged
import chat_control import chat_control
...@@ -49,19 +48,21 @@ import nbxmpp ...@@ -49,19 +48,21 @@ import nbxmpp
log = logging.getLogger('gajim.plugin_system.httpupload') log = logging.getLogger('gajim.plugin_system.httpupload')
if os.name != 'nt': try:
try: if os.name == 'nt':
from cryptography.hazmat.backends.openssl import backend
else:
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import Cipher from cryptography.hazmat.primitives.ciphers import Cipher
from cryptography.hazmat.primitives.ciphers import algorithms from cryptography.hazmat.primitives.ciphers import algorithms
from cryptography.hazmat.primitives.ciphers.modes import GCM from cryptography.hazmat.primitives.ciphers.modes import GCM
encryption_available = True encryption_available = True
except Exception as e: except Exception as e:
log.debug(e) DEP_MSG = 'For encryption of files, ' \
encryption_available = False 'please install python-cryptography!'
else: log.debug('Cryptography Import Error: ' + str(e))
log.info('Decryption/Encryption disabled due to errors')
encryption_available = False encryption_available = False
log.info('Cryptography not available on Windows for now')
# XEP-0363 (http://xmpp.org/extensions/xep-0363.html) # XEP-0363 (http://xmpp.org/extensions/xep-0363.html)
NS_HTTPUPLOAD = 'urn:xmpp:http:upload' NS_HTTPUPLOAD = 'urn:xmpp:http:upload'
...@@ -78,6 +79,8 @@ class HttpuploadPlugin(GajimPlugin): ...@@ -78,6 +79,8 @@ class HttpuploadPlugin(GajimPlugin):
@log_calls('HttpuploadPlugin') @log_calls('HttpuploadPlugin')
def init(self): def init(self):
if not encryption_available:
self.available_text = DEP_MSG
self.config_dialog = None # HttpuploadPluginConfigDialog(self) self.config_dialog = None # HttpuploadPluginConfigDialog(self)
self.controls = [] self.controls = []
self.events_handlers = {} self.events_handlers = {}
...@@ -571,10 +574,14 @@ class StreamFileWithProgress(file): ...@@ -571,10 +574,14 @@ class StreamFileWithProgress(file):
self.encrypted_upload = encrypted_upload self.encrypted_upload = encrypted_upload
self.seek(0, os.SEEK_END) self.seek(0, os.SEEK_END)
if self.encrypted_upload: if self.encrypted_upload:
if os.name == 'nt':
self.backend = backend
else:
self.backend = default_backend()
self.encryptor = Cipher( self.encryptor = Cipher(
algorithms.AES(key), algorithms.AES(key),
GCM(iv), GCM(iv),
backend=default_backend()).encryptor() backend=self.backend).encryptor()
self._total = self.tell() + TAGSIZE self._total = self.tell() + TAGSIZE
else: else:
self._total = self.tell() self._total = self.tell()
......
[info] [info]
name: HttpUpload name: HttpUpload
short_name: httpupload short_name: httpupload
version: 0.4.0 version: 0.4.1
description: This plugin is designed to send a file to a contact or muc by using httpupload.<br/> description: This plugin is designed to send a file to a contact or muc by using httpupload.<br/>
Your server must support <a href="http://xmpp.org/extensions/xep-0363.html">XEP-0363: HTTP Upload</a>.<br/> Your server must support <a href="http://xmpp.org/extensions/xep-0363.html">XEP-0363: HTTP Upload</a>.<br/>
Conversations supported this.<br/> Conversations supported this.<br/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment