diff --git a/plugin.py b/plugin.py index 114e055..e858055 100644 --- a/plugin.py +++ b/plugin.py @@ -185,7 +185,7 @@ class XEP_0384(BasePlugin): header = msg['omemo_encrypted']['header'] payload = msg['omemo_encrypted']['payload'] - jid = msg['from'] + jid = msg['from'].bare sid = header['sid'] key = header.xml.find("{%s}key[@rid='%s']" % ( diff --git a/session.py b/session.py index aaca555..3b318e8 100644 --- a/session.py +++ b/session.py @@ -1,7 +1,7 @@ import omemo from slixmpp.plugins.xep_0384.storage import SQLiteDatabase from omemo.util import generateDeviceID - +import base64 class SessionManager: def __init__(self, own_jid, db_path): @@ -49,6 +49,10 @@ class SessionManager: return self._sm.encryptMessage(jids, plaintext, bundles, devices, callback) def decrypt(self, jid, sid, iv, message, payload, prekey): + iv = base64.b64decode(iv.get_value()) + payload = base64.b64decode(payload.get_value()) + message = base64.b64decode(message) + sid = int(sid) if prekey: return self._sm.decryptMessage(jid, sid, iv, message, payload) return self._sm.decryptPreKeyMessage(jid, sid, iv, message, payload) diff --git a/stanza.py b/stanza.py index 4eaeb11..2c07c5f 100644 --- a/stanza.py +++ b/stanza.py @@ -65,14 +65,33 @@ class IV(ElementBase): namespace = OMEMO_BASE_NS name = 'iv' plugin_attrib = name - interfaces = set() + interfaces = {'value'} + + def get_value(self): + return self.xml.text + + def set_value(self, value): + self.xml.text = str(value) + + def del_value(self): + self.xml.text = '' class Payload(ElementBase): namespace = OMEMO_BASE_NS name = 'payload' plugin_attrib = name - interfaces = set() + interfaces = {'value'} + + def get_value(self): + return self.xml.text + + def set_value(self, value): + self.xml.text = str(value) + + def del_value(self): + self.xml.text = '' + class Bundle(ElementBase):