From fd28d13e19939c4d0bc29a8b9f6c122162058b84 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 22 Jun 2018 13:54:17 +0100 Subject: [PATCH 1/2] Server-enforced e2e for private rooms --- synapse/handlers/room.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 8df8fcbbad..a66433ad55 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -46,12 +46,14 @@ class RoomCreationHandler(BaseHandler): "history_visibility": "shared", "original_invitees_have_ops": False, "guest_can_join": True, + "encryption_alg": "m.megolm.v1.aes-sha2", }, RoomCreationPreset.TRUSTED_PRIVATE_CHAT: { "join_rules": JoinRules.INVITE, "history_visibility": "shared", "original_invitees_have_ops": True, "guest_can_join": True, + "encryption_alg": "m.megolm.v1.aes-sha2", }, RoomCreationPreset.PUBLIC_CHAT: { "join_rules": JoinRules.PUBLIC, @@ -373,6 +375,15 @@ class RoomCreationHandler(BaseHandler): content=content, ) + if "encryption_alg" in config: + send( + etype="m.room.encryption", + state_key="", + content={ + 'algorithm': config["encryption_alg"], + } + ) + class RoomContextHandler(BaseHandler): @defer.inlineCallbacks From 3d0faa39fb8813fd747f63776fd88ccd0e893e2b Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 22 Jun 2018 16:47:49 +0100 Subject: [PATCH 2/2] Add m.encryption to event types --- synapse/api/constants.py | 2 ++ synapse/handlers/room.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/synapse/api/constants.py b/synapse/api/constants.py index 5baba43966..92b5790557 100644 --- a/synapse/api/constants.py +++ b/synapse/api/constants.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2014-2016 OpenMarket Ltd # Copyright 2017 Vector Creations Ltd +# Copyright 2018 New Vector Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -70,6 +71,7 @@ class EventTypes(object): CanonicalAlias = "m.room.canonical_alias" RoomAvatar = "m.room.avatar" GuestAccess = "m.room.guest_access" + Encryption = "m.room.encryption" # These are used for validation Message = "m.room.message" diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index a66433ad55..bcb54fe41a 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -377,7 +377,7 @@ class RoomCreationHandler(BaseHandler): if "encryption_alg" in config: send( - etype="m.room.encryption", + etype=EventTypes.Encryption, state_key="", content={ 'algorithm': config["encryption_alg"],