Commit Graph

107 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 d4e8261a76
Update references to tiabc 2019-09-10 10:14:35 +02:00
Andrea Maria Piana f2aeb83683
Merge pull request #8 from status-im/feature/dont-delete-key-until-confirmed
Don't delete key without explicit request
2019-02-14 10:10:03 +01:00
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 4dcb6cba28
Merge pull request #6 from status-im/features/delete-skipped-messages
Change handling of skipped/deleted keys
2018-11-02 07:41:21 +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
Andrea Maria Piana 321788dbb6 Save session when skipping keys (#5) 2018-09-12 19:00:48 +02: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 57d54b111a Use provided crypto in chains 2018-08-16 16:03:58 +02:00
Andrea Maria Piana 649676cce3 Add error handling in persistence 2018-08-14 12:26:54 +02:00
Ivan Tomilov 9d7f37c630 Groomed a bit 2017-06-20 11:36:38 +07:00
Ivan Tomilov 1aaec96807 Made bob header keys non-empty so that he could safely encrypt headers right away 2017-06-20 11:28:24 +07:00
Ivan Tomilov 5b9fe10107 Added information on header encryption to readme 2017-06-20 10:46:15 +07:00
Ivan Tomilov 1e6b6aef3f Wrote tests for the header encrypted modification 2017-06-20 09:54:31 +07:00
Ivan Tomilov 3170609485 Wrote negative constructor tests 2017-06-19 22:56:13 +07:00
Ivan Tomilov f041431779 TestSessionHE_RatchetDecrypt_CommunicationBobSends 2017-06-19 22:40:55 +07:00
Ivan Tomilov 71e3dd7771 Wrote TestSessionHE_RatchetDecrypt_CommunicationAliceSends 2017-06-19 22:36:27 +07:00
Ivan Tomilov 3aa8e4ef8f Wrote TestState_RatchetEncrypt_Basic 2017-06-19 22:10:59 +07:00
Ivan Tomilov 05040db3bf Wrote constructor tests for a header-encrypted session 2017-06-19 22:05:37 +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
Ivan Tomilov ddbc01b113 Wrote option tests 2017-06-19 13:02:38 +07:00
Ivan Tomilov 5fa25a1215 Wrote test for KeysStorageInMemory.All() 2017-06-19 12:17:05 +07:00
Ivan Tomilov e9c7295c76 Wrote tests for message encode and decode 2017-06-19 12:13:14 +07:00
Ivan Tomilov 9b8364b1b0 Wrote tests for kdfChain and kdfRootChain 2017-06-19 11:50:06 +07:00
Ivan Tomilov e71374e5da Fixed tests 2017-06-19 11:02:10 +07:00
Ivan Tomilov 764cd3686c Renamed crypto_recommended.go into default_crypto.go 2017-06-19 10:34:06 +07:00
Ivan Tomilov c5a96e62c8 Split session into session and sessionHE and put them in different files 2017-06-19 10:27:47 +07:00
Ivan Tomilov 35d10ddcde Moved as much logic as possible into state 2017-06-19 10:21:46 +07:00
Ivan Tomilov a2118fdefb Session interface now doesn't contain public key 2017-06-19 10:12:07 +07:00
Ivan Tomilov b3edc46c01 Moved options into a separate file 2017-06-19 10:09:18 +07:00
Ivan Tomilov 1a718966f9 Moved more fields from session into state 2017-06-19 10:02:19 +07:00
Ivan Tomilov 37688f542c (unstable) Moved chains to a separate file 2017-06-19 09:22:17 +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 8b5f7921a6 Added comments 2017-06-14 19:42:59 +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 d3aa2e75ba Added json tags to Message and MessageHeader 2017-06-14 19:16:03 +07:00
Ivan Tomilov 3c4ad2c0bd Changed old skipped messages deletion from 10 to 100 ratchet steps 2017-06-14 18:10:15 +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 4a463db109 Key.String() test 2017-06-14 16:50:03 +07:00
Ivan Tomilov 49a2ae4295 Wrote more tests for KeysStorage 2017-06-14 16:46:11 +07:00
Ivan Tomilov f37a0867cd dhPair.String() test 2017-06-14 16:35:50 +07:00
Ivan Tomilov 6cbd7777ee Changes to state maps are now only applied at the end of RatchetDecrypt 2017-06-14 14:47:07 +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