1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Megolm: don't dereference nullable object

It is possible for `room` to be null when passed to
MegolmEncryption.encryptMessage; we need to avoid dereferencing it. Instead,
make sure that the EncryptionAlgorithm knows about the roomId it is targeting,
and use that.

Replace the increasingly-long argument list on the EncryptionAlgorithm
constructor with a params list, and update DecryptionAlgorithm to match.
This commit is contained in:
Richard van der Hoff
2016-08-17 16:21:37 +01:00
parent 783b1feb70
commit 4d6f9da578
4 changed files with 52 additions and 53 deletions

View File

@@ -33,13 +33,11 @@ var OLM_ALGORITHM = "m.olm.v1.curve25519-aes-sha2";
* @constructor
* @extends {module:crypto-algorithms/base.EncryptionAlgorithm}
*
* @param {string} deviceId The identifier for this device.
* @param {module:crypto} crypto crypto core
* @param {module:OlmDevice} olmDevice olm.js wrapper
*
* @param {object} params parameters, as per
* {@link module:crypto-algorithms/base.EncryptionAlgorithm}
*/
function OlmEncryption(deviceId, crypto, olmDevice) {
base.EncryptionAlgorithm.call(this, deviceId, crypto, olmDevice);
function OlmEncryption(params) {
base.EncryptionAlgorithm.call(this, params);
}
utils.inherits(OlmEncryption, base.EncryptionAlgorithm);
@@ -58,7 +56,7 @@ OlmEncryption.prototype.initRoomEncryption = function(roomMembers) {
/**
* @inheritdoc
*
* @param {module:models/room} room
* @param {module:models/room?} room
* @param {string} eventType
* @param {object} plaintext event content
*
@@ -138,14 +136,11 @@ OlmEncryption.prototype.encryptMessage = function(room, eventType, content) {
*
* @constructor
* @extends {module:crypto-algorithms/base.DecryptionAlgorithm}
*
* @param {string} deviceId The identifier for this device.
* @param {module:crypto} crypto crypto core
* @param {module:OlmDevice} olmDevice olm.js wrapper
*
* @param {object} params parameters, as per
* {@link module:crypto-algorithms/base.DecryptionAlgorithm}
*/
function OlmDecryption(deviceId, crypto, olmDevice) {
base.DecryptionAlgorithm.call(this, deviceId, crypto, olmDevice);
function OlmDecryption(params) {
base.DecryptionAlgorithm.call(this, params);
}
utils.inherits(OlmDecryption, base.DecryptionAlgorithm);