element-hq / element-ios

A glossy Matrix collaboration client for iOS
https://element.io
Apache License 2.0
1.72k stars 480 forks source link

Olm sessions imported from legacy crypto will always be used in preference to newer olm sessions #7727

Closed richvdh closed 6 months ago

richvdh commented 6 months ago

Background: If an Olm session "wedges", we will attempt to work around it by starting a new session. Later, when either side wants to send another olm message, it will use the most recent Olm session -- ie, the new session.

However: when sessions are imported from legacy crypto, their "creation_time" and "last_used_time" are both set 50000 years in the future. (They are set in milliseconds rather than seconds. See also https://github.com/matrix-org/matrix-rust-sdk/issues/2974, https://github.com/matrix-org/matrix-rust-sdk/issues/2973.) That means that the imported session will always be used in preference to any newer sessions.

richvdh commented 6 months ago

Turns out iOS does this right, actually.