From 8334fa56993321d1e2945713f06ee5b298b81d37 Mon Sep 17 00:00:00 2001 From: lilia Date: Wed, 16 Nov 2016 17:03:01 +0100 Subject: [PATCH] Double the max old ratchet list length Attempt to mitigate Bad MAC errors due to repeated ciphertext from more than 5 exchanges ago. --- dist/libsignal-protocol.js | 5 +++-- src/SessionRecord.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dist/libsignal-protocol.js b/dist/libsignal-protocol.js index bf97ef8..13353bc 100644 --- a/dist/libsignal-protocol.js +++ b/dist/libsignal-protocol.js @@ -35515,6 +35515,7 @@ Internal.ChainType = { Internal.SessionRecord = function() { 'use strict'; var ARCHIVED_STATES_MAX_LENGTH = 40; + var OLD_RATCHETS_MAX_LENGTH = 10; var SESSION_RECORD_VERSION = 'v1'; var StaticByteBufferProto = new dcodeIO.ByteBuffer().__proto__; @@ -35747,8 +35748,8 @@ Internal.SessionRecord = function() { removeOldChains: function(session) { // Sending ratchets are always removed when we step because we never need them again // Receiving ratchets are added to the oldRatchetList, which we parse - // here and remove all but the last five. - while (session.oldRatchetList.length > 5) { + // here and remove all but the last ten. + while (session.oldRatchetList.length > OLD_RATCHETS_MAX_LENGTH) { var index = 0; var oldest = session.oldRatchetList[0]; for (var i = 0; i < session.oldRatchetList.length; i++) { diff --git a/src/SessionRecord.js b/src/SessionRecord.js index cb6d4dc..c0cb3e6 100644 --- a/src/SessionRecord.js +++ b/src/SessionRecord.js @@ -16,6 +16,7 @@ Internal.ChainType = { Internal.SessionRecord = function() { 'use strict'; var ARCHIVED_STATES_MAX_LENGTH = 40; + var OLD_RATCHETS_MAX_LENGTH = 10; var SESSION_RECORD_VERSION = 'v1'; var StaticByteBufferProto = new dcodeIO.ByteBuffer().__proto__; @@ -248,8 +249,8 @@ Internal.SessionRecord = function() { removeOldChains: function(session) { // Sending ratchets are always removed when we step because we never need them again // Receiving ratchets are added to the oldRatchetList, which we parse - // here and remove all but the last five. - while (session.oldRatchetList.length > 5) { + // here and remove all but the last ten. + while (session.oldRatchetList.length > OLD_RATCHETS_MAX_LENGTH) { var index = 0; var oldest = session.oldRatchetList[0]; for (var i = 0; i < session.oldRatchetList.length; i++) {