Set messageKeysLimit to unlimited if communicating with our devices (#1348)

Set messageKeysLimit to unlimited if communicating with our devices

FREEBIE
This commit is contained in:
Scott Nonnenberg 2017-08-04 12:25:30 -07:00 committed by GitHub
parent 7e0bd82bd3
commit e223db56d9
4 changed files with 88 additions and 14 deletions

View file

@ -36032,7 +36032,14 @@ libsignal.SessionBuilder = function (storage, remoteAddress) {
this.processV3 = builder.processV3.bind(builder);
};
function SessionCipher(storage, remoteAddress) {
function SessionCipher(storage, remoteAddress, options) {
options = options || {};
if (typeof options.messageKeysLimit === 'undefined') {
options.messageKeysLimit = 1000;
}
this.messageKeysLimit = options.messageKeysLimit;
this.remoteAddress = remoteAddress;
this.storage = storage;
}
@ -36305,7 +36312,7 @@ SessionCipher.prototype = {
});
},
fillMessageKeys: function(chain, counter) {
if (Object.keys(chain.messageKeys).length >= 1000) {
if (this.messageKeysLimit && Object.keys(chain.messageKeys).length >= this.messageKeysLimit) {
console.log("Too many message keys for chain");
return Promise.resolve(); // Stalker, much?
}
@ -36428,8 +36435,8 @@ SessionCipher.prototype = {
}
};
libsignal.SessionCipher = function(storage, remoteAddress) {
var cipher = new SessionCipher(storage, remoteAddress);
libsignal.SessionCipher = function(storage, remoteAddress, options) {
var cipher = new SessionCipher(storage, remoteAddress, options);
// returns a Promise that resolves to a ciphertext object
this.encrypt = cipher.encrypt.bind(cipher);