Skip to content

Commit 3084f3d

Browse files
uhoregrichvdh
authored andcommitted
Merge pull request #3150 from uhoreg/verification_fixes
Make SAS outline fit with key verification in DM flow.
2 parents 194fef8 + 7a96037 commit 3084f3d

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add key verification using in-room messages as per [MSC2241](https://github.com/matrix-org/matrix-doc/pull/2241).

content/client-server-api/modules/end_to_end_encryption.md

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ file type. The key is sent using the [JSON Web
247247
Key](https://tools.ietf.org/html/rfc7517#appendix-A.3) format, with a
248248
[W3C extension](https://w3c.github.io/webcrypto/#iana-section-jwk).
249249

250-
Extensions to `m.room.message` msgtypes
251-
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
250+
###### Extensions to `m.room.message` msgtypes
252251

253252
This module adds `file` and `thumbnail_file` properties, of type
254253
`EncryptedFile`, to `m.room.message` msgtypes that reference files, such
@@ -572,8 +571,7 @@ To advertise support for this method, clients use the name `m.sas.v1` in the
572571
`methods` fields of the `m.key.verification.request` and
573572
`m.key.verification.ready` events.
574573

575-
The verification process takes place over [to-device](#send-to-device-messaging) messages in two
576-
phases:
574+
The verification process takes place in two phases:
577575

578576
1. Key agreement phase (based on [ZRTP key
579577
agreement](https://tools.ietf.org/html/rfc6189#section-4.4.1)).
@@ -584,63 +582,62 @@ The process between Alice and Bob verifying each other would be:
584582
1. Alice and Bob establish a secure out-of-band connection, such as
585583
meeting in-person or a video call. "Secure" here means that either
586584
party cannot be impersonated, not explicit secrecy.
587-
2. Alice and Bob communicate which devices they'd like to verify with
588-
each other.
589-
3. Alice selects Bob's device from the device list and begins
590-
verification.
591-
4. Alice's client ensures it has a copy of Bob's device key.
592-
5. Alice's device sends Bob's device an `m.key.verification.start`
593-
message.
594-
6. Bob's device receives the message and selects a key agreement
585+
2. Alice and Bob begin a key verification using the key verification
586+
framework as described above.
587+
3. Alice's device sends Bob's device an `m.key.verification.start`
588+
message. Alice's device ensures it has a copy of Bob's device key.
589+
4. Bob's device receives the message and selects a key agreement
595590
protocol, hash algorithm, message authentication code, and SAS
596591
method supported by Alice's device.
597-
7. Bob's device ensures it has a copy of Alice's device key.
598-
8. Bob's device creates an ephemeral Curve25519 key pair
592+
5. Bob's device ensures it has a copy of Alice's device key.
593+
6. Bob's device creates an ephemeral Curve25519 key pair
599594
(*K<sub>B</sub><sup>private</sup>*, *K<sub>B</sub><sup>public</sup>*),
600595
and calculates the hash (using the chosen algorithm) of the public
601596
key *K<sub>B</sub><sup>public</sup>*.
602-
9. Bob's device replies to Alice's device with an
597+
7. Bob's device replies to Alice's device with an
603598
`m.key.verification.accept` message.
604-
10. Alice's device receives Bob's message and stores the commitment hash
599+
8. Alice's device receives Bob's message and stores the commitment hash
605600
for later use.
606-
11. Alice's device creates an ephemeral Curve25519 key pair
601+
9. Alice's device creates an ephemeral Curve25519 key pair
607602
(*K<sub>A</sub><sup>private</sup>*, *K<sub>A</sub><sup>public</sup>*)
608603
and replies to Bob's device with an `m.key.verification.key`,
609604
sending only the public key
610605
*K<sub>A</sub><sup>public</sup>*.
611-
12. Bob's device receives Alice's message and replies with its own
606+
10. Bob's device receives Alice's message and replies with its own
612607
`m.key.verification.key` message containing its public key
613608
*K<sub>B</sub><sup>public</sup>*.
614-
13. Alice's device receives Bob's message and verifies the commitment
609+
11. Alice's device receives Bob's message and verifies the commitment
615610
hash from earlier matches the hash of the key Bob's device just sent
616611
and the content of Alice's `m.key.verification.start` message.
617-
14. Both Alice and Bob's devices perform an Elliptic-curve
612+
12. Both Alice and Bob's devices perform an Elliptic-curve
618613
Diffie-Hellman
619614
(*ECDH(K<sub>A</sub><sup>private</sup>*, *K<sub>B</sub><sup>public</sup>*)),
620615
using the result as the shared secret.
621-
15. Both Alice and Bob's devices display a SAS to their users, which is
616+
13. Both Alice and Bob's devices display a SAS to their users, which is
622617
derived from the shared key using one of the methods in this
623618
section. If multiple SAS methods are available, clients should allow
624619
the users to select a method.
625-
16. Alice and Bob compare the strings shown by their devices, and tell
620+
14. Alice and Bob compare the strings shown by their devices, and tell
626621
their devices if they match or not.
627-
17. Assuming they match, Alice and Bob's devices calculate the HMAC of
622+
15. Assuming they match, Alice and Bob's devices calculate the HMAC of
628623
their own device keys and a comma-separated sorted list of the key
629624
IDs that they wish the other user to verify, using SHA-256 as the
630625
hash function. HMAC is defined in [RFC
631626
2104](https://tools.ietf.org/html/rfc2104). The key for the HMAC is
632627
different for each item and is calculated by generating 32 bytes
633628
(256 bits) using [the key verification HKDF](#hkdf-calculation).
634-
18. Alice's device sends Bob's device an `m.key.verification.mac`
629+
16. Alice's device sends Bob's device an `m.key.verification.mac`
635630
message containing the MAC of Alice's device keys and the MAC of her
636631
key IDs to be verified. Bob's device does the same for Bob's device
637632
keys and key IDs concurrently with Alice.
638-
19. When the other device receives the `m.key.verification.mac` message,
633+
17. When the other device receives the `m.key.verification.mac` message,
639634
the device calculates the HMAC of its copies of the other device's
640635
keys given in the message, as well as the HMAC of the
641636
comma-separated, sorted, list of key IDs in the message. The device
642637
compares these with the HMAC values given in the message, and if
643638
everything matches then the device keys are verified.
639+
18. Alice and Bob's devices send `m.key.verification.done` messages to complete
640+
the verification.
644641

645642
The wire protocol looks like the following between Alice and Bob's
646643
devices:

0 commit comments

Comments
 (0)