| ... |
... |
@@ -25,6 +25,7 @@ from nbxmpp.protocol import NS_EME |
|
25
|
25
|
from nbxmpp.protocol import NS_HINTS
|
|
26
|
26
|
from nbxmpp.protocol import NodeProcessed
|
|
27
|
27
|
from nbxmpp.protocol import Node
|
|
|
28
|
+from nbxmpp.protocol import Message
|
|
28
|
29
|
from nbxmpp.protocol import isResultNode
|
|
29
|
30
|
from nbxmpp.protocol import StanzaMalformed
|
|
30
|
31
|
from nbxmpp.util import call_on_response
|
| ... |
... |
@@ -435,6 +436,25 @@ def create_omemo_message(stanza, omemo_message, store_hint=True, |
|
435
|
436
|
stanza.addChild(node=Node('store', attrs={'xmlns': NS_HINTS}))
|
|
436
|
437
|
|
|
437
|
438
|
|
|
|
439
|
+def get_key_transport_message(typ, jid, omemo_message):
|
|
|
440
|
+ message = Message(typ=typ, to=jid)
|
|
|
441
|
+
|
|
|
442
|
+ encrypted = Node('encrypted', attrs={'xmlns': NS_OMEMO_TEMP})
|
|
|
443
|
+ header = Node('header', attrs={'sid': omemo_message.sid})
|
|
|
444
|
+ for rid, (key, prekey) in omemo_message.keys.items():
|
|
|
445
|
+ attrs = {'rid': rid}
|
|
|
446
|
+ if prekey:
|
|
|
447
|
+ attrs['prekey'] = 'true'
|
|
|
448
|
+ child = header.addChild('key', attrs=attrs)
|
|
|
449
|
+ child.addData(b64encode(key))
|
|
|
450
|
+
|
|
|
451
|
+ header.addChild('iv').addData(b64encode(omemo_message.iv))
|
|
|
452
|
+ encrypted.addChild(node=header)
|
|
|
453
|
+
|
|
|
454
|
+ message.addChild(node=encrypted)
|
|
|
455
|
+ return message
|
|
|
456
|
+
|
|
|
457
|
+
|
|
438
|
458
|
def cleanup_stanza(stanza, node_whitelist):
|
|
439
|
459
|
whitelisted_nodes = []
|
|
440
|
460
|
for tag, ns in node_whitelist:
|