comparison sat/plugins/plugin_xep_0384.py @ 3696:52ee22d78e18

plugin XEP-0384: fix encryption for user own devices: our own jid is added automatically by OMEMO library, but during the generation of the stanza, our list of jids was used to get the keys (and thus our own jid and devices keys was missing). fix 402
author Goffi <goffi@goffi.org>
date Fri, 22 Oct 2021 18:46:51 +0200
parents be6d91572633
children 09f5ac48ffe3
comparison
equal deleted inserted replaced
3695:87caf6284c55 3696:52ee22d78e18
1422 1422
1423 encrypted_elt = message_elt.addElement((NS_OMEMO, 'encrypted')) 1423 encrypted_elt = message_elt.addElement((NS_OMEMO, 'encrypted'))
1424 header_elt = encrypted_elt.addElement('header') 1424 header_elt = encrypted_elt.addElement('header')
1425 header_elt['sid'] = str(encryption_data['sid']) 1425 header_elt['sid'] = str(encryption_data['sid'])
1426 1426
1427 for to_jid in to_jids: 1427 for key_data in encryption_data['keys'].values():
1428 bare_jid_s = to_jid.userhost() 1428 for rid, data in key_data.items():
1429
1430 for rid, data in encryption_data['keys'][bare_jid_s].items():
1431 key_elt = header_elt.addElement( 1429 key_elt = header_elt.addElement(
1432 'key', 1430 'key',
1433 content=b64enc(data['data'])) 1431 content=b64enc(data['data'])
1432 )
1434 key_elt['rid'] = str(rid) 1433 key_elt['rid'] = str(rid)
1435 if data['pre_key']: 1434 if data['pre_key']:
1436 key_elt['prekey'] = 'true' 1435 key_elt['prekey'] = 'true'
1437 1436
1438 header_elt.addElement( 1437 header_elt.addElement(