Fix decryption.
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
deba255cb0
commit
737f5eae33
3 changed files with 27 additions and 4 deletions
|
@ -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']" % (
|
||||
|
|
|
@ -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)
|
||||
|
|
23
stanza.py
23
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):
|
||||
|
|
Loading…
Reference in a new issue