Commit Graph

8853 Commits

Author SHA1 Message Date
Richard van der Hoff
dcc32da55a Merge pull request #3448 from matrix-org/rav/fix_backup_import
Crypto: fix backed-up keys being re-backed-up
2024-05-23 16:20:32 +01:00
Richard van der Hoff
0777aa6ece crypto: Remove Olm::import_room_keys altogether 2024-05-23 15:53:21 +01:00
Richard van der Hoff
3945071446 crypto: Update changelog 2024-05-23 15:53:16 +01:00
Richard van der Hoff
05e4d7a502 ffi: Deprecate import_decrypted_room_keys
... and expose a new method `import_room_keys_from_backup` which does the right
thing.
2024-05-23 15:52:22 +01:00
Richard van der Hoff
ba38d0c1de sdk: avoid deprecated BackupMachine::import_backed_up_room_keys
... and use its replacement, `Store::import_room_keys`
2024-05-23 15:52:22 +01:00
Richard van der Hoff
f7cc17e1e0 crypto: Deprecate BackupMachine::import_backed_up_room_keys
This whole method is a bit broken. It assumes that, when we did an import from
backup, the backup that they came from is the same as the "current" version.

We *could* add another argument, but to be honest I find the whole method a bit
pointless. It's not particularly tied to the `BackupMachine` abstraction. Let's
instead expose `Store::import_room_keys` and
`ExportedRooomKey::from_backed_up_room_key` publicly, and tell callers to use
that directly.
2024-05-23 15:52:22 +01:00
Richard van der Hoff
f77d2cd83f crypto: Use new CryptoStore::save_inbound_group_sessions method
When we are importing a batch of room keys, use the newly-added
`CryptoStore::save_inbound_group_sessions` method instead of
`CryptoStore::save_changes`.

To do this, we need to pass the backup version into `Store::import_room_keys`
instead of just `from_backup` flag.
2024-05-23 15:52:22 +01:00
Richard van der Hoff
4cd619ccdd crypto: New method CryptoStore::save_inbound_group_sessions
When we add a batch of inbound group sessions to the store, if they came from a
backup, we need to record which backup version they came from.
`CryptoStore::save_changes` doesn't give us an easy way to set the backup
version (we could add it to the `Changes` struct, but ugh).

So, we add a new method `save_inbound_group_sessions` which takes the backup
version as a separate param. This works fine, because whenever we import
sessions there are no other changes to store.

The new method isn't used outside of tests yet -- that comes in a follow-up
commit.
2024-05-23 15:52:22 +01:00
Richard van der Hoff
66aae2a0b5 crypto: Add a failing test demonstrating our problem 2024-05-23 15:52:22 +01:00
Damir Jelić
7fb57ea271 chore: Move the cross-process lock enabling into a separate method 2024-05-23 15:31:25 +02:00
Damir Jelić
4d9e41871e chore: The e2ee initialization tasks method doesn't need to return an error 2024-05-23 15:31:25 +02:00
Stefan Ceriu
f672f17fcf feat(calls): add support for sending Matrix RTC call notifications 2024-05-23 15:07:13 +02:00
Benjamin Bouvier
13ceb3e745 sdk: make use of the WeakClient in the encryption/ directory too 2024-05-23 12:20:17 +02:00
Benjamin Bouvier
6250677493 sdk: move the WeakRoom into room/mod.rs
This moves code around, and tweaks the behavior:

- `WeakRoom::get()` returns an `Option`, that will be None if the client
is missing or the room is missing.
- `PaginableRoom` for `WeakRoom` will now return a default response if
the room could not be reconstructed from the weak room. It's fine to do
so because we're in a shutdown context.
2024-05-23 12:20:17 +02:00
Benjamin Bouvier
f1dcfd6332 event cache: keep a weak link to the room when paginating 2024-05-23 12:20:17 +02:00
Benjamin Bouvier
c40b3e768e sdk: add failing test for the strong Client <-> EventCache cycle 2024-05-23 12:20:17 +02:00
Benjamin Bouvier
3eaac27789 sdk: introduce a WeakClient data structure 2024-05-23 12:20:17 +02:00
Benjamin Bouvier
affb5d195e day dividers: remove all the trailing day dividers if needs be
multipletrailing
2024-05-23 12:19:07 +02:00
Benjamin Bouvier
7995c046b4 day dividers: tweak invariant
It's possible the timeline starts with a read marker, in which case the
first item won't be a day divider; in that case, check for the next
item, if present.

