Commit graph

108 commits

Author SHA1 Message Date
Tulir Asokan
0443daef0e crypto: use exzerolog.ArrayOfStrs instead of custom function 2024-06-30 01:14:27 +03:00
Tulir Asokan
0b07ae9942 Ignore conflicts when inserting withheld group sessions 2024-05-26 18:27:48 +03:00
Tulir Asokan
a2169274da Include room ID and first known index in SessionReceived callback 2024-05-26 00:59:30 +03:00
Tulir Asokan
3bd42f5a82 Add option to disable tracking megolm session ratchet state
The tracking is meant for bridges/bots that want to delete old ratchet states
after they're not needed, but for normal clients it's just unnecessary overhead
2024-05-16 17:14:13 +03:00
Sumner Evans
de0347db00
crypto: fix usages of Store interface
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2024-05-14 12:47:45 -06:00
Sumner Evans
d10103dcf5
crypto/encryptmegolm: return error if sharing outbound session fails
This allows us to catch and throw "database is locked" errors. This will
ensure that if saving the key fails, then we won't share the key out to
anyone.

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2024-05-13 21:47:45 -06:00
Sumner Evans
ff9e2e0f1d
machine/ShareKeys: save keys before sending server request in case it fails
Signed-off-by: Sumner Evans <sumner@beeper.com>
2024-04-19 08:47:36 -06:00
Toni Spets
bb6c88faf3 Add callback on megolm session receive 2024-03-06 15:06:21 +02:00
Sumner Evans
6bfa468ee7
crypto: remove old verification code
Signed-off-by: Sumner Evans <sumner@beeper.com>
2024-02-09 10:20:48 -07:00
Toni Spets
11c2907f2e Database level support for key backup versioning
This doesn't plumb anything in yet but adds the columns and types for an
external implementation.

Key backup version is now typed.
2024-02-01 13:22:32 +02:00
Toni Spets
8dc80b3178 Share room keys to known devices on request
If we have shared a session with a device once, allow asking for it
again.
2024-01-26 13:52:25 +02:00
Toni Spets
94664f1c8a Secret sharing implementation 2024-01-24 12:56:46 +02:00
Toni Spets
9f12b80726 Open up OlmMachine event handlers 2024-01-17 12:15:21 +02:00
Toni Spets
6ac759c8ff Only skip fetching keys during Megolm decryption if disabled
Blanket disabling caused a lot of side effects which were hard to
deal with without major refactoring.

This should probably be an argument to DecryptMegolm instead of a
flag.
2024-01-17 12:15:21 +02:00
Toni Spets
970ba1a907 Store own device keys on init 2024-01-15 13:13:10 +02:00
Tulir Asokan
308e3583b0 Add contexts to event handlers 2024-01-13 18:56:12 +02:00
Toni Spets
a3883fcf6f Allow disabling automatic key fetching for Olm machine
Many crypto operations in the Olm machine have a possible side effect of
fetching keys from the server if they are missing. This may be undesired
in some special cases.

To tracking which users need key fetching, CryptoStore now exposes APIs
to mark and query the status.
2024-01-12 14:12:47 +02:00
Toni Spets
8da3a17402 Add context to OLM machine LoadDevices
As there's a side effect of going to the crypto store we want the
context to at least exist for now.
2024-01-10 13:25:44 +02:00
Tulir Asokan
25bc36bc7a Add more contexts everywhere 2024-01-07 22:45:02 +02:00
Tulir Asokan
48bfc596f0 Fix incorrect context.Backgrounds 2024-01-07 15:35:58 +02:00
Joakim Recht
753cdb2e1c
Add context parameter to all client and bridge API functions (#144) 2023-12-15 16:23:31 +02:00
Sumner Evans
c273e40a12
bridge/crypto: add ShareKeys function to CryptoHelper
Signed-off-by: Sumner Evans <sumner@beeper.com>
2023-08-10 08:30:55 -06:00
Tulir Asokan
5b04875090 Add option to not rotate keys when devices change 2023-06-02 18:15:43 +03:00
Tulir Asokan
1696b56e50 Add some more logs 2023-04-12 16:09:32 +03:00
Tulir Asokan
7c98416947 Add option to disable storing outbound keys in inbound table 2023-04-12 15:59:49 +03:00
Tulir Asokan
d03c193a31 Add appservice listener for room key acks 2023-04-12 15:55:28 +03:00
Tulir Asokan
ad073fdc6e Don't redact previous sessions when receiving a scheduled one 2023-04-12 14:46:18 +03:00
Tulir Asokan
87d2cbdfe6 Fix mistakes and change db upgrade message 2023-04-12 12:27:55 +03:00
Tulir Asokan
00090f6e78 Delete expired keys periodically 2023-04-11 13:13:45 +03:00
Tulir Asokan
43d58fbad2 Redact megolm sessions when device is deleted 2023-04-11 12:55:23 +03:00
Tulir Asokan
6879d6b693 Delete megolm sessions when receiving new one and when session is fully used 2023-04-11 11:42:13 +03:00
Tulir Asokan
20df20d25a Ratchet inbound sessions on decrypt and delete outbound on ack 2023-04-10 16:27:05 +03:00
Tulir Asokan
ae03517eb7 Remove unused traceID param 2023-04-10 13:06:36 +03:00
Sumner Evans
bba3d08d27
crypto/machine: fix typo in log
Signed-off-by: Sumner Evans <sumner@beeper.com>
2023-03-29 10:51:58 +02:00
Tulir Asokan
8d2d226c8c Use floats instead of strings for logging durations 2023-03-04 14:38:41 +02:00
Tulir Asokan
5a66a33d4a Add structs for MSC3952 2023-03-01 17:40:54 +02:00
Tulir Asokan
87bfbbea2e Don't import appservice module from crypto 2023-02-24 15:16:42 +02:00
Tulir Asokan
cd081f597d Move some crypto logs to debug level 2023-02-24 14:19:41 +02:00
Tulir Asokan
9d8cb0223c Switch bridge module to zerolog 2023-02-24 12:20:47 +02:00
Tulir Asokan
55e6fb593c Switch crypto module to zerolog 2023-02-19 22:45:43 +02:00
Tulir Asokan
0e872e597c Remove deprecated DeviceIdentity alias 2023-02-19 22:35:52 +02:00
Tulir Asokan
a7f1f1e3b6 Add simplified crypto helper for clients
Fixes #19
Fixes #2
2023-02-19 03:22:14 +02:00
Tulir Asokan
27bace5ffa Handle race conditions in WaitForSession 2022-11-09 17:06:35 +02:00
Tulir Asokan
f7d28cc18d Try to avoid race conditions in OTK upload when using MSC3202 2022-10-16 11:20:58 +03:00
Tulir Asokan
a64afd0fe6 Run gofmt with Go 1.19 for godocs 2022-08-04 11:37:35 +03:00
Tulir Asokan
d1d7f999f7 Move DeviceIdentity and Fingerprint to id package 2022-07-05 11:56:45 +03:00
Tulir Asokan
9162944672 Add cross-signing TOFU support 2022-06-23 14:42:05 +03:00
Tulir Asokan
6d5a9d184c Make required trust level in e2be configurable 2022-06-22 20:05:22 +03:00
Tulir Asokan
f8f9fe45cb Handle room key requests in a goroutine 2022-06-06 17:38:38 +01:00
Tulir Asokan
72d5a9abf0 Add more detailed logs for debugging olm decryption delays 2021-12-17 00:51:47 +02:00