diff --git a/lib/crypto/OlmDevice.js b/lib/crypto/OlmDevice.js index ca9565fe3..bca4280ab 100644 --- a/lib/crypto/OlmDevice.js +++ b/lib/crypto/OlmDevice.js @@ -578,17 +578,21 @@ OlmDevice.prototype._getInboundGroupSession = function( * * @param {string} roomId room in which this session will be used * @param {string} senderKey base64-encoded curve25519 key of the sender - * @param {string} sessionId session identifier * @param {string} sessionKey base64-encoded secret key at index chainIndex * @param {number} chainIndex index at which sessionKey applies */ OlmDevice.prototype.addInboundGroupSession = function( - roomId, senderKey, sessionId, sessionKey, chainIndex + roomId, senderKey, sessionId, sessionKey, chainIndex, ) { var self = this; var session = new Olm.InboundGroupSession(); try { - session.create(chainIndex, sessionKey); + session.create(sessionKey); + if (sessionId != session.session_id()) { + throw new Error( + "Mismatched group session ID from senderKey: " + senderKey + ); + } self._saveInboundGroupSession(roomId, senderKey, sessionId, session); } finally { session.free(); diff --git a/lib/crypto/algorithms/megolm.js b/lib/crypto/algorithms/megolm.js index b10794524..0a809780a 100644 --- a/lib/crypto/algorithms/megolm.js +++ b/lib/crypto/algorithms/megolm.js @@ -124,7 +124,7 @@ MegolmEncryption.prototype._prepareNewSession = function(room) { this._olmDevice.addInboundGroupSession( this._roomId, this._olmDevice.deviceCurve25519Key, session_id, - key.key, key.chain_index + key.key ); // we're going to share the key with all current members of the room, @@ -394,8 +394,7 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) { if (!content.room_id || !content.session_id || - !content.session_key || - content.chain_index === undefined + !content.session_key ) { console.error("key event is missing fields"); return; @@ -403,7 +402,7 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) { this._olmDevice.addInboundGroupSession( content.room_id, event.getSenderKey(), content.session_id, - content.session_key, content.chain_index + content.session_key ); }; diff --git a/package.json b/package.json index a425f13d0..d31ec996d 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,6 @@ "uglifyjs": "^2.4.10" }, "optionalDependencies": { - "olm": "https://matrix.org/packages/npm/olm/olm-1.2.0.tgz" + "olm": "https://matrix.org/packages/npm/olm/olm-1.3.0.tgz" } }