@@ -357,7 +357,7 @@ out-of-band channel: there is no way to do it within Matrix without
357357trusting the administrators of the homeservers.
358358
359359In Matrix, verification works by Alice meeting Bob in person, or
360- contacting him via some other trusted medium, and use [ SAS
360+ contacting him via some other trusted medium, and using [ SAS
361361Verification] (#SAS Verification) to interactively verify Bob's devices.
362362Alice and Bob may also read aloud their unpadded base64 encoded Ed25519
363363public key, as returned by ` /keys/query ` .
@@ -390,60 +390,70 @@ decrypted by such a device. For the Olm protocol, this is documented at
390390Verifying keys manually by reading out the Ed25519 key is not very
391391user-friendly, and can lead to errors. In order to help mitigate errors,
392392and to make the process easier for users, some verification methods are
393- supported by the specification. The methods all use a common framework
393+ supported by the specification and use messages exchanged by the user's devices
394+ to assist in the verification. The methods all use a common framework
394395for negotiating the key verification.
395396
396- To use this framework, Alice's client would send
397- ` m.key.verification.request ` events to Bob's devices. All of the
398- ` to_device ` messages sent to Bob MUST have the same ` transaction_id ` to
399- indicate they are part of the same request. This allows Bob to reject
400- the request on one device, and have it apply to all of his devices.
401- Similarly, it allows Bob to process the verification on one device
402- without having to involve all of his devices.
403-
404- When Bob's device receives an ` m.key.verification.request ` , it should
405- prompt Bob to verify keys with Alice using one of the supported methods
406- in the request. If Bob's device does not understand any of the methods,
407- it should not cancel the request as one of his other devices may support
408- the request. Instead, Bob's device should tell Bob that an unsupported
409- method was used for starting key verification. The prompt for Bob to
410- accept/reject Alice's request (or the unsupported method prompt) should
411- be automatically dismissed 10 minutes after the ` timestamp ` field or 2
412- minutes after Bob's client receives the message, whichever comes first,
413- if Bob does not interact with the prompt. The prompt should additionally
414- be hidden if an appropriate ` m.key.verification.cancel ` message is
415- received.
416-
417- If Bob rejects the request, Bob's client must send an
418- ` m.key.verification.cancel ` message to Alice's device. Upon receipt,
419- Alice's device should tell her that Bob does not want to verify her
420- device and send ` m.key.verification.cancel ` messages to all of Bob's
421- devices to notify them that the request was rejected.
422-
423- If Bob accepts the request, Bob's device starts the key verification
424- process by sending an ` m.key.verification.start ` message to Alice's
425- device. Upon receipt of this message, Alice's device should send an
426- ` m.key.verification.cancel ` message to all of Bob's other devices to
427- indicate the process has been started. The start message must use the
428- same ` transaction_id ` from the original key verification request if it
429- is in response to the request. The start message can be sent
430- independently of any request.
431-
432- Individual verification methods may add additional steps, events, and
433- properties to the verification messages. Event types for methods defined
434- in this specification must be under the ` m.key.verification ` namespace
435- and any other event types must be namespaced according to the Java
436- package naming convention.
437-
438- Any of Alice's or Bob's devices can cancel the key verification request
439- or process at any time with an ` m.key.verification.cancel ` message to
440- all applicable devices.
441-
442- This framework yields the following handshake, assuming both Alice and
443- Bob each have 2 devices, Bob's first device accepts the key verification
444- request, and Alice's second device initiates the request. Note how
445- Alice's first device is not involved in the request or verification
446- process.
397+ Verification messages can be sent either in a room shared by the two parties,
398+ which should be a [ direct messaging] ( #direct-messaging ) room between the two
399+ parties, or by using [ to-device] ( #send-to-device-messaging ) messages sent
400+ directly between the two devices involved. In both cases, the messages
401+ exchanged are similar, with minor differences as detailed below. Verifying
402+ between two different users should be performed using in-room messages, whereas
403+ verifying two devices belonging to the same user should be performed using
404+ to-device messages.
405+
406+ A key verification session is identified by an ID that is established by the
407+ first message sent in that session. For verifications using in-room messages,
408+ the ID is the event ID of the initial message, and for verifications using
409+ to-device messages, the first message contains a ` transaction_id ` field that is
410+ shared by the other messages of that session.
411+
412+ In general, verification operates as follows:
413+
414+ - Alice requests a key verification with Bob by sending an
415+ ` m.key.verification.request ` event. This event indicates the verification
416+ methods that Alice's client supports. (Note that "Alice" and "Bob" may in
417+ fact be the same user, in the case where a user is verifying their own
418+ devices.)
419+ - Bob's client prompts Bob to accept the key verification. When Bob accepts
420+ the verification, Bob's client sends an ` m.key.verification.ready ` event.
421+ This event indicates the verification methods, corresponding to the
422+ verification methods supported by Alice's client, that Bob's client supports.
423+ - Alice's or Bob's devices allow their users to select one of the verification
424+ methods supported by both devices to use for verification. When Alice or Bob
425+ selects a verification method, their device begins the verification by
426+ sending an ` m.key.verification.start ` event, indicating the selected
427+ verification method. Note that if there is only one verification method in
428+ common between the devices then the receiver's device (Bob) can auto-select
429+ it.
430+ - Alice and Bob complete the verification as defined by the selected
431+ verification method. This could involve their clients exchanging messages,
432+ Alice and Bob exchanging information out-of-band, and/or Alice and Bob
433+ interacting with their devices.
434+ - Alice's and Bob's clients send ` m.key.verification.done ` events to indicate
435+ that the verification was successful.
436+
437+ Verifications can be cancelled by either device at any time by sending an
438+ ` m.key.verification.cancel ` event with a ` code ` field that indicates the reason
439+ it was cancelled.
440+
441+ When using to-device messages, Alice may not know which of Bob's devices to
442+ verify, or may not want to choose a specific device. In this case, Alice will
443+ send ` m.key.verification.request ` events to all of Bob's devices. All of these
444+ events will use the same transaction ID. When Bob accepts or declines the
445+ verification on one of his devices (sending either an
446+ ` m.key.verification.ready ` or ` m.key.verification.cancel ` event), Alice will
447+ send an ` m.key.verification.cancel ` event to Bob's other devices with a ` code `
448+ of ` m.accepted ` in the case where Bob accepted the verification, or ` m.user ` in
449+ the case where Bob rejected the verification. This yields the following
450+ handshake when using to-device messages, assuming both Alice and Bob each have
451+ 2 devices, Bob's first device accepts the key verification request, and Alice's
452+ second device initiates the request. Note how Alice's first device is not
453+ involved in the request or verification process. Also note that, although in
454+ this example, Bob's device sends the ` m.key.verification.start ` , Alice's device
455+ could also send that message. As well, the order of the
456+ ` m.key.verification.done ` messages could be reversed.
447457
448458```
449459 +---------------+ +---------------+ +-------------+ +-------------+
@@ -456,20 +466,85 @@ process.
456466 | | m.key.verification.request | |
457467 | |-------------------------------------------------->|
458468 | | | |
459- | | m.key.verification.start | |
469+ | | m.key.verification.ready | |
460470 | |<----------------------------------| |
461471 | | | |
462472 | | m.key.verification.cancel | |
463473 | |-------------------------------------------------->|
464474 | | | |
475+ | | m.key.verification.start | |
476+ | |<----------------------------------| |
477+ | | | |
478+ .
479+ . (verification messages)
480+ .
481+ | | | |
482+ | | m.key.verification.done | |
483+ | |<----------------------------------| |
484+ | | | |
485+ | | m.key.verification.done | |
486+ | |---------------------------------->| |
487+ | | | |
465488```
466489
467- After the handshake, the verification process begins.
490+ When using in-room messages and the room has encryption enabled, clients should
491+ ensure that encryption does not hinder the verification. For example, if the
492+ verification messages are encrypted, clients must ensure that all the
493+ recipient's unverified devices receive the keys necessary to decrypt the
494+ messages, even if they would normally not be given the keys to decrypt messages
495+ in the room. Alternatively, verification messages may be sent unencrypted,
496+ though this is not encouraged.
497+
498+ Upon receipt of Alice's ` m.key.verification.request ` message, if Bob's device
499+ does not understand any of the methods, it should not cancel the request as one
500+ of his other devices may support the request. Instead, Bob's device should tell
501+ Bob that no supported method was found, and allow him to manually reject the
502+ request.
503+
504+ The prompt for Bob to accept/reject Alice's request (or the unsupported method
505+ prompt) should be automatically dismissed 10 minutes after the ` timestamp ` (in
506+ the case of to-device messages) or ` origin_ts ` (in the case of in-room
507+ messages) field or 2 minutes after Bob's client receives the message, whichever
508+ comes first, if Bob does not interact with the prompt. The prompt should
509+ additionally be hidden if an appropriate ` m.key.verification.cancel ` message is
510+ received.
511+
512+ If Bob rejects the request, Bob's client must send an
513+ ` m.key.verification.cancel ` event with ` code ` set to ` m.user ` . Upon receipt,
514+ Alice's device should tell her that Bob does not want to verify her device and,
515+ if the request was sent as a to-device message, send
516+ ` m.key.verification.cancel ` messages to all of Bob's devices to notify them
517+ that the request was rejected.
518+
519+ If Alice's and Bob's clients both send an ` m.key.verification.start ` message,
520+ and both specify the same verification method, then the
521+ ` m.key.verification.start ` message sent by the user whose ID is the
522+ lexicographically largest user ID should be ignored, and the situation should
523+ be treated the same as if only the user with the lexicographically smallest
524+ user ID had sent the ` m.key.verification.start ` message. In the case where the
525+ user IDs are the same (that is, when a user is verifying their own device),
526+ then the device IDs should be compared instead. If the two
527+ ` m.key.verification.start ` messages do not specify the same verification
528+ method, then the verification should be cancelled with a ` code ` of
529+ ` m.unexpected_message ` .
530+
531+ An ` m.key.verification.start ` message can also be sent independently of any
532+ request, specifying the verification method to use.
533+
534+ Individual verification methods may add additional steps, events, and
535+ properties to the verification messages. Event types for methods defined
536+ in this specification must be under the ` m.key.verification ` namespace
537+ and any other event types must be namespaced according to the Java
538+ package naming convention.
468539
469540{{% event event="m.key.verification.request" %}}
470541
542+ {{% event event="m.key.verification.ready" %}}
543+
471544{{% event event="m.key.verification.start" %}}
472545
546+ {{% event event="m.key.verification.done" %}}
547+
473548{{% event event="m.key.verification.cancel" %}}
474549
475550##### Short Authentication String (SAS) verification
@@ -493,6 +568,10 @@ example, if we verify 40 bits, then an attacker has a 1 in
493568success. A failed attack would result in a mismatched Short
494569Authentication String, alerting users to the attack.
495570
571+ To advertise support for this method, clients use the name ` m.sas.v1 ` in the
572+ ` methods ` fields of the ` m.key.verification.request ` and
573+ ` m.key.verification.ready ` events.
574+
496575The verification process takes place over [ to-device] ( #send-to-device-messaging ) messages in two
497576phases:
498577
0 commit comments