test_start_with_read_marker
2024-05-23 12:19:07 +02:00
Benjamin Bouvier
612ed3b603 day dividers: don't remove the final entry if it was already scheduled for removal 2024-05-23 12:19:07 +02:00
Ivan Enderlin
c5f4168dd6 Merge pull request #3442 from matrix-org/rav/no_device_update_on_unchanged
crypto: emit no `identities_stream` items on no-op changes
2024-05-23 09:31:15 +02:00
Ivan Enderlin
7ea804bd2a Merge pull request #3443 from matrix-org/valere/apple_binding_update_podspec
Apple Bindings | Update SDKCrypto podspec files
2024-05-23 09:23:55 +02:00
Valere
748c3d514a Apple Bindings | Update SDKCrypto podspec files 2024-05-22 19:50:37 +02:00
Richard van der Hoff
818778cdf3 Add a test for invalid responses
This was untested before, and it seems the coverage gate is now sad.
2024-05-22 17:23:11 +01:00
Richard van der Hoff
2a605deaa5 changelog 2024-05-22 13:42:57 +01:00
Richard van der Hoff
a154cd4640 crypto: emit no stream update for unchanged devices
There is no need to emit a notification from `identities_stream` when all
devices are unchanged since last time.
2024-05-22 13:42:57 +01:00
Richard van der Hoff
eee0dc4e87 crypto: indicate when a device was updated
update `ReadOnlyDevice::update_device` to return a bool indicating whether
anything is changing.
2024-05-22 13:42:57 +01:00
Ivan Enderlin
fa554455b7 Merge pull request #3334 from matrix-org/valere/fix_crypto_binding_apple_script
crypto: Apple Crypto Bindings | Fix crypto xcframework script
matrix-sdk-crypto-ffi-0.4.1
2024-05-22 11:43:47 +02:00
Valere
b430d95c0a Workflow | only add the needed target for script 2024-05-22 11:29:01 +02:00
Richard van der Hoff
d7a887766c indexeddb: expose new method IndexeddbCryptoStore::open_with_key (#3423)
Allow applications to skip the PBKDF2 operation if they already have a cryptographically secure key,
instead using a simple HKDF to derive a key.

In order to maintain compatibility for existing element-web sessions, if we discover that we have an
existing store that was encrypted with a key derived from PBKDF2, then we reconstruct what
element-web used to do: specifically, we base64-encode the key to obtain the "passphrase" that
was previously passed in. If that matches, we know we've got the right key, and can update the
meta store accordingly.

Part of a resolution to element-hq/element-web#26821.

Signed-off-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: Damir Jelić <poljar@termina.org.uk>
2024-05-22 09:07:45 +01:00
Valere
ee040aba60 split for do in several lines 2024-05-22 09:55:25 +02:00
Valere
f7e06d0c20 Generate ffi files only using aarch64-apple-ios 2024-05-22 09:55:25 +02:00
Valere
d2ecf461d0 fix script 2024-05-22 09:55:25 +02:00
Valere
a1bbe9d810 reduce build time of CI check 2024-05-22 09:55:25 +02:00
Valere
20ada4014d fix target name 2024-05-22 09:55:24 +02:00
Valere
604190d3ca CI: Test CrypoFFI XCFramework generation 2024-05-22 09:55:24 +02:00
Valere
6ad26fff5c remove unneeded \ at end of script 2024-05-22 09:54:43 +02:00
Valere
de989b2c51 fmt 2024-05-22 09:54:43 +02:00
Valere
ea4737269f Fix crypto xcframework apple bindings 2024-05-22 09:54:43 +02:00
Kegan Dougal
794b11a0ce ci: Add a step running complement crypto (#3400)
Add a CI step running complement crypto, automatically matching the complement-crypto branch name based on the current branch name, if needs be.

Signed-off-by: Kegan Dougal <7190048+kegsay@users.noreply.github.com>
2024-05-21 16:34:39 +02:00
Benjamin Bouvier
dba7cf39e6 day dividers: record the insert position when applying an operation based on the previous item
We could end up, like in the regression test, with a sequence of
operations like that:

- remove day divider @ i+1 (because it's redundant with one @ i)
- remove day divider @ i (because it's useless, since the event before
the day divider and after the day divider use the same date).

In that case, it would break the non-decreasing invariant: we'd apply an
operation on the array @ i+1, then @ i, which troubles the offset
computation.

Instead, when doing an operation based on the "prev_item" (now with a
small helper struct, to facilitate understanding of each field), we also
record the insertion order for the operation itself: it's always "at the
end of the operation order, at the time we're looking at it", so
equivalent to a "push_back" if there's no operation in between; but that
ensures that we'll do the operation in a non-decreasing order. For
instance in the above test case, the Remove(i) is now inserted before
the Remove(i+1), instead of after.
2024-05-21 12:45:59 +02:00
Benjamin Bouvier
1a872ac383 day dividers: only run the poisoning check for DayDividerAdjuster::drop if we're not already panicking 2024-05-21 12:45:59 +02:00
Andy Balaam
7bce12ca70 Merge pull request #3320 from matrix-org/andybalaam/fast-backup-reset-in-memorystore2
crypto: MemoryStore uses backup versions to track which sessions are backed up
2024-05-21 09:57:26 +01:00
Andy Balaam
2652b77a1b crypto: MemoryStore uses backup versions to track which sessions are backed up 2024-05-21 09:44:39 +01:00
Andy Balaam
f310db44a3 crypto: Test for resetting backups by asking for new version 2024-05-21 09:43:40 +01:00
Benjamin Bouvier
5df53d7338 timeline queue refactoring: address review comments 2024-05-20 11:18:43 +02:00
Benjamin Bouvier
9575ee92d4 timeline queue: unify updating event send state into a single place 2024-05-20 11:18:43 +02:00
Benjamin Bouvier
e49d62988b timeline queue: tiny refactorings
A few renamings here and there, making use of `as_variant!` a bit more,
adding a few comments,…
2024-05-20 11:18:43 +02:00
Benjamin Bouvier
8867a03c07 memory state store: correctly save user avatar url
With a regression test.

Fixes #3432.
2024-05-20 11:03:07 +02:00
Kévin Commaille
6c18bcf748 sdk: Improvements around generate_image_thumbnail (#3415)
* sdk: Return a Thumbnail from generate_image_thumbnail

We have already all the data for it.
Also fixes an error where the thumbnail format was assumed to always be
JPEG.

* sdk: Allow to select the format of the generated thumbnail

Sending an attachment could often fail if the image crate
cannot encode the thumbnail to the same format as the original.
This allows to select a known supported format to always
be able to generate a thumbnail.

* sdk: Do not return error of thumbnail generation for SendAttachment

Since the thumbnail is optional, failing to generate it should not
stop us from sending the attachment.

* Apply code review fixes
* sdk: Split attachment tests in separate file
* sdk: Add integration tests for generating thumbnails
* Revert wiremock debug log level

---------

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-05-17 16:48:59 +02:00