comparison sat/memory/encryption.py @ 3104:118d91c932a7

plugin XEP-0384: OMEMO for MUC implementation: - encryption is now allowed for group chats - when an encryption is requested for a MUC, real jids or all occupants are used to encrypt the message - a cache for plain text message sent to MUC is used, because for security reason we can't encrypt message for our own device with OMEMO (that would prevent ratchet and break the prefect forward secrecy). Thus, message sent in MUC are cached for 5 min, and the decrypted version is used when found. We don't send immediately the plain text message to frontends and history because we want to keep the same MUC behaviour as for plain text, and receiving a message means that it was received and sent back by MUC service - <origin-id> is used to identify messages sent by our device - a feedback_jid is now use to use correct entity for feedback message in case of problem: with a room we have to send feedback message to the room and not the the emitter - encryptMessage now only accepts list in the renamed "entity_bare_jids" argument
author Goffi <goffi@goffi.org>
date Mon, 30 Dec 2019 20:59:46 +0100
parents ab2696e34d29
children 9d0df638c8b4
comparison
equal deleted inserted replaced
3103:f0f48b4deb35 3104:118d91c932a7
414 414
415 ## Triggers ## 415 ## Triggers ##
416 416
417 def setEncryptionFlag(self, mess_data): 417 def setEncryptionFlag(self, mess_data):
418 """Set "encryption" key in mess_data if session with destinee is encrypted""" 418 """Set "encryption" key in mess_data if session with destinee is encrypted"""
419
420 if mess_data["type"] == "groupchat":
421 # FIXME: to change when group chat encryption will be handled
422 return
423
424 to_jid = mess_data['to'] 419 to_jid = mess_data['to']
425 encryption = self._sessions.get(to_jid.userhostJID()) 420 encryption = self._sessions.get(to_jid.userhostJID())
426 if encryption is not None: 421 if encryption is not None:
422 if mess_data["type"] == "groupchat" and encryption['plugin'].directed:
423 raise exceptions.InternalError(
424 f"encryption flag must not be set for groupchat if encryption algorithm "
425 f"({encryption['plugin'].name}) is directed!")
427 mess_data[C.MESS_KEY_ENCRYPTION] = encryption 426 mess_data[C.MESS_KEY_ENCRYPTION] = encryption
428 427
429 ## Misc ## 428 ## Misc ##
430 429
431 def markAsEncrypted(self, mess_data): 430 def markAsEncrypted(self, mess_data):