XEP-0384: OMEMO Encryption
Total Page:16
File Type:pdf, Size:1020Kb
XEP-0384: OMEMO Encryption Andreas Straub Daniel Gultsch Tim Henkes mailto:andy@strb:org mailto:daniel@gultsch:de mailto:me@syndace:dev xmpp:andy@strb:org xmpp:daniel@gultsch:de Klaus Herberth Paul Schaub Marvin Wißfeld xmpp:klaus@jsxc:org mailto:vanitasvitae@riseup:net mailto:xmpp@larma:de xmpp:vanitasvitae@jabberhead:tk xmpp:jabber@larma:de 2021-09-28 Version 0.8.0 Status Type Short Name Experimental Standards Track OMEMO This specification defines a protocol for end-to-end encryption in one-to-one chats, as well as group chats where each participant may have multiple clients per account. Legal Copyright This XMPP Extension Protocol is copyright © 1999 – 2020 by the XMPP Standards Foundation (XSF). Permissions Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the ”Specification”), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specifi- cation, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or sub- stantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or pub- lisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation. Warranty ## NOTE WELL: This Specification is provided on an ”AS IS” BASIS, WITHOUT WARRANTIES OR CONDI- TIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ## Liability In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, includ- ing any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer fail- ure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages. Conformance This XMPP Extension Protocol has been contributed in full conformance with the XSF’s Intellectual Property Rights Policy (a copy of which can be found at <https://xmpp:org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA). Contents 1 Introduction 1 1.1 Motivation ...................................... 1 1.2 Overview ....................................... 1 2 Requirements 2 2.1 Threat Model ..................................... 3 3 Glossary 3 4 Protocol Definition 3 4.1 Overview ....................................... 3 4.2 Key Exchange .................................... 4 4.3 Double Ratchet .................................... 6 4.4 Message Encryption ................................. 8 4.5 Message Decryption ................................. 8 5 Use Cases 9 5.1 Setup ......................................... 9 5.2 Discovering peer support .............................. 9 5.3 Announcing support ................................. 9 5.3.1 Device list .................................. 9 5.3.2 Bundles ................................... 10 5.4 Building a session .................................. 12 5.5 Sending a message .................................. 13 5.5.1 SCE Profile .................................. 13 5.5.2 Encryption .................................. 14 5.5.3 Message structure description ....................... 14 5.6 Receiving a message ................................. 15 5.7 Opt-out ........................................ 15 5.8 Group Chats ..................................... 16 5.8.1 Retrieving and maintaining members list ................. 16 5.8.2 Fetching devices and bundles ....................... 16 5.8.3 Sending a message ............................. 17 6 Business Rules 18 7 Implementation Notes 19 7.1 Server side requirements .............................. 19 8 Security Considerations 20 9 IANA Considerations 20 10 XMPP Registrar Considerations 20 10.1 Protocol Namespaces ................................ 20 10.2 Protocol Versioning ................................. 21 11 XML Schema 21 12 Protobuf Schema 23 13 Acknowledgements 24 1 INTRODUCTION 1 Introduction 1.1 Motivation There are two main end-to-end encryption schemes in common use in the XMPP ecosystem, Off-the-Record (OTR) messaging (Current Off-the-Record Messaging Usage (XEP-0364) 1) and OpenPGP (Current Jabber OpenPGP Usage (XEP-0027) 2). Older OTR versions have had significant usability drawbacks for inter-client mobility. As OTR sessions existed between exactly two clients, the chat history would not be synchronized across other clients of the involved parties. Furthermore, OTR chats were only possible if both participants were online at the same time, due to how the rolling key agreement scheme of OTR worked. Some of those problems have been addressed in OTRv4. OpenPGP, while not suffering from these mobility issues, does not provide any kind of forward secrecy and is vulnerable to replay attacks. Additionally, PGP over XMPP uses a custom wireformat which is defined by convention rather than standardization, and involves quite a bit of external complexity. The wire format issues were resolved with OpenPGP for XMPP (XEP-0373) 3. This XEP defines a protocol that leverages the Double Ratchet encryption scheme to provide multi-end to multi-end encryption, allowing messages to be synchronized securely across multiple clients, even if some of them are offline. The Double Ratchet encryption scheme is based on work by Trevor Perrin and Moxie Marlinspike and was first published as the Axolotl protocol. The specification for the protocol is available in the public domain. 1.2 Overview The general idea behind this protocol is to maintain separate, long-standing Double Ratchet- encrypted sessions with each device of each contact (as well as with each of our other devices), which are used as secure key transport channels. In this scheme, each message is encrypted with a fresh, randomly generated encryption key. An encrypted header is added to the message for each device that is supposed to receive it. These headers simply contain the key that the payload message is encrypted with, and they are separately encrypted using the session corresponding to the counterpart device. The encrypted payload is sent together with the headers as a <message> stanza. Individual recipient devices can decrypt the header item intended for them, and use the contained payload key to decrypt the payload message. As the encrypted payload is common to all recipients, it only has to be included once, reducing overhead. Furthermore, the transparent handling by the Double Ratchet encryption scheme of messages that were lost or received out of order, as well as those sent while the recipient was offline, is maintained by this protocol. As a result, in combination with Message Carbons (XEP-0280) 4 and Message Archive Management (XEP-0313) 5, the desired property of inter-client history synchronization is achieved. 1XEP-0364: Current Off-the-Record Messaging Usage <https://xmpp:org/extensions/xep-0364:html>. 2XEP-0027: Current Jabber OpenPGP Usage <https://xmpp:org/extensions/xep-0027:html>. 3XEP-0373: OpenPGP for XMPP <https://xmpp:org/extensions/xep-0373:html>. 4XEP-0280: Message Carbons <https://xmpp:org/extensions/xep-0280:html>. 5XEP-0313: Message Archive Management <https://xmpp:org/extensions/xep-0313:html>. 1 2 REQUIREMENTS While in the future a dedicated key server component could be used to distribute key material for session creation, the current specification relies on Publish-Subscribe (XEP-0060) 6 and Personal Eventing Protocol (XEP-0163) 7 to publish and acquire key bundles. 2 Requirements It is a result of XMPP’s federated nature that a message may pass more than just one server. Therefore it is in the users’ interest to secure their communication from any intermediate host. End-to-end encryption is an efficient way to protect any data exchanged between sender and receiver against passive and active attackers such as servers and network nodes. OMEMO is an end-to-end encryption protocol based on the Double Ratchet specified in section Double Ratchet. It provides the following guarantees under the threat model described in the next section: • Confidentiality: Nobody else except sender and receiver is able to read the content of a message. • Forward Secrecy: Compromised key material does not compromise previous message exchanges. It has been demonstrated, that OMEMO provides only weak forward secrecy (it protects the session key only once both parties complete the key exchange). • Break-in Recovery: A session which has been compromised due to leakage of key mate- rial recovers from the compromise after a