Skip to main content

End-to-End Object Encryption for the Extensible Messaging and Presence Protocol (XMPP)
draft-miller-xmpp-e2e-00

The information below is for an old version of the document.
Document Type
This is an older version of an Internet-Draft whose latest revision state is "Expired".
Author Matthew A. Miller
Last updated 2012-02-29
RFC stream (None)
Formats
Additional resources
Stream Stream state (No stream defined)
Consensus boilerplate Unknown
RFC Editor Note (None)
IESG IESG state I-D Exists
Telechat date (None)
Responsible AD (None)
Send notices to (None)
draft-miller-xmpp-e2e-00
Network Working Group                                          M. Miller
Internet-Draft                                       Cisco Systems, Inc.
Intended status: Standards Track                       February 29, 2012
Expires: August 14, 2012

 End-to-End Object Encryption for the Extensible Messaging and Presence
                            Protocol (XMPP)
                        draft-miller-xmpp-e2e-00

Abstract

   This document defines a method of end-to-end object encryption for
   the Extensible Messaging and Presence Protocol (XMPP).

Status of this Memo

   This Internet-Draft is submitted in full conformance with the
   provisions of BCP 78 and BCP 79.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF).  Note that other groups may also distribute
   working documents as Internet-Drafts.  The list of current Internet-
   Drafts is at http://datatracker.ietf.org/drafts/current/.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   This Internet-Draft will expire on August 14, 2012.

Copyright Notice

   Copyright (c) 2012 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents (http://trustee.ietf.org/
   license-info) in effect on the date of publication of this document.
   Please review these documents carefully, as they describe your rights
   and restrictions with respect to this document.  Code Components
   extracted from this document must include Simplified BSD License text
   as described in Section 4.e of the Trust Legal Provisions and are
   provided without warranty as described in the Simplified BSD License.

Table of Contents

   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  2
   2.  Terminology  . . . . . . . . . . . . . . . . . . . . . . . . .  2
   3.  Encrypting XMPP Stanzas  . . . . . . . . . . . . . . . . . . .  2
     3.1.  Prerequisites  . . . . . . . . . . . . . . . . . . . . . .  3
     3.2.  Process  . . . . . . . . . . . . . . . . . . . . . . . . .  3

Miller                            std                           [Page 1]
Internet-Draft                  XMPP E2E                   February 2012

     3.3.  Example Securing a Message . . . . . . . . . . . . . . . .  4
   4.  Requesting Content Keys  . . . . . . . . . . . . . . . . . . .  6
     4.1.  Request Process  . . . . . . . . . . . . . . . . . . . . .  6
     4.2.  Accept Process . . . . . . . . . . . . . . . . . . . . . .  7
     4.3.  Error Conditions . . . . . . . . . . . . . . . . . . . . .  8
     4.4.  Example of Successful Key Request  . . . . . . . . . . . .  8
   5.  Handling of Inbound Encrypted Stanzas  . . . . . . . . . . . . 10
     5.1.  Protocol Not Understood  . . . . . . . . . . . . . . . . . 11
     5.2.  Insufficient Information . . . . . . . . . . . . . . . . . 11
     5.3.  Failed Decryption  . . . . . . . . . . . . . . . . . . . . 12
     5.4.  Timestamp Not Acceptable . . . . . . . . . . . . . . . . . 12
     5.5.  Successful Decryption  . . . . . . . . . . . . . . . . . . 13
   6.  Inclusion and Checking of Timestamps . . . . . . . . . . . . . 13
   7.  Interaction with Stanza Semantics  . . . . . . . . . . . . . . 14
   8.  Mandatory-to-Implement Cryptographic Algorithms  . . . . . . . 14
   9.  Security Considerations  . . . . . . . . . . . . . . . . . . . 14
     9.1.  Storage of Encrypted Stanzas . . . . . . . . . . . . . . . 14
     9.2.  Re-use of Content Encryption Keys  . . . . . . . . . . . . 14
   10. IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 14
     10.1.  XML Namespace Name for e2e Data in XMPP . . . . . . . . . 14
   11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 15
     11.1.  Normative References  . . . . . . . . . . . . . . . . . . 15
     11.2.  Informative References  . . . . . . . . . . . . . . . . . 16
   Appendix A. Schema for urn:ietf:params:xml:ns:xmpp-e2e:1 . . . . . 16
   Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 18

1.  Introduction

   End-to-end encryption of traffic sent over the Extensible Messaging
   and Presence Protocol [RFC6120] is a desirable goal.  Requirements
   and a threat analysis for XMPP encryption are provided in [E2E-REQ].
   Many possible approaches to meet those (or similar) requirements have
   been proposed over the years, including methods based on PGP, S/MIME,
   SIGMA, and TLS.

   Most proposals have not been able to support multiple end-points for
   a given recipient.  As more devices support XMPP, it becomes more
   desirable to allow an entity to communicate with another in a more
   secure manner, regardless of the number of agents th entity is
   employing.  This document specifies an approach for encrypting
   communications between two entities which each might have multiple
   end-points.

2.  Terminology

   This document inherits terminology defined in [RFC6120].

   Security-related terms are to be understood in the sense defined in
   [SECTERMS].

   The capitalized key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
   "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
   "OPTIONAL" in this document are to be interpreted as described in
   [KEYWORDS].

3.  Encrypting XMPP Stanzas

