Commit graph

565 commits

Author SHA1 Message Date
Damir Jelić
b9ddbb11af crypto: Move the inner sas struct into a separate module. 2020-12-10 14:07:47 +01:00
Damir Jelić
7198b0daba crypto: WIP key verification request handling. 2020-12-09 17:18:23 +01:00
Damir Jelić
5babd71341 crypto: Copy the relates to field to the unencrypted content when encrypting 2020-12-09 17:16:03 +01:00
Damir Jelić
d9e5a17ab0 crypto: Use a native Rust sha2 implementation to calculate the commitment 2020-12-08 16:21:29 +01:00
Damir Jelić
b5c61af472 crypto: Move the base64 helpers into a common module. 2020-12-08 16:21:29 +01:00
Damir Jelić
fd705b7d5e crypto: Canonicalize the start event content before calculating the commitment
This fixes: #117.
2020-12-08 16:02:51 +01:00
Damir Jelić
8e53982bcd Merge branch 'master' into crypto-improvements 2020-12-08 15:06:14 +01:00
Damir Jelić
40d13d9b59 cyrpto: Another timing based test that only works on Linux. 2020-12-08 13:37:55 +01:00
Damir Jelić
4ab6ae7f30 crypto: Fix an os_target definition. 2020-12-08 13:15:19 +01:00
Damir Jelić
c8dd6bfd26 crypto: Scope the imports for the unwedging test into the test. 2020-12-08 12:56:16 +01:00
Damir Jelić
b982d36303 crypto: Run the time sensitive tests only on linux. 2020-12-08 12:34:59 +01:00
Damir Jelić
35247fac2a crypto: Fix a lint issue. 2020-12-08 10:50:58 +01:00
Damir Jelić
aa1a64628f crypto: Remove a bunch of unneeded whitespace in a log line. 2020-12-05 14:59:40 +01:00
Damir Jelić
0e66640b9f crypto: Log both user id versions when the device keys mismatch. 2020-12-05 14:59:40 +01:00
Damir Jelić
3f41e5071b crypto: Preserve the relationship info while decrypting events. 2020-12-05 14:59:40 +01:00
Damir Jelić
9eb17e757c matrix-sdk: Update ruma. 2020-12-05 14:59:40 +01:00
Damir Jelić
804bd221b2 crypto: Improve key imports.
This patch changes so key imports load all existing sessions at once
instead loading a single session for each session we are importing. It
removes the need to lock the session when we check the first known index
and exposes the total number of sessions the key export contained.
2020-12-02 11:12:46 +01:00
Damir Jelić
e20b1efae9 crypto: Store private identities and accounts with the Changes struct as well. 2020-12-01 17:14:32 +01:00
Damir Jelić
5d0ff961b2 crypto: Check the Olm message hash if we fail to decrypt an Olm message.
Wether by accident (the next_batch token doesn't get stored properly) or
by malicious intent (the server replays a message) an Olm encrypted to-device
message may appear multiple times.

This is usually fine since nothing bad happens, we don't decrypt the message
and the message gets thrown away.

Since the introduction of Olm session unwedging an undecryptable message
leads to the creation of a new fresh Olm session. To avoid this we
remember which Olm messages we already decrypted so they don't trigger
an unwedging dance.
2020-12-01 14:50:04 +01:00
Damir Jelić
270350cd34 crypto: Save the olm message hash. 2020-12-01 14:38:03 +01:00
Damir Jelić
ae2391791d crypto: Use a released sqlx version. 2020-12-01 13:25:51 +01:00
Damir Jelić
24592adbba crypto: Return a higher level struct when decrypting olm messages instead of tuples 2020-12-01 12:41:11 +01:00
Damir Jelić
efe659910f crypto: Remove some stale TODOs. 2020-12-01 11:20:55 +01:00
Damir Jelić
08babb6d6c crypto: Document the new cross signing methods in the store. 2020-12-01 10:54:41 +01:00
Damir Jelić
7e9baf2707 crypto: Remove some dead code definitions. 2020-11-26 14:15:52 +01:00
Damir Jelić
3073883076 crypto: Fix a clippy warning. 2020-11-26 14:02:35 +01:00
Damir Jelić
7ec5a5ad1a Merge branch 'master' into crypto-improvements 2020-11-26 13:24:57 +01:00
Jonas Platte
0422bae924
Fix clippy lint rc_buffer 2020-11-25 19:01:28 +01:00
Damir Jelić
dedb1eb745 Merge branch 'update-ruma' 2020-11-20 21:21:24 +01:00
Damir Jelić
c40edcf2fc matrix-sdk: Try to lower our compile times, at least in the crypto part for now. 2020-11-20 20:35:48 +01:00
Alejandro Domínguez
95243003c4 Update ruma 2020-11-20 20:14:18 +01:00
Damir Jelić
b27f1b0e34 crypto: Fix some clippy warnings. 2020-10-30 14:38:29 +01:00
Damir Jelić
b67cd4ddd2 crypto: Create a trusted public cross signing identity when we create a private one. 2020-10-30 13:21:14 +01:00
Damir Jelić
44cc1cef71 crypto: Let devices hold on to the private identity. 2020-10-30 11:41:48 +01:00
Damir Jelić
34bec59389 crypto: Hold on to the private identity in the store. 2020-10-30 11:34:55 +01:00
Damir Jelić
cb95f576a5 crypto: Clear out the signatures when signing a device.
This avoids re-uploading all the existing signatures.
2020-10-29 15:37:29 +01:00
Damir Jelić
5c530cf9ee crypto: Upload signatures after verification is done. 2020-10-27 16:39:23 +01:00
Damir Jelić
30a78bb1d6 crypto: Add the private identity to the Sas object. 2020-10-27 14:21:22 +01:00
Damir Jelić
2077ea0ddf crypto: Split out the device_key signing method. 2020-10-27 13:48:51 +01:00
Damir Jelić
e757d605f5 crypto: Allow users to be signed as well. 2020-10-27 13:29:19 +01:00
Damir Jelić
61a5293af5 cyrpto: Document the signing module. 2020-10-26 16:03:59 +01:00
Damir Jelić
6e83a4bbca crypto: Split out the signing module into two files. 2020-10-26 16:03:59 +01:00
Damir Jelić
5c14910126 crypto: WIP cross signing bootstrap. 2020-10-26 16:03:59 +01:00
Damir Jelić
8ed1e37cef crypto: Save the account if we create a new one. 2020-10-23 11:17:37 +02:00
Damir Jelić
5fd004bae5 crypto: Connect the private identity to the verification machine. 2020-10-23 11:17:13 +02:00
Damir Jelić
7de002b128 crypto: Fix some lint issues. 2020-10-22 16:40:05 +02:00
Damir Jelić
f60dc7ed78 crypto: Allow cross signing identities to be stored/restored. 2020-10-22 16:25:25 +02:00
Damir Jelić
78d7f6c10b crypto: Fix a clippy issue. 2020-10-21 17:05:36 +02:00
Damir Jelić
fa25ca4475 crypto: Make the pickle key encryption future proof. 2020-10-21 16:52:40 +02:00
Damir Jelić
c9db63509f crypto: Add error handling to the signing module. 2020-10-21 16:24:10 +02:00
Damir Jelić
ac0df5dea9 crypto: Properly handle errors in the pickle key decryption. 2020-10-21 15:28:43 +02:00
Damir Jelić
d175c47a05 crypto: Use a random pickle key in the sqlite store. 2020-10-21 15:13:21 +02:00
Damir Jelić
959e8450af crypto: Use a transaction to create sqlite tables. 2020-10-21 14:01:27 +02:00
Damir Jelić
dd0642cd59 crypto: Add a pickle key struct. 2020-10-21 13:21:22 +02:00
Damir Jelić
6a7da5a8b6 crypto: Correctly generate a random nonce for pickling of the signing objects. 2020-10-21 12:55:45 +02:00
Damir Jelić
7cab7cadc9 crypto: Rework the cryptostore.
This modifies the cryptostore and storage logic in two ways:
    * The cryptostore trait has only one main save method.
    * The receive_sync method tries to save all the objects in one
    `save_changes()` call.

This means that all the changes a sync makes get commited to the store
in one transaction, leaving us in a consistent state.

This also means that we can pass the Changes struct the receive sync
method collects to our caller if the caller wishes to store the room
state and crypto state changes in a single transaction.
2020-10-20 17:19:37 +02:00
Damir Jelić
728d80ed06 crypto: Connect the cross signing to the main state machine. 2020-10-19 16:03:01 +02:00
Damir Jelić
404cc410cc crypto: Fix the docs and return value of the import_keys method. 2020-10-17 14:39:19 +02:00
Damir Jelić
93f49265a6 crypto: Use a git version of sqlx.
The beta release has a nasty bug where one thread would consume 100% of
CPU.
2020-10-16 19:42:41 +02:00
Damir Jelić
425a07d670 crypto: Don't load all the devices in the sqlite store. 2020-10-16 16:57:26 +02:00
Damir Jelić
4262f1d3b0 crypto: Don't cache inbound group sessions in the sqlite store. 2020-10-16 15:54:50 +02:00
Damir Jelić
b5560d3cb6 crypto: More transactions in the sqlite store. 2020-10-16 15:23:34 +02:00
Damir Jelić
fc54c63a4c crypto: Upgrade sqlx to the beta release.
This change is much needed to enable transactions in our sqlite store,
before this release creating a transaction would take ownership of the
connection, now it just mutably borrows it.
2020-10-16 15:05:53 +02:00
Damir Jelić
e7a24d5e68 crypto: Move the session managers under a common module. 2020-10-16 11:09:55 +02:00
Damir Jelić
b5c9473424 crypto: Test the session unwedging logic. 2020-10-15 15:03:22 +02:00
Damir Jelić
59d7b53242 crypto: Add an user for a key request if the device was marked as wedged. 2020-10-15 15:02:02 +02:00
Damir Jelić
59a7199202 crypto: Initial test for the session manager. 2020-10-15 13:58:35 +02:00
Damir Jelić
d1313b8614 crypto: Fix another clippy warning. 2020-10-14 16:15:26 +02:00
Damir Jelić
4e8ce4cb5d crypto: Fix clippy warnings and don't use the PickleMode for signing pickling. 2020-10-14 16:01:52 +02:00
Damir Jelić
c85fe6bc21 crypto: Initial support for private cross signing identities. 2020-10-14 15:35:06 +02:00
Damir Jelić
3338ecf62a Merge branch 'master' into crypto-improvements 2020-10-13 13:02:02 +02:00
Damir Jelić
1c6a67d864 matrix-sdk: Bump our deps. 2020-10-13 13:01:18 +02:00
Damir Jelić
1cabc0cac9 crypto: Correctly store the uploaded key count when saving the account.
This fixes: #101.
2020-10-13 09:47:49 +02:00
Damir Jelić
bd0ac703a0 crypto: Initial logic for session unwedging. 2020-10-09 15:39:35 +02:00
Damir Jelić
6d2e9cfc02 crypto: Share the users_for_key_claim map between modules. 2020-10-09 11:36:31 +02:00
Damir Jelić
473e49252e crytpo: Get the session from the list of sessions in a safe manner. 2020-10-08 15:56:17 +02:00
Damir Jelić
d96c9f85a1 crypto: Add doces for the get_missing_sessions method. 2020-10-08 14:50:35 +02:00
Damir Jelić
279ce0bba0 crypto: Split out the Olm session handling logic into a separate module. 2020-10-08 14:41:34 +02:00
Damir Jelić
da5ef42719 crypto: Log when we invalidate a group session. 2020-10-08 14:03:01 +02:00
Damir Jelić
723fdeaa06 crypto: Fix a clippy warning. 2020-10-08 12:59:10 +02:00
Damir Jelić
19d513e3c0 crypto: Simplify and test the group session invalidation logic. 2020-10-08 12:40:42 +02:00
Damir Jelić
23ac00c8ec crypto: Initial support for group session invalidation. 2020-10-08 11:16:02 +02:00
Damir Jelić
4019ebf121 crypto: Fix some clippy warnings. 2020-10-07 17:56:29 +02:00
Damir Jelić
9a838abd67 crypto: Log when we're not serving a key request because of a missing session. 2020-10-07 14:22:13 +02:00
Damir Jelić
17d23eb9e5 matrix-sdk: Add automatic key claiming support. 2020-10-07 14:07:47 +02:00
Damir Jelić
8ea0035cd0 crypto: Add the automatic key claim users to the key claim request. 2020-10-07 14:02:50 +02:00
Damir Jelić
06b9c71dbc crypto: Refactor out the key share wait queue. 2020-10-07 12:42:39 +02:00
Damir Jelić
6a8ac62a51 crypto: Remove an unwrap. 2020-10-07 11:57:46 +02:00
Damir Jelić
1e894269c8 crypto: Correctly handle the key share without a session and test it. 2020-10-07 11:57:09 +02:00
Damir Jelić
e5f0f64405 crypto: Initial scaffolding for key shares for devices that are missing a session. 2020-10-06 16:38:42 +02:00
Damir Jelić
e3d24f5c31 crypto: Fix some clippy warnings. 2020-10-01 16:45:13 +02:00
Damir Jelić
02c765f903 crypto: Don't mark outbound group sessions automatically as shared. 2020-10-01 16:31:24 +02:00
Damir Jelić
fc6ff2c78a crytpo: Remove an unneeded map/clone. 2020-10-01 12:46:09 +02:00
Damir Jelić
1d8f01ef11 crypto: Remove the third Device variant. 2020-10-01 12:15:13 +02:00
Damir Jelić
c8ca93c924 crytpo: Let the verification machine hold on to a raw CryptoStore.
This will later be useful when our higher level store wrapper holds on
to a verification machine to return higher level Device objects.
2020-10-01 11:17:27 +02:00
Damir Jelić
d644af7be9 crypto: Remove an unneeded clone. 2020-10-01 09:56:22 +02:00
Damir Jelić
ff2079da91 crypto: Move the group session handling logic into separate module. 2020-09-30 15:43:25 +02:00
Damir Jelić
646f18ae18 crypto: Remove an unused import. 2020-09-29 17:53:11 +02:00
Damir Jelić
2b8d4a21a4 crypto: Connect the key request handling to the main state machine. 2020-09-29 17:40:06 +02:00
Damir Jelić
78badd9af8 crypto: Use the correct event type when sending out forwarded room keys. 2020-09-29 17:36:56 +02:00
Damir Jelić
58aef51770 crypto: Remove an unneeded mutable borrow. 2020-09-29 14:44:18 +02:00
Damir Jelić
8fe1eda169 crypto: Test the full key share flow. 2020-09-29 14:18:03 +02:00
Damir Jelić
84066d4a76 crypto: Split out the Account into a read only portion and one with effects. 2020-09-29 12:03:41 +02:00
Damir Jelić
e1c220e2f7 crypto: Test a key share cycle. 2020-09-29 10:24:54 +02:00
Damir Jelić
798656dac5 crypto: Allow the key request machine to access the outbound group sessions. 2020-09-29 10:09:47 +02:00
Damir Jelić
721c459577 crypto: Collapse an if tree. 2020-09-28 15:07:57 +02:00
Damir Jelić
23173c4a1e crypto: Test our key sharing decision logic. 2020-09-28 14:51:57 +02:00
Damir Jelić
4a8c5ebab0 crypto: Return an enum that describes why we won't serve a key share request. 2020-09-28 14:12:08 +02:00
Damir Jelić
e29508938b crypto: More work on the incoming key request handling. 2020-09-28 13:32:30 +02:00
Damir Jelić
a357536ade crypto: Initial scaffolding for incoming key share handling. 2020-09-28 09:27:16 +02:00
Damir Jelić
f3be27921c crypto: Move the device trust state logic into the read only device. 2020-09-24 12:45:23 +02:00
Damir Jelić
42c4cf2a30 crypto: Test the outgoing requests method instead of accessing the field. 2020-09-24 12:00:22 +02:00
Damir Jelić
c5bece2d58 crypto: Zeroize and remove the session key copies for forwarded room keys. 2020-09-24 11:18:01 +02:00
Damir Jelić
4662ca2e32 crypto: Refactor the one-time key count update logic. 2020-09-24 11:16:15 +02:00
Damir Jelić
5a86b067e4 crypto: Add tests for the identity manager. 2020-09-23 15:45:25 +02:00
Damir Jelić
7c3e751d6e Merge branch 'crypto-improvements' into master 2020-09-23 11:07:49 +02:00
Damir Jelić
95e906e0dc crypto: Save the account if the one-time key count updates. 2020-09-18 20:50:32 +02:00
Damir Jelić
2e3d30d7b4 crypto: Move the identity/device management logic into a separate struct. 2020-09-18 20:50:32 +02:00
Damir Jelić
5b0457dad0 crypto: Remember the users that received the outbound group session. 2020-09-18 18:55:17 +02:00
Damir Jelić
a183584541 crypto: Test that we correctly check the hash when decrypting attachments. 2020-09-18 17:49:44 +02:00
Damir Jelić
562bb5aee3 crypto: Remove some dead key requests code for now. 2020-09-18 17:26:56 +02:00
Damir Jelić
dea3e4adf4 crypto: Document when a key export may panic. 2020-09-18 14:04:39 +02:00
Damir Jelić
5d5d5bb141 crypto: Hook up the key requesting to the main state machine. 2020-09-18 13:50:13 +02:00
Damir Jelić
c58cf71be1 crypto: Send out key request cancellations once we receive a key. 2020-09-18 13:49:46 +02:00
Damir Jelić
af4b00195b crypto: Implement the key/value store for the sqlite store. 2020-09-18 13:42:51 +02:00
Damir Jelić
300b03bd9e crypto: Add more test for the outgoing key requests. 2020-09-17 17:13:42 +02:00
Damir Jelić
a5b195efc7 crypto: Initial tests for the key requests state machine. 2020-09-17 16:55:33 +02:00
Damir Jelić
692f9baa0e crypto: Add logic to handle outgoing key requests. 2020-09-17 16:09:08 +02:00
Damir Jelić
6b24d91ed9 crypto: Add an initial version of our key request state machine. 2020-09-17 14:16:43 +02:00
Damir Jelić
24ce4881c7 crypto: Add a method to save/load arbitrary objects from a CryptoStore.
This actually adds trait methods that save/load strings from the
CryptoStore. We add a wrapper for the CryptoStore since we can't mix
trait objects and generics, so we add generic methods to save/load
anything that implements Serialize/Deserialize.
2020-09-16 16:03:19 +02:00
Damir Jelić
849934b180 crypto: Use a constant for the attachment encryption version. 2020-09-16 12:39:23 +02:00
Damir Jelić
ae894e0ff6 crypto: Finish up the attachment encryption.
This adds docs and proper error handling to the attachment encryption.
Zeroing out the key buffers is added as well.
2020-09-16 12:05:44 +02:00
Damir Jelić
890e6cbc73 crypto: Turn an unwrap into a except. 2020-09-15 17:18:31 +02:00
Damir Jelić
3573614640 crypto: Add some TODOs for the key query handling. 2020-09-15 12:13:35 +02:00
Damir Jelić
a60f60bd7d Merge branch 'master' into encrypted_attachments 2020-09-15 12:04:37 +02:00
Damir Jelić
b628e6286a crypto: Remove an unused import. 2020-09-14 20:27:30 +02:00
Jonas Platte
fb47abcc17
Update ruma 2020-09-14 20:26:52 +02:00
Damir Jelić
2d6882c495 crypto: Use a Read implementation for the attachment encryption as well. 2020-09-14 20:06:44 +02:00
Damir Jelić
51f3d90224 crypto: Move the file encryption modules under a submodule. 2020-09-14 17:14:18 +02:00
Damir Jelić
1a140ecc2f crypto: Initial support for attachment encryption. 2020-09-14 16:38:52 +02:00
Damir Jelić
ffd2843b0a matrix-sdk: Expose the import/export keys methods. 2020-09-11 16:34:39 +02:00
Damir Jelić
618a58ba34 crypto: Add error handling to the key exports. 2020-09-10 17:02:36 +02:00
Damir Jelić
8af18a4df7 crypto: Test the EncryptionSettings conversion. 2020-09-10 16:21:23 +02:00
Damir Jelić
7790c3db8f crypto: Fix a bunch of clippy warnings. 2020-09-10 16:07:28 +02:00
Damir Jelić
e3f4c1849c crypto: Finish up the key export feature. 2020-09-10 15:54:41 +02:00
Damir Jelić
848156213b crypto: Add a PartialEq derive for the exported key struct. 2020-09-10 15:51:39 +02:00
Damir Jelić
23e953d9cf crypto: Hide some methods that shouldn't be public. 2020-09-10 15:49:34 +02:00
Damir Jelić
464e181f66 crypto: Add a method to get all group sessions from the store. 2020-09-10 14:59:20 +02:00
Damir Jelić
7bd0e4975b crypto: Store the forwarding chains for group sessions. 2020-09-09 17:27:10 +02:00
Damir Jelić
127d4c225b crypto: Change the crypto store so we can save multiple group sessions at once. 2020-09-09 16:34:18 +02:00