From c5efa582b1b018880b8e4a17d27c77c584ddcbde Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 3 Sep 2020 17:51:00 +0200 Subject: [PATCH] check algorithm --- src/matrix/Session.js | 5 +++++ src/matrix/room/Room.js | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/matrix/Session.js b/src/matrix/Session.js index e3f82bda..68afcf5b 100644 --- a/src/matrix/Session.js +++ b/src/matrix/Session.js @@ -24,6 +24,7 @@ import {Decryption as OlmDecryption} from "./e2ee/olm/Decryption.js"; import {Encryption as OlmEncryption} from "./e2ee/olm/Encryption.js"; import {Decryption as MegOlmDecryption} from "./e2ee/megolm/Decryption.js"; import {Encryption as MegOlmEncryption} from "./e2ee/megolm/Encryption.js"; +import {MEGOLM_ALGORITHM} from "./e2ee/common.js"; import {RoomEncryption} from "./e2ee/RoomEncryption.js"; import {DeviceTracker} from "./e2ee/DeviceTracker.js"; import {LockMap} from "../utils/LockMap.js"; @@ -108,6 +109,10 @@ export class Session { if (!this._olmEncryption) { throw new Error("creating room encryption before encryption got globally enabled"); } + // only support megolm + if (encryptionParams.algorithm !== MEGOLM_ALGORITHM) { + return null; + } return new RoomEncryption({ room, deviceTracker: this._deviceTracker, diff --git a/src/matrix/room/Room.js b/src/matrix/room/Room.js index e8315538..d2272b3d 100644 --- a/src/matrix/room/Room.js +++ b/src/matrix/room/Room.js @@ -88,7 +88,9 @@ export class Room extends EventEmitter { // encryption got enabled if (!this._summary.encryption && summaryChanges.encryption && !this._roomEncryption) { this._roomEncryption = this._createRoomEncryption(this, summaryChanges.encryption); - this._sendQueue.enableEncryption(this._roomEncryption); + if (this._roomEncryption) { + this._sendQueue.enableEncryption(this._roomEncryption); + } } if (memberChanges.size) { if (this._changedMembersDuringSync) { @@ -138,7 +140,9 @@ export class Room extends EventEmitter { this._summary.load(summary); if (this._summary.encryption) { this._roomEncryption = this._createRoomEncryption(this, this._summary.encryption); - this._sendQueue.enableEncryption(this._roomEncryption); + if (this._roomEncryption) { + this._sendQueue.enableEncryption(this._roomEncryption); + } } // need to load members for name? if (this._summary.needsHeroes) {