Commit graph

126 commits

Author SHA1 Message Date
Tulir Asokan
315d2ab17d all: fix staticcheck issues
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run
2025-12-08 00:07:25 +02:00
Tulir Asokan
fa90bba820 crypto: don't check otk count if sharing new keys 2025-09-26 19:48:22 +03:00
Tulir Asokan
5dbab3ae99 crypto/machine: don't clear account on Destroy()
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run
2025-09-11 14:46:21 +03:00
Tulir Asokan
84e5d6bda1 crypto/machine: allow canceling background context 2025-09-11 14:13:18 +03:00
Tulir Asokan
69869f7cb5 crypto: log active driver 2025-09-11 14:12:35 +03:00
Tulir Asokan
faa1c5ff8d crypto/machine: log when loading olm account
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run
2025-09-10 16:46:05 +03:00
Tulir Asokan
19f3b2179c pre-commit: ban log.Str(x.String()) 2025-08-29 11:07:16 +03:00
Tulir Asokan
6eb4c7b17f crypto/keybackup: allow importing room keys without saving
Some checks failed
Go / Lint (latest) (push) Has been cancelled
Go / Build (old, libolm) (push) Has been cancelled
Go / Build (latest, libolm) (push) Has been cancelled
Go / Build (old, goolm) (push) Has been cancelled
Go / Build (latest, goolm) (push) Has been cancelled
2025-05-04 14:09:06 +03:00
Tulir Asokan
99ff0c0964 crypto/decryptmegolm: add option to ignore failing to parse content after decryption
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run
2025-04-14 23:08:11 +03:00
Tulir Asokan
0c1fc68ec3 crypto/machine: return unhandled to-device events in HandleEncryptedEvent 2025-03-04 02:37:08 +02:00
Tulir Asokan
e879ad19cc crypto/decryptmegolm: hide state event decryption behind flag 2025-02-23 16:24:03 +02:00
Tulir Asokan
e844153658 crypto/decryptolm: store olm hashes to prevent errors if they're repeated 2024-12-20 14:48:50 +02:00
Nick Mills-Barrett
15ab545e72
crypto: add background context to olm machine
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run
Defaults to `context.Background()` but can be passed any context to
support cancelling background jobs the olm instance might be executing.
2024-12-16 15:45:57 +00:00
Tulir Asokan
1170825b09 crypto: fix key share count log
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run
2024-11-21 18:23:04 +02:00
Tulir Asokan
830136b49d crypto: avoid data race in HandleOTKCounts
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run
2024-09-16 17:15:19 +03:00
Tulir Asokan
6f9927c399 crypto: make OTK count for other user log less noisy 2024-09-15 01:12:21 +03:00
Tulir Asokan
a0d427e4df crypto: add hack to avoid logging about OTK counts for cross-signing keys
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run
2024-09-02 01:20:22 +03:00
Tulir Asokan
238cacf2d5 client,crypto,appservice: add MSC3202 features 2024-08-30 17:27:12 +03:00
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