encryption: Send the group session key before ratcheting it.
This commit is contained in:
parent
5f3842e4fa
commit
2bf9766276
2 changed files with 11 additions and 14 deletions
|
@ -313,14 +313,14 @@ class Olm():
|
||||||
except OlmSessionError:
|
except OlmSessionError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def group_encrypt(self, room_id, plaintext_dict):
|
def group_encrypt(self, room_id, plaintext_dict, own_id, users):
|
||||||
# type: (str, Dict[str, str]) -> Dict[str, str], Bool
|
# type: (str, Dict[str, str]) -> Dict[str, str], Optional[Dict[Any, Any]]
|
||||||
is_new = False
|
|
||||||
plaintext_dict["room_id"] = room_id
|
plaintext_dict["room_id"] = room_id
|
||||||
|
to_device_dict = None
|
||||||
|
|
||||||
if room_id not in self.outbound_group_sessions:
|
if room_id not in self.outbound_group_sessions:
|
||||||
self.create_outbound_group_session(room_id)
|
self.create_outbound_group_session(room_id)
|
||||||
is_new = True
|
to_device_dict = self.share_group_session(room_id, own_id, users)
|
||||||
|
|
||||||
session = self.outbound_group_sessions[room_id]
|
session = self.outbound_group_sessions[room_id]
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ class Olm():
|
||||||
"device_id": self.device_id
|
"device_id": self.device_id
|
||||||
}
|
}
|
||||||
|
|
||||||
return payload_dict, is_new
|
return payload_dict, to_device_dict
|
||||||
|
|
||||||
@encrypt_enabled
|
@encrypt_enabled
|
||||||
def group_decrypt(self, room_id, session_id, ciphertext):
|
def group_decrypt(self, room_id, session_id, ciphertext):
|
||||||
|
|
|
@ -510,19 +510,16 @@ class MatrixServer:
|
||||||
|
|
||||||
W.prnt("", "matrix: Encrypting message")
|
W.prnt("", "matrix: Encrypting message")
|
||||||
|
|
||||||
payload_dict, session_is_new = self.olm.group_encrypt(
|
payload_dict, to_device_dict = self.olm.group_encrypt(
|
||||||
room_id,
|
room_id,
|
||||||
plaintext_dict
|
plaintext_dict,
|
||||||
|
self.user_id,
|
||||||
|
room.users.keys()
|
||||||
)
|
)
|
||||||
|
|
||||||
if session_is_new:
|
if to_device_dict:
|
||||||
to_device_dict = self.olm.share_group_session(
|
|
||||||
room_id,
|
|
||||||
self.user_id,
|
|
||||||
room.users.keys()
|
|
||||||
)
|
|
||||||
message = MatrixToDeviceMessage(self.client, to_device_dict)
|
|
||||||
W.prnt("", "matrix: Megolm session missing for room.")
|
W.prnt("", "matrix: Megolm session missing for room.")
|
||||||
|
message = MatrixToDeviceMessage(self.client, to_device_dict)
|
||||||
self.send_queue.append(message)
|
self.send_queue.append(message)
|
||||||
|
|
||||||
message = MatrixEncryptedMessage(
|
message = MatrixEncryptedMessage(
|
||||||
|
|
Loading…
Add table
Reference in a new issue