Commit Graph

28 Commits

Author SHA1 Message Date
Andrea Maria Piana 1e33002ac8
[do-not-merge] Bug/allow returning an error in dh (#11)
* Remove encryted header version

* Return error from DH & Encrypt

* Use slices instead of fixed array for keys

In order to support multiple types of curves, this commits changes the
type of `Key` from `[32]byte` to `[]byte`. This is useful as most of the
eliptic keys have a size of a compressed key of `33 bytes` instead of
`32 bytes`, which the default implemetation uses (curve25519).
2019-10-31 16:13:07 +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
Ivan Tomilov 3170609485 Wrote negative constructor tests 2017-06-19 22:56:13 +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 88d085e289 Renamed from state_test.go into session_tst.go 2017-06-19 13:04:46 +07:00
Ivan Tomilov ddbc01b113 Wrote option tests 2017-06-19 13:02:38 +07:00
Ivan Tomilov e71374e5da Fixed tests 2017-06-19 11:02:10 +07:00
Ivan Tomilov b3edc46c01 Moved options into a separate file 2017-06-19 10:09:18 +07:00
Ivan Tomilov 9367c98eac (unstable) Implemented RatchetDecryptHE 2017-06-17 00:09:18 +07:00
Ivan Tomilov ade5042528 (unstable) Implemented RatchetEncryptHE plus plenty of refactoring
1. Renamed state to session, created state and included it in session
2. Removed AssociatedData type
3. Implemented message header encoding and decoding
4. Added a paragraph about header encryption into README.md
5. Added PublicKeyer interface
6. Added chain structs
7. Added NewWithRK constructor
2017-06-16 20:37:46 +07:00
Ivan Tomilov 71a3b81ad2 Added a negative test on communication 2017-06-14 19:34:08 +07:00
Ivan Tomilov e1417340f3 Added a negative test for MaxKeep 2017-06-14 19:19:19 +07:00
Ivan Tomilov 1f8ef95d52 Skipped message are now in fact deleted after 10 ratchet steps 2017-06-14 18:09:31 +07:00
Ivan Tomilov fffab73a03 Implemented skipped message keys deletion, switched [32]byte to Key, added KeysStorage.DeletePk 2017-06-14 13:29:46 +07:00
Ivan Tomilov 4151180300 Wrote a test that invalid signature won't pollute state 2017-06-14 09:37:45 +07:00
Ivan Tomilov cc834c76e2 Added the PublicKey() method to the interface 2017-06-14 09:31:15 +07:00
Ivan Tomilov 09443d5ad5 Handled TODOs 2017-06-14 00:15:32 +07:00
Ivan Tomilov f8cd076cf3 Tests for KeysStorageInMemory 2017-06-14 00:00:33 +07:00
Ivan Tomilov 25eacbff6a MaxSkip is now handled correctly: no more than MaxSkip messages is allowed in a single chain 2017-06-13 23:46:11 +07:00
Ivan Tomilov 4a3f81461e Wrote a failing test for skipped messages 2017-06-13 20:44:20 +07:00
Ivan Tomilov 1712314e37 Wrote TestState_RatchetDecrypt_CommunicationPingPong 2017-06-13 15:46:53 +07:00
Ivan Tomilov 6c1e364f87 Fixed tests 2017-06-13 15:39:59 +07:00
Ivan Tomilov 373cd7b621 Wrote decrypt tests 2017-06-13 15:39:07 +07:00
Ivan Tomilov 9c273917f4 Wrote TestState_RatchetDecrypt_BasicCommunication 2017-06-13 13:56:56 +07:00
Ivan Tomilov 5609071a7a Wrote TestState_RatchetEncrypt_Basic 2017-06-13 09:19:29 +07:00
Ivan Tomilov 7ecda0d04c Implemented WithRemoteKey option tests 2017-06-13 09:09:49 +07:00
Ivan Tomilov 60fb66f8fb Started implementing state.New tests 2017-06-13 09:00:46 +07:00