Miller                            std                           [Page 2]
Internet-Draft                  XMPP E2E                   February 2012

   The process that a sending agent follows for securing stanzas is the
   same regardless of the form of stanza (i.e., <iq/>, <message/>, or
   <presence/>).

3.1.  Prerequisites

   First, the sending agent prepares and retains the following:

   o  The JID of the sender (i.e.  its own JID).  This SHOULD be the
      bare JID (localpart@domainpart).

   o  The JID of the recipient.  This SHOULD be the bare JID
      (localpart@domainpart).

   o  A random Content Encryption Key (CEK).  The CEK MUST have a length
      at least equal to that of the required encryption keys and MUST be
      generated randomly.  See [RFC4086] for considerations on
      generating random values.

   o  A CEK identifier (CID). The CID MUST be unique for a given
      (sender, recipient, CEK) tuple, and MUST NOT be derived from CEK
      itself.

3.2.  Process

   For a given plaintext stanza (S), the sending agent performs the
   following:

   1.  Notes the current UTC date and time N when this stanza is
       constructed, formatted as described under [timestamps].
   2.  Constructs a forwarding envelope P using a <forwarded/> element
       qualified by the "urn:xmpp:forward:0" namespace (as defined in
       [MSG-FWD]) as follows:

   *  The child element <delay/> qualified by the "urn:xmpp:delay"
      namespace (as defined in [DELAY]) with the attribute 'stamp' set
      to the UTC date and time value N

   *  The plaintext stanza S
   3.  Generates any additional unprotected block cipher factors (IV);
       e.g.  initialization vector, nonce, and/or associated
       authentication data.  A sending agent MUST ensure that no two
       sets of factors are used with the same CEK, and SHOULD NOT reuse
       such factors for other stanzas.

   4.  Constructs a partial [JOSE-JWE] header (H) with the following
       information:

   *  The property 'enc' indicating the algorithm used to encrypt the
      content.

