Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: clarify/expand comments in Device::is_owner_of_session #3789

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions crates/matrix-sdk-crypto/src/identities/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,27 @@ impl Device {
} else if let Some(key) =
session.signing_keys().get(&DeviceKeyAlgorithm::Ed25519).and_then(|k| k.ed25519())
{
// Room keys are received as an `m.room.encrypted` event using the `m.olm`
// algorithm. Upon decryption of the `m.room.encrypted` event, the
// decrypted content will contain also a `Ed25519` public key[1].
// Room keys are received as an `m.room.encrypted` to-device message using the
// `m.olm` algorithm. Upon decryption of the `m.room.encrypted` to-device
// message, the decrypted content will contain also an `Ed25519` public key[1].
//
// The inclusion of this key means that the `Curve25519` key of the `Device` and
// Olm `Session`, established using the DH authentication of the
// double ratchet, binds the `Ed25519` key of the `Device`
// double ratchet, "binds" the `Ed25519` key of the `Device`. In other words, it
// prevents an attack in which Mallory publishes Bob's public `Curve25519` key
// as her own, and subsequently forwards an Olm message she received from Bob to
// Alice, claiming that she, Mallory, originated the Olm message (leading Alice
// to believe that Mallory also sent the messages in the subsequent Megolm
// session).
//
// On the other hand, the `Ed25519` key is binding the `Curve25519` key
// On the other hand, the `Ed25519` key binds the `Curve25519` key
// using a signature which is uploaded to the server as
// `device_keys` and downloaded by us using a `/keys/query` request.
//
// A `Device` is considered to be the owner of a room key iff:
// 1. The `Curve25519` key that was used to establish the Olm `Session` that
// was used to decrypt the event is binding the `Ed25519`key of this
// `Device`.
// was used to decrypt the to-device message is binding the `Ed25519` key
// of this `Device` via the content of the to-device message, and:
// 2. The `Ed25519` key of this device has signed a `device_keys` object
// that contains the `Curve25519` key from step 1.
//
Expand Down
Loading