Throw error if asked to jump forward in chain by over 2000 (#43)

As libsignal-protocol-java has had for more than three years. This check
was present when it was first pulled out into its own repo in late 2014:

60800e1556/src/main/java/org/whispersystems/libaxolotl/SessionCipher.java (L383)
This commit is contained in:
Scott Nonnenberg 2018-02-14 11:35:16 -08:00 committed by GitHub
parent 5679fe7a49
commit d08705329a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -36303,6 +36303,10 @@ SessionCipher.prototype = {
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");
}

View File

@ -287,6 +287,10 @@ SessionCipher.prototype = {
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");
}