Miller                            std                           [Page 3]
Internet-Draft                  XMPP E2E                   February 2012

   *  The property 'iv' indicating the initialization vector, if
      required by the algorithm.

   NOTE: this header is intentionally lacking required attributes.  The
   receiving agent is responsible for assembling a final, valid JWE
   header.
   5.  Convert the stanza to a UTF-8 encoded string (P'), optionallly
       removing line breaks and other insignificant whitespace between
       elements and attributes, i.e.  P' = UTF8-encode(P).  We call P' a
       "stanza-string" because for purposes of encryption and decryption
       it is treated not as XML but as an opaque string (this avoids the
       need for complex canonicalization of the XML input).

   6.  Encrypts P' using the intended block cipher, i.e.  T = block-
       encrypt(CEK, IV, P').

   7.  Constructs an <e2e/> element qualified by the
       "urn:ietf:params:xml:ns:xmpp-e2e:1" namespace as follows:

   *  The attribute 'id' set to the identifier value CID.

   *  The child element <header/> qualified by the
      "urn:ietf:params:xml:ns:xmpp-e2e:1" namespace and with XML
      character data as the base64url-encoded form of H.

   *  The child element <data/> qualified by the "urn:ietf:params:xml:ns
      :xmpp-e2e:1" namespace and with XML character data as the
      base64url-encoded form of T.

   8.  Sends the <e2e/> element as the payload of a stanza that SHOULD
       match the stanza from step 1 in kind (e.g., <message/>), type
       (e.g., "chat"), and addressing (e.g.  to="romeo@montague.net"
       from="juliet@capulet.net/balcony"). If the original stanza (S)
       has a value for the "id" attribute, this stanza MUST NOT use the
       same value for its "id" attribute.

3.3.  Example Securing a Message

   NOTE: unless otherwise indicated, all line breaks are included for
   readability.

   The sending agent begins with the plaintext version of the <message/>
   stanza 'S':

Miller                            std                           [Page 4]
Internet-Draft                  XMPP E2E                   February 2012

   <message xmlns='jabber:client'
            from='juliet@capulet.lit/balcony'
            to='romeo@montegue.lit/garden'
            type='chat'>
     <thread>35740be5-b5a4-4c4e-962a-a03b14ed92f4</thread>
     <body>
       But to be frank, and give it thee again.
       And yet I wish but for the thing I have.
       My bounty is as boundless as the sea,
       My love as deep; the more I give to thee,
       The more I have, for both are infinite.
     </body>
   </message>

   and the following prerequisites:

   o  Sender JID as "juliet@capulet.lit"

   o  Recipient JID as "romeo@montegue.lit"

   o  Content encryption key 'CEK' as (base64 encoded)
      "-ElMo6FndEkMxWP3TIkp1dDfVKqmqAAgrlcvVnUVpOc="

   o  CEK identifier CID as "835c92a8-94cd-4e96-b3f3-b2e75a438f92"

   The sending agent performs steps 1 and 2 to generate the envelope:

   <forwarded xmlns='urn:xmpp:forward:0'>
     <delay xmlns='urn:xmpp:delay'
            stamp='1492-05-12T20:07:37.012Z'/>
     <message xmlns='jabber:client'
              from='juliet@capulet.lit/balcony'
              to='romeo@montegue.lit/garden'
              type='chat'>
       <thread>35740be5-b5a4-4c4e-962a-a03b14ed92f4</thread>
       <body>
         But to be frank, and give it thee again.
         And yet I wish but for the thing I have.
         My bounty is as boundless as the sea,
         My love as deep; the more I give to thee,
         The more I have, for both are infinite.
       </body>
     </message>
   </forwarded>

   Then the sending agent performs steps 3 and 4 to generate the [JOSE-
   JWE] header:

   {
     "enc":"A256CCM",
     "iv":"B7waCj2vF_sLaJfe-1GHrA==",
     "adata":"1492-05-12T20:07:37.012Z",
     "msize":"16"

Miller                            std                           [Page 5]
Internet-Draft                  XMPP E2E                   February 2012

   }

   Then the sending agent performs steps 5 and 6 to generate the
   protected content:

   7LlMXd-qqPAQ_LZm6u9AR2csyDgT09z5DWdn8K5GLr_qbWRDKw2ufZrmO9YZ-jHl
   1IDeXeQ9azbNNViv8gpa-prDYkXOo3QoqYOJiA0RAkPU-UjN41wqqVvV62gad_OB
   Dd9q2xsNnK1PI5frIGTCZSexOIeSD3EcP0cDI_0MzMEKqpVnPbYQDkWQNrtxPs2b
   lE15KcQXbHVxA9rEz7y0a-ITXruV_fOXGftkRVDuiF1yVh2xNRPa-TQxDegZh1D_
   u_c2mwPLO6ED_1ZlvL7075_VL0DT01YGtDDQeyzrQWnQNEBJ4G5jFpCyqtCszbgx
   9kjWjxLYNLLGxbMOtwF45OLCd8JFUIQAHoLeKp4aIWr5yp7aATX8dKvQm5_TFICt
   nLonaM1e5mRPnRgg5zNeMErx6FFkqowOI1h7hVl_QHF8Ofoy99CmWKiVT3Nq5ngL
   74Xm4CtiJMHnAEn2Q-10-fWuIHIEA0u4GwBaXo0ToBw4uCM4ZhG1SFSKyCKkjXmr
   7TL-5jwSuuQHX6efS8Hhi7fujmqw9VXekeubsY2btl5put0SWT8_0S8ZBDMjrkXj
   y7iI5NUOhQMms3ou1r01NZdzNVKcqiX5q3z1eB1FLWmGymnnj_gE_HalWUL0HoqL
   93Fr1nfFLNhXLCZYhZ7By6T9NN8omp4ZYE92HMpPzgo-eCGP

   Then the sending agent performs step 7 and sends the following:

   <message xmlns='jabber:client'
            from='juliet@capulet.lit/balcony'
            id='fJZd9WFIIwNjFctT'
            to='romeo@montegue.lit/garden'
            type='chat'>
     <e2e xmlns='urn:ietf:params:xml:ns:xmpp-e2e:1'
          id='835c92a8-94cd-4e96-b3f3-b2e75a438f92'>
       <header>
         eyJlbmMiOiJBMjU2Q0NNIiwiaXYiOiJCN3dhQ2oydkZfc0xhSmZlLTFHSHJBPT0i
         LCJhZGF0YSI6IjQ5Mi0wNS0xMlQyMDowNzozNy4wMTJaIiwibXNpemUiOiIxNiJ9
       </header>
       <data>
         7LlMXd-qqPAQ_LZm6u9AR2csyDgT09z5DWdn8K5GLr_qbWRDKw2ufZrmO9YZ-jHl
         1IDeXeQ9azbNNViv8gpa-prDYkXOo3QoqYOJiA0RAkPU-UjN41wqqVvV62gad_OB
         Dd9q2xsNnK1PI5frIGTCZSexOIeSD3EcP0cDI_0MzMEKqpVnPbYQDkWQNrtxPs2b
         lE15KcQXbHVxA9rEz7y0a-ITXruV_fOXGftkRVDuiF1yVh2xNRPa-TQxDegZh1D_
         u_c2mwPLO6ED_1ZlvL7075_VL0DT01YGtDDQeyzrQWnQNEBJ4G5jFpCyqtCszbgx
         9kjWjxLYNLLGxbMOtwF45OLCd8JFUIQAHoLeKp4aIWr5yp7aATX8dKvQm5_TFICt
         nLonaM1e5mRPnRgg5zNeMErx6FFkqowOI1h7hVl_QHF8Ofoy99CmWKiVT3Nq5ngL
         74Xm4CtiJMHnAEn2Q-10-fWuIHIEA0u4GwBaXo0ToBw4uCM4ZhG1SFSKyCKkjXmr
         7TL-5jwSuuQHX6efS8Hhi7fujmqw9VXekeubsY2btl5put0SWT8_0S8ZBDMjrkXj
         y7iI5NUOhQMms3ou1r01NZdzNVKcqiX5q3z1eB1FLWmGymnnj_gE_HalWUL0HoqL
         93Fr1nfFLNhXLCZYhZ7By6T9NN8omp4ZYE92HMpPzgo-eCGP
       </data>
     </e2e>
   </message>

4.  Requesting Content Keys

   A receiving agent might not have the conetnt encryption key to
   decrypt the stanza.

Miller                            std                           [Page 6]
Internet-Draft                  XMPP E2E                   February 2012

4.1.  Request Process

   Before a CEK can be requested, the receiving agent MUST have at least
   one public key for which it also has the private key.

   To request a CEK, the receiving agent performs the following:

   1.  Constructs a [JOSE-JWK] container object (KS), containing
       information about each public key the requesting agent wishes to
       use.  Each key SHOULD include a value for the property 'kid'
       which uniquely identifies it within the context of all provided
       keys.  Each key MUST include a value for the property 'kid' if
       any two keys use the same algorithm.

   2.  Constructs a <keyreq/> element qualified by the
       "urn:ietf:params:xml:ns:xmpp-e2e:1" namespace as follows:

   *  The attribute 'id' set to the CEK identifier value CID.

   *  The child element <pkey/> qualified by the "urn:ietf:params:xml:ns
      :xmpp-e2e:1" namespace and with XML character data as the
      base64url-encoded form of KS.

   3.  Sends the <keyreq/> element as the payload of an <iq/> stanza
       with the attribute 'type' set to "get", the attribute 'to' set to
       the full JID of the original encrypted stanza's sender, and the
       attribute 'id' set to an opaque string value the receiving agent
       uses to track the <iq/> response.

4.2.  Accept Process

   If the sending agent approves the request, it performs the following:

   1.  Chooses a key (PK) from the list provided via KS, and notes its
       identifier value 'kid'.
   2.  Constructs a parial [JOSE-JWE] header (H) as follows:

   *  The property 'alg' set to the cryptographic algorithm for PK,
      which is used to secure the content encryption key CEK.

   *  The property 'kid' set to the identifier matching PK.

   NOTE: this header is intentionally lacking required attributes.  The
   receiving agent is responsible for assembling a final, valid JWE
   header.
   3.  Encrypts the content encryption key CEK using the key PK, i.e.
       CEK' = pki-encrypt(PK, CEK).

   4.  Constructs a <keyreq/> element qualified by the
       "urn:ietf:params:xml:ns:xmpp-e2e:1" namespace as follows:

Miller                            std                           [Page 7]
Internet-Draft                  XMPP E2E                   February 2012

   *  The attribute 'id' set to the CEK identifier CID.

   *  The child element <header/> qualified by the
      "urn:ietf:params:xml:ns:xmpp-e2e:1" namespace and with XML
      cahracter data as the base64url-encoded form of H.

   *  The child element <cek/> qualified by the "urn:ietf:params:xml:ns
      :xmpp-e2e:1" namespace and with XML character data as the
      base64url-encoded form of CEK'.

   5.  Sends the <keyreq/> element as the payload of an <iq/> stanza
       with the attribute 'type' set to "result", the attribute 'to' set
       to the full JID from the request <iq/>'s 'from' attribute, and
       the attribute 'id' set to the value of the request <iq/>'s 'id'
       attribute.

4.3.  Error Conditions

   If the sending agent does not approve of the request, it sends an <iq
   /> stanza of type "error" and containing the reason for denying the
   request:

   o  <forbidden/>: the key request is made by an entity that is not
      authorized to decrypt stanzas from the sending agent and/or for
      the indicated CID.

   o  <item-not-found/>: the requested CID is no longer valid.

   o  <not-acceptable/>: the key request did not contain any keys the
      sending agent understands.

4.4.  Example of Successful Key Request

   NOTE: unless otherwise indicated, all line breaks are included for
   readability.

   To begin a key request, the receiving agent performs step 1 from
   request process [keyreq-process-request] to generate the [JOSE-JWK]:

   [{
     "alg":"RSA",
     "mod":"AL7ano5DBdNYfKChGh3xxGDtAtozO3iEm20rzbNEjSLWFjuhm46SXzeJXV8Nr6V
            UXcrJ8FN85OqNv0g9GAh9VoHriNECtZJzEw3TUl8edntXOAU8IZQPIh7rrU1pqQ
            anrJ9RjWZqgd42LCTpFQWMAibZAfQD2gb5NIrZUbYs4wn9Rx52ru5xkrcrIYLvP
            rK8Yv3fKwuU0y0gf809Yunz_H8A5aHplzrQtFOuW8uT_tWR8Wn_2w_H6Y6bOoME
            oHZGSjCQCNGzlmVrjKadp7amtMCwezXcW9iI63qIP7ObLAKEolw1XaLMEm6d-mT
            _tZZwpNo_r2eKm4WhYOW2bYLfoME=",
     "exp":"AQAB",
     "kid":"romeo@montegue.lit/garden"
   }]

Miller                            std                           [Page 8]
Internet-Draft                  XMPP E2E                   February 2012

   Then the receiving agent performs step 2 to generate the <keyreq/>:

   <keyreq xmlns='urn:ietf:params:xml:ns:xmpp-e2e:1'
           id='835c92a8-94cd-4e96-b3f3-b2e75a438f92'>
     <pkey>
       W3siYWxnIjoiUlNBIiwibW9kIjoiQUw3YW5vNURCZE5ZZktDaEdoM3h4R0R0QXR
       vek8zaUVtMjByemJORWpTTFdGanVobTQ2U1h6ZUpYVjhOcjZWVVhjcko4Rk44NU
       9xTnYwZzlHQWg5Vm9IcmlORUN0Wkp6RXczVFVsOGVkbnRYT0FVOElaUVBJaDdyc
       lUxcHFRYW5ySjlSaldacWdkNDJMQ1RwRlFXTUFpYlpBZlFEMmdiNU5JclpVYllz
       NHduOVJ4NTJydTV4a3JjcklZTHZQcks4WXYzZkt3dVUweTBnZjgwOVl1bnpfSDh
       BNWFIcGx6clF0Rk91Vzh1VF90V1I4V25fMndfSDZZNmJPb01Fb0haR1NqQ1FDTk
       d6bG1WcmpLYWRwN2FtdE1Dd2V6WGNXOWlJNjNxSVA3T2JMQUtFb2x3MVhhTE1Fb
       TZkLW1UX3RaWndwTm9fcjJlS200V2hZT1cyYllMZm9NRT0iLCJleHAiOiJBUUFC
       Iiwia2lkIjoicm9tZW9AbW9udGVndWUubGl0L2dhcmRlbiJ9XQ==
     </pkey>
   </keyreq>

   Then the receiving agent performs step 3 and sends the following:

   <iq xmlns='jabber:client'
       from='romeo@montegue.lit/garden'
       id='xdJbWMA+'
       to='juliet@capulet.lit/balcony'
       type='get'>
     <keyreq xmlns='urn:ietf:params:xml:ns:xmpp-e2e:1'
             id='835c92a8-94cd-4e96-b3f3-b2e75a438f92'>
       <pkey>
         W3siYWxnIjoiUlNBIiwibW9kIjoiQUw3YW5vNURCZE5ZZktDaEdoM3h4R0R0QXR
         vek8zaUVtMjByemJORWpTTFdGanVobTQ2U1h6ZUpYVjhOcjZWVVhjcko4Rk44NU
         9xTnYwZzlHQWg5Vm9IcmlORUN0Wkp6RXczVFVsOGVkbnRYT0FVOElaUVBJaDdyc
         lUxcHFRYW5ySjlSaldacWdkNDJMQ1RwRlFXTUFpYlpBZlFEMmdiNU5JclpVYllz
         NHduOVJ4NTJydTV4a3JjcklZTHZQcks4WXYzZkt3dVUweTBnZjgwOVl1bnpfSDh
         BNWFIcGx6clF0Rk91Vzh1VF90V1I4V25fMndfSDZZNmJPb01Fb0haR1NqQ1FDTk
         d6bG1WcmpLYWRwN2FtdE1Dd2V6WGNXOWlJNjNxSVA3T2JMQUtFb2x3MVhhTE1Fb
         TZkLW1UX3RaWndwTm9fcjJlS200V2hZT1cyYllMZm9NRT0iLCJleHAiOiJBUUFC
         Iiwia2lkIjoicm9tZW9AbW9udGVndWUubGl0L2dhcmRlbiJ9XQ==
       </pkey>
     </keyreq>
   </iq>

   If the sending agent accepts this key request, it performs steps 1
   and 2 from accept process [keyreq-process-accept] to generate the
   partial [JOSE-JWE] header:

   {
     "alg":"RSA-OEAP",
     "kid":"romeo@montegue.lit/garden"
   }

   Then the sending agent performs step 3 to generate the encrypted CEK:

Miller                            std                           [Page 9]
Internet-Draft                  XMPP E2E                   February 2012

   DCKrJpLd8XYze7joNKsyvpzGD4MffVQF7apQMkPK8_vKx4J3xEqWB3tXxp6oxJF
   4YHla4SFiMp44LccMEd6JchPp_23OXrBo8i7Fwo8jVH6QoQa71T_1rQj6CWQ1eF
   vXiU4Qmp52F-gjuUhlKfe3qccdlFp3kLy8Mpq5mDdq6deOq0_qusqr8QTqrT5LN
   IgsXYzrdiDdKx8KSKpI4FBB_H1x-A1C97DfJk9s5H7GzKVm2BRWVXWjJfO4lckE
   Z45ZJkA3CKq86Yth3YBetoScPVLhoRoO2qqBg4gR9dDO5mXnOgPslVfXWvegexH
   AyhHmJZsj3yV_pW1Rlb5jn5J4Rw==

   Then the sending agent performs step 4 to generate the <keyreq/>
   response:

   <keyreq xmlns='urn:ietf:params:xml:ns:xmpp-e2e:1'
           id='835c92a8-94cd-4e96-b3f3-b2e75a438f92'>
     <header>
       eyJhbGciOiJSU0EtT0VBUCIsImtpZCI6InJvbWVvQG1vbnRlZ3VlLmxpc3QvZ2F
       yZGVuIn0=
     </header>
     <cek>
       DCKrJpLd8XYze7joNKsyvpzGD4MffVQF7apQMkPK8_vKx4J3xEqWB3tXxp6oxJF
       4YHla4SFiMp44LccMEd6JchPp_23OXrBo8i7Fwo8jVH6QoQa71T_1rQj6CWQ1eF
       vXiU4Qmp52F-gjuUhlKfe3qccdlFp3kLy8Mpq5mDdq6deOq0_qusqr8QTqrT5LN
       IgsXYzrdiDdKx8KSKpI4FBB_H1x-A1C97DfJk9s5H7GzKVm2BRWVXWjJfO4lckE
       Z45ZJkA3CKq86Yth3YBetoScPVLhoRoO2qqBg4gR9dDO5mXnOgPslVfXWvegexH
       AyhHmJZsj3yV_pW1Rlb5jn5J4Rw==
     </cek>
   </keyreq>

   Then the sending agent performs step 5 and sends the following:

   <iq xmlns='jabber:client'
       from='juliet@capulet.lit/balcony'
       id='xdJbWMA+'
       to='romeo@montegue.lit/garden'
       type='result'>
     <keyreq xmlns='urn:ietf:params:xml:ns:xmpp-e2e:1'
             id='835c92a8-94cd-4e96-b3f3-b2e75a438f92'>
       <header>
         eyJhbGciOiJSU0EtT0VBUCIsImtpZCI6InJvbWVvQG1vbnRlZ3VlLmxpc3QvZ2F
         yZGVuIn0=
       </header>
       <cek>
         DCKrJpLd8XYze7joNKsyvpzGD4MffVQF7apQMkPK8_vKx4J3xEqWB3tXxp6oxJF
         4YHla4SFiMp44LccMEd6JchPp_23OXrBo8i7Fwo8jVH6QoQa71T_1rQj6CWQ1eF
         vXiU4Qmp52F-gjuUhlKfe3qccdlFp3kLy8Mpq5mDdq6deOq0_qusqr8QTqrT5LN
         IgsXYzrdiDdKx8KSKpI4FBB_H1x-A1C97DfJk9s5H7GzKVm2BRWVXWjJfO4lckE
         Z45ZJkA3CKq86Yth3YBetoScPVLhoRoO2qqBg4gR9dDO5mXnOgPslVfXWvegexH
         AyhHmJZsj3yV_pW1Rlb5jn5J4Rw==
       </cek>
     </keyreq>
   </iq>

5.  Handling of Inbound Encrypted Stanzas

   Several scenarios are possible when an entity receives an encrypted
   stanza:

Miller                            std                          [Page 10]
Internet-Draft                  XMPP E2E                   February 2012

   o  The receiving agent does not understand the protocol.

   o  The receiving agent understands the protocol but does not have
      enough infomration to decrypt the payload.

   o  The receiving agent understands the protocol but is unable to
      decrypt the payload.

   o  The receiving agent understands the protocol and is able to
      decrypt the payload, but the timestamps fail the checks specified
      under [timestamps].

   o  The receiving agent understands the protocol and is able to
      decrypt the payload (success case).

5.1.  Protocol Not Understood

   In the case where the receiving agent does not understand the
   protocol, it MUST do one and only one of the following: (1) ignore
   the <e2e/> extension, (2) ignore the entire stanza, or (3) return a
   <service-unavailable/> error to the sender, as described in
   [RFC6120].

   NOTE: If the inbound stanza is an <iq/>, the receiving agent MUST
   return an error to the sending agent, to comply with the exchanging
   of IQ stanzas in [RFC6121].

5.2.  Insufficient Information

   In the case where the protocol is understood but the receiving agent
   does not have enough information to decrypt the payload, it SHOULD
   request the additional information as described in [keyreq].

   If the key request fails, or the receiving agent could not otherwise
   determine the additional information, it MAY return a <bad-request/>
   error to the sending agent (as described in [RFC6120]), optionally
   supplemented by an application-specific error condition element of
   <insufficient-information/>:

   <message xmlns='jabber:client'
            from='juliet@capulet.lit/balcony'
            id='fJZd9WFIIwNjFctT'
            to='romeo@montegue.lit/garden'
            type='chat'>
     <e2e xmlns='urn:ietf:params:xml:ns:xmpp-e2e:1'
          id='835c92a8-94cd-4e96-b3f3-b2e75a438f92'>
       <header>[XML character data]</header>
       <data>[XML character data]</header>
     </e2e>
     <error type='modify'>
       <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
       <insufficient-information xmlns='urn:ietf:params:xml:ns:xmpp-e2e'/>
     </error>
   </message>

Miller                            std                          [Page 11]
Internet-Draft                  XMPP E2E                   February 2012

   In addition to returning an error, the receiving agent SHOULD NOT
   present the stanza to the intended recipient (human or application)
   and SHOULD provide some explicit alternate processing of the stanza
   (which MAY be to display a message informing the recipient that it
   has received a stanza that cannot be decrypted).

5.3.  Failed Decryption

   In the case where the protocol is understood but the receiving agent
   is unable to decrypt the payload, the receiving agent SHOULD return a
   <bad-request/> error to the sending agent (as described in
   [RFC6120]), optionally supplemented by an application-specific error
   condition element of <decryption-failed/> (previously defined in
   [RFC3923]):

   <message xmlns='jabber:client'
            from='juliet@capulet.lit/balcony'
            id='fJZd9WFIIwNjFctT'
            to='romeo@montegue.lit/garden'
            type='chat'>
     <e2e xmlns='urn:ietf:params:xml:ns:xmpp-e2e:1'
          id='835c92a8-94cd-4e96-b3f3-b2e75a438f92'>
       <header>[XML character data]</header>
       <data>[XML character data]</header>
     </e2e>
     <error type='modify'>
       <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
       <decryption-failed xmlns='urn:ietf:params:xml:ns:xmpp-e2e'/>
     </error>
   </message>

   In addition to returning an error, the receiving agent SHOULD NOT
   present the stanza to the intended recipient (human or application)
   and SHOULD provide some explicit alternate processing of the stanza
   (which MAY be to display a message informing the recipient that it
   has received a stanza that cannot be decrypted).

5.4.  Timestamp Not Acceptable

   In Case #4, the receiving agent MAY return a <not-acceptable/> error
   to the sender (as described in [RFC6120]), optionally supplemented by
   an application-specific error condition element of <bad-timestamp/>
   (previously defined in [RFC3923]):

Miller                            std                          [Page 12]
Internet-Draft                  XMPP E2E                   February 2012

   <message xmlns='jabber:client'
            from='juliet@capulet.lit/balcony'
            id='fJZd9WFIIwNjFctT'
            to='romeo@montegue.lit/garden'
            type='chat'>
     <e2e xmlns='urn:ietf:params:xml:ns:xmpp-e2e:1'
          id='835c92a8-94cd-4e96-b3f3-b2e75a438f92'>
       <header>[XML character data]</header>
       <data>[XML character data]</header>
     </e2e>
     <error type='modify'>
       <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
       <bad-timestamp xmlns='urn:ietf:params:xml:ns:xmpp-e2e'/>
     </error>
   </message>

5.5.  Successful Decryption

   In the case where the protocol is understood and the receiving agent
   successfully decrypted the payload, it MUST NOT return a stanza
   error.

   If the payload is an <iq/> of type "get" or "set", and the response
   is an error, the receiving agent MUST send the encrypted response in
   an <iq/> of type "result", to prevent exposing information about the
   payload.

6.  Inclusion and Checking of Timestamps

   Timestamps are included to help prevent replay attacks.  All
   timestamps MUST conform to [DATETIME] and be presented as UTC with no
   offset, and SHOULD include the seconds and fractions of a second to
   three digits.  Absent a local adjustment to the sending agent's
   perceived time or the underlying clock time, the sending agent MUST
   ensure that the timestamps it sends to the receiver increase
   monotonically (if necessary by incrementing the seconds fraction in
   the timestamp if the clock returns the same time for multiple
   requests).  The following rules apply to the receiving agent:

   o  It MUST verify that the timestamp received is within five minutes
      of the current time, except as described below for offline
      messages.

   o  It SHOULD verify that the timestamp received is greater than any
      timestamp received in the last 10 minutes which passed the
      previous check.

   o  If any of the foregoing checks fails, the timestamp SHOULD be
      presented to the receiving entity (human or application) marked as
      "old timestamp", "future timestamp", or "decreasing timestamp",
      and the receiving entity MAY return a stanza error to the sender.

Miller                            std                          [Page 13]
Internet-Draft                  XMPP E2E                   February 2012

   The foregoing timestamp checks assume that the recipient is online
   when the message is received.  However, if the recipient is offline
   then the server will probably store the message for delivery when the
   recipient is next online (offline storage does not apply to <iq/> or
   <presence/> stanzas, only <message/> stanzas).  As described in
   [OFFLINE], when sending an offline message to the recipient, the
   server SHOULD include delayed delivery data as specified in [DELAY]
   so that the recipient knows that this is an offline message and also
   knows the original time of receipt at the server.  In this case, the
   recipient SHOULD verify that the timestamp received in the encrypted
   message is within five minutes of the time stamped by the recipient's
   server in the <delay/> element.

7.  Interaction with Stanza Semantics

   The following limitations and caveats apply:

   o  Undirected <presence/> stanzas SHOULD NOT be encrypted.  Such
      stanzas are delivered to anyone the sender has authorized, and can
      generate a large volume of key requests.

   o  Stanzas directed to multiplexing services (e.g.  multi-user chat)
      SHOULD NOT be encrypted, unless the sender has established an
      acceptable trust relationship with the multiplexing service.

8.  Mandatory-to-Implement Cryptographic Algorithms

   All algorithms that MUST be implemented for [JOSE-JWE] also MUST be
   implemented for this specification.

9.  Security Considerations

9.1.  Storage of Encrypted Stanzas

   The recipient's server might store any <message/> stanzas received
   until the recipient is next available; this duration could be
   anywhere from a few minutes to several months.

9.2.  Re-use of Content Encryption Keys

   A sender SHOULD NOT use the same CEK for stanzas intended for
   different recipients.

   A sender MAY re-use a CEK for several stanzas to the same recpient.
   In this case, the CID remains the same, but MUST generate a new IV
   (and other data) for each encrypted stanza.  The sender SHOULD
   periodically generate a new CEK; however, this specification does not
   mandate any specific algorithms or processes.

10.  IANA Considerations

10.1.  XML Namespace Name for e2e Data in XMPP

Miller                            std                          [Page 14]
Internet-Draft                  XMPP E2E                   February 2012

   A URN sub-namespace of encrypted content for the Extensible Messaging
   and Presence Protocol (XMPP) is defined as follows.

   URI: urn:ietf:params:xml:ns:xmpp-e2e:1
   Specification: RFC XXXX
   Description: This is an XML namespace name of encrypted content for
      the Extensible Messaging and Presence Protocol as defined by RFC
      XXXX.
   Registrant Contact: IESG, <iesg@ietf.org>

11.  References

11.1.  Normative References

   [BASE64]   Josefsson, S., "The Base16, Base32, and Base64 Data
              Encodings", RFC 4648, October 2006.

   [CMS-AES]  Schaad, J., "Use of the Advanced Encryption Standard (AES)
              Encryption Algorithm in Cryptographic Message Syntax
              (CMS)", RFC 3565, July 2003.

   [DATETIME]
              Saint-Andre, P., "XMPP Date and Time Profiles", XSF XEP
              0082, May 2003.

   [DELAY]    Saint-Andre, P., "Delayed Delivery", XSF XEP 0203,
              September 2009.

   [E2E-REQ]  Saint-Andre, P, "Requirements for End-to-End Encryption in
              the Extensible Messaging and Presence Protocol (XMPP)",
              Internet-Draft draft-saintandre-xmpp-e2e-requirements-01,
              March 2010.

   [MSG-FWD]  Wild, M. and K. Smith, "Message Forwarding", XSF XEP 0297,
              July 2011.

   [KEYWORDS]
              Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119, March 1997.

   [HMAC]     Eastlake, D. and T. Hansen, "US Secure Hash Algorithms
              (SHA and HMAC-SHA)", RFC 4634, July 2006.

   [JOSE-JWA]
              Jones, M., "JSON Web Algorithms (JWA)", Internet-Draft
              draft-ietf-jose-json-web-algorithms-00, January 2012.

   [JOSE-JWE]
              Jones, M., Rescola, E. and J. Hildebrand, "JSON Web
              Encryption (JWE)", Internet-Draft draft-ietf-jose-json-
              web-encryption-00, January 2012.

   [JOSE-JWK]
              Jones, M., "JSON Web Key (JWK)", Internet-Draft draft-
              ietf-jose-json-web-key-00, January 2012.

Miller                            std                          [Page 15]
Internet-Draft                  XMPP E2E                   February 2012

   [PKIX]     Cooper, D., Santesson, S., Farrell, S., Boeyen, S.,
              Housley, R. and W. Polk, "Internet X.509 Public Key
              Infrastructure Certificate and Certificate Revocation List
              (CRL) Profile", RFC 5280, May 2008.

   [SECTERMS]
              Shirey, R., "Internet Security Glossary, Version 2", RFC
              4949, August 2007.

   [X509-ALGO]
              Jonsson, J. and B. Kaliski, "Public-Key Cryptography
              Standards (PKCS) #1: RSA Cryptography Specifications
              Version 2.1", RFC 3447, February 2003.

11.2.  Informative References

   [OFFLINE]  Saint-Andre, P., "Best Practices for Handling Offline
              Messages", XSF XEP 0160, January 2006.

   [RFC3923]  Saint-Andre, P., "End-to-End Signing and Object Encryption
              for the Extensible Messaging and Presence Protocol
              (XMPP)", RFC 3923, October 2004.

   [RFC4086]  Eastlake, D., Schiller, J. and S. Crocker, "Randomness
              Requirements for Security", RFC 4086, June 2005.

   [RFC6120]  Saint-Andre, P., "Extensible Messaging and Presence
              Protocol (XMPP): Core", RFC 6121, March 2011.

   [RFC6121]  Saint-Andre, P., "Extensible Messaging and Presence
              Protocol (XMPP): Instant Messaging and Presence", RFC
              6121, March 2011.

Appendix A.  Schema for urn:ietf:params:xml:ns:xmpp-e2e:1

   The following XML schema is descriptive, not normative.

Miller                            std                          [Page 16]
Internet-Draft                  XMPP E2E                   February 2012

   <?xml version='1.0' encoding='UTF-8'?>
   
   <xs:schema
       xmlns:xs='http://www.w3.org/2001/XMLSchema'
       targetNamespace='urn:ietf:params:xml:ns:xmpp-e2e:1'
       xmlns='urn:ietf:params:xml:ns:xmpp-e2e:1'
       elementFormDefault='qualified'>
   
     <xs:element name='e2e'>
       <xs:complexType>
         <xs:attribute name='id' type='xs:string' use='required'/>
         <xs:sequence>
           <xs:element ref='header' minOccurs='1' maxOccurs='1'/>
           <xs:element ref='data' minOccurs='1' maxOccurs='1'/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
   
     <xs:element name='keyreq'>
       <xs:complexType>
         <xs:attribute name='id' type='xs:string' use='required'/>
         <xs:sequence>
           <xs:element ref='header' minOccurs='0' maxOccurs='1'/>
           <xs:element ref='pkey' minOccurs='0' maxOccurs='1'/>
           <xs:element ref='cek' minOccurs='0' maxOccurs='1'/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
   
     <xs:element name='cek'>
       <xs:complexType>
         <xs:simpleType>
           <xs:extension base='xs:string'>
           </xs:extension>
         </xs:simpleType>
       </xs:complexType>
     </xs:element>
   
     <xs:element name='data'>
       <xs:complexType>
         <xs:simpleType>
           <xs:extension base='xs:string'>
           </xs:extension>
         </xs:simpleType>
       </xs:complexType>
     </xs:element>
   
     <xs:element name='header'>
       <xs:complexType>
         <xs:simpleType>
           <xs:extension base='xs:string'>
           </xs:extension>
         </xs:simpleType>
       </xs:complexType>
     </xs:element>

Miller                            std                          [Page 17]
Internet-Draft                  XMPP E2E                   February 2012

   
     <xs:element name='pkey'>
       <xs:complexType>
         <xs:simpleType>
           <xs:extension base='xs:string'>
           </xs:extension>
         </xs:simpleType>
       </xs:complexType>
     </xs:element>
   
     <xs:element name='bad-timestamp' type='empty'/>
     <xs:element name='decryption-failed' type='empty'/>
     <xs:element name='insufficient-information' type='empty'/>
   
     <xs:simpleType name='empty'>
       <xs:restriction base='xs:string'>
         <xs:enumeration value=''/>
       </xs:restriction>
     </xs:simpleType>
   
   </xs:schema>

Author's Address

   Matthew Miller
   Cisco Systems, Inc.
   1899 Wyknoop Street, Suite 600
   Denver, CO 80202
   USA
   
   Phone: +1-303-308-3204
   Email: mamille2@cisco.com

Miller                            std                          [Page 18]