|
|
|
@ -35291,8 +35291,6 @@ var Internal = Internal || {};
|
|
|
|
|
result = result | (a[i] ^ b[i]);
|
|
|
|
|
}
|
|
|
|
|
if (result !== 0) {
|
|
|
|
|
console.log('Our MAC ', dcodeIO.ByteBuffer.wrap(calculated_mac).toHex());
|
|
|
|
|
console.log('Their MAC', dcodeIO.ByteBuffer.wrap(mac).toHex());
|
|
|
|
|
throw new Error("Bad MAC");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -36016,14 +36014,7 @@ libsignal.SessionBuilder = function (storage, remoteAddress) {
|
|
|
|
|
this.processV3 = builder.processV3.bind(builder);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function SessionCipher(storage, remoteAddress, options) {
|
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
|
|
if (typeof options.messageKeysLimit === 'undefined') {
|
|
|
|
|
options.messageKeysLimit = 1000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.messageKeysLimit = options.messageKeysLimit;
|
|
|
|
|
function SessionCipher(storage, remoteAddress) {
|
|
|
|
|
this.remoteAddress = remoteAddress;
|
|
|
|
|
this.storage = storage;
|
|
|
|
|
}
|
|
|
|
@ -36296,15 +36287,14 @@ SessionCipher.prototype = {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
fillMessageKeys: function(chain, counter) {
|
|
|
|
|
if (this.messageKeysLimit && Object.keys(chain.messageKeys).length >= this.messageKeysLimit) {
|
|
|
|
|
console.log("Too many message keys for chain");
|
|
|
|
|
return Promise.resolve(); // Stalker, much?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (chain.chainKey.counter >= counter) {
|
|
|
|
|
return Promise.resolve(); // Already calculated
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (counter - chain.chainKey.counter > 2000) {
|
|
|
|
|
throw new Error('Over 2000 messages into the future!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (chain.chainKey.key === undefined) {
|
|
|
|
|
throw new Error("Got invalid request to extend chain after it was already closed");
|
|
|
|
|
}
|
|
|
|
@ -36433,8 +36423,8 @@ SessionCipher.prototype = {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
libsignal.SessionCipher = function(storage, remoteAddress, options) {
|
|
|
|
|
var cipher = new SessionCipher(storage, remoteAddress, options);
|
|
|
|
|
libsignal.SessionCipher = function(storage, remoteAddress) {
|
|
|
|
|
var cipher = new SessionCipher(storage, remoteAddress);
|
|
|
|
|
|
|
|
|
|
// returns a Promise that resolves to a ciphertext object
|
|
|
|
|
this.encrypt = cipher.encrypt.bind(cipher);
|
|
|
|
|