Commit Graph

11 Commits

Author SHA1 Message Date
Andrea Maria Piana ad7500ed07
Don't delete key without explicit request
We need to wait for messages to be confirmed before we can actually
delete the message key, otherwise if for whatever reason is not
processed we will be unable to receive it again.
2019-02-13 16:28:48 +01:00
Andrea Maria Piana 7279c44c22
Change handling of skipped/deleted keys
The purpose of limiting the number of skipped keys generated is to avoid a dos
attack whereby an attacker would send a large N, forcing the device to
compute all the keys between currentN..N .

Previously the logic for handling skipped keys was:

- If in the current receiving chain there are more than maxSkip keys,
throw an error

This is problematic as in long-lived session dropped/unreceived messages starts
piling up, eventually reaching the threshold (1000 dropped/unreceived
messages).

This logic has been changed to be more inline with signals spec, and now
it is:

- If N is > currentN + maxSkip, throw an error

The purpose of limiting the number of skipped keys stored is to avoid a dos
attack whereby an attacker would force us to store a large number of
keys, filling up our storage.

Previously the logic for handling old keys was:

- Once you have maxKeep ratchet steps, delete any key from
currentRatchet - maxKeep.

This, in combination with the maxSkip implementation, capped the number of stored keys to
maxSkip * maxKeep.

The logic has been changed to:

- Keep a maximum of MaxMessageKeysPerSession

and additionally we delete any key that has a sequence number <
currentSeqNum - maxKeep
2018-11-01 15:15:23 +01:00
Pedro Pombeiro c243ae5a66
Add makefile with lint support (#4) 2018-08-21 11:18:46 +02:00
Andrea Maria Piana 47d1cda18c Allow to store and load sessions (#3)
* Allow storing and loading sessions
2018-08-21 11:12:32 +02:00
Andrea Maria Piana 649676cce3 Add error handling in persistence 2018-08-14 12:26:54 +02:00
Ivan Tomilov 3170609485 Wrote negative constructor tests 2017-06-19 22:56:13 +07:00
Ivan Tomilov 3aa8e4ef8f Wrote TestState_RatchetEncrypt_Basic 2017-06-19 22:10:59 +07:00
Ivan Tomilov b17d29f335 Moved some tests from session_test.go to state_test.go 2017-06-19 21:21:57 +07:00
Ivan Tomilov 26c18ebd0e Moved dh key pair generation from state to session 2017-06-19 14:05:04 +07:00
Ivan Tomilov 505a37f424 Updated usage example in README.md 2017-06-19 13:42:14 +07:00
Ivan Tomilov 88d085e289 Renamed from state_test.go into session_tst.go 2017-06-19 13:04:46 +07:00