<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>OpenPGP for XMPP Instant Messaging</title>
  <abstract>Specifies a OpenPGP for XMPP (XEP-0373) profile for the Instant
    Messaging (IM) use case.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<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 Specification, 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 substantial 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 publisher 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.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<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, including 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 failure 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.</liability>
<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 &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0374</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0030</spec>
    <spec>XEP-0373</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>oxim</shortname>
  
  <author>
    <firstname>Florian</firstname>
    <surname>Schmaus</surname>
    <email>flo@geekplace.eu</email>
    <jid>flo@geekplace.eu</jid>
  </author>

  <author>
    <firstname>Dominik</firstname>
    <surname>Schürmann</surname>
    <email>dominik@dominikschuermann.de</email>
    <jid>dominik@dominikschuermann.de</jid>
  </author>
  <author>
    <firstname>Vincent</firstname>
    <surname>Breitmoser</surname>
    <email>look@my.amazin.horse</email>
    <jid>valodim@stratum0.org</jid>
  </author>
  <revision>
    <version>0.2.0</version>
    <date>2018-01-25</date>
    <initials>XEP Editor (jwi)</initials>
    <remark>Defer due to lack of activity.</remark>
  </revision>
  <revision>
	<version>0.1.2</version>
	<date>2017-01-20</date>
	<initials>fs</initials>
	<remark><p>Make use of XEP-0380: Explicit Message Encryption.</p></remark>
  </revision>
  <revision>
    <version>0.1.1</version>
    <date>2016-06-04</date>
    <initials>fs</initials>
    <remark><p>Minior editorial fixes.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2016-05-10</date>
    <initials>XEP Editor (ssw)</initials>
    <remark><p>Initial published version approved by the XMPP Council.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2016-03-25</date>
    <initials>fs</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>

<section1 topic="Introduction" anchor="intro">

  <p>This XMPP extension protocol specifies a profile of <span class="ref"><link url="https://xmpp.org/extensions/xep-0373.html">OpenPGP for XMPP (XEP-0373)</link></span> <note>XEP-0373: OpenPGP for XMPP &lt;<link url="https://xmpp.org/extensions/xep-0373.html">https://xmpp.org/extensions/xep-0373.html</link>&gt;.</note> for OpenPGP
    secured Instant Messaging (IM).</p>

  <p>Unlike similar XEPs, e.g., <span class="ref"><link url="https://xmpp.org/extensions/xep-0384.html">OMEMO Encryption (XEP-0384)</link></span> <note>XEP-0384: OMEMO Encryption &lt;<link url="https://xmpp.org/extensions/xep-0384.html">https://xmpp.org/extensions/xep-0384.html</link>&gt;.</note>, this XEP <em>does not</em>
  provide Forward Secrecy (FS), but as an advantage in return, allows
  users to read their archived conversations (respectively their
  encrypted data) later on. Of course, only as long as they still
  possess the according secret key. FS and being able to decrypt
  archived messages are mutually exclusive, i.e., one can not have
  both. The authors therefore consider this XEP complementary to
  similar ones which also provide end-to-end encryption but with a
  different feature set.</p>

</section1>

<section1 topic="OX Instant Messaging Profile" anchor="ox-im-profile">

    <section2 topic="Discovering Support" anchor="disco">

    <p>If an entity supports exchanging OpenPGP encrypted and signed
    instant messages over XMPP, i.e., what is specified herein, it MUST
    advertise that fact by announcing a <span class="ref"><link url="https://xmpp.org/extensions/xep-0030.html">Service Discovery (XEP-0030)</link></span> <note>XEP-0030: Service Discovery &lt;<link url="https://xmpp.org/extensions/xep-0030.html">https://xmpp.org/extensions/xep-0030.html</link>&gt;.</note> feature of
    'urn:xmpp:openpgp:im:0'. It thus includes this feature in response
    to a service discovery request.</p>

    <example caption="Service Discovery information request"><![CDATA[
<iq type='get'
    from='juliet@example.org/balcony'
    to='romeo@example.org/orchard'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>]]></example>
  <example caption="Service Discovery information response"><![CDATA[
<iq type='result'
    from='romeo@example.org/orchard'
    to='juliet@example.org/balcony'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    ...
    <feature var='urn:xmpp:openpgp:im:0'/>
    ...
  </query>
</iq>]]></example>

    <p>Because of possible downgrade attacks, users should be given an
    option to force the usage of the protocol defined herein no matter
    if the remote announces support or not.</p>

  </section2>

  <section2 topic="OpenPGP Secured Instant Messaging" anchor="openpgp-secured-im">

    <p>In order to establish an OpenPGP secured IM communication, IM
    clients first need to determine the public key of their
    interlocutor(s). OpenPGP historically provides public keyservers
    which can be used for key retrieval. Additional there are methods
    to store OpenPGP key information in the Domain Name
    System (DNS). This specification does not restrict the mechanism
    of key discovery and retrieval, but compliant clients MUST support
    the public key announcement as described in <span class="ref"><link url="https://xmpp.org/extensions/xep-0373.html">OpenPGP for XMPP (XEP-0373)</link></span> <note>XEP-0373: OpenPGP for XMPP &lt;<link url="https://xmpp.org/extensions/xep-0373.html">https://xmpp.org/extensions/xep-0373.html</link>&gt;.</note>
    <link url="./xep-0373.html#announcing-discover-pubkey">§ 4</link>.</p>

    <p>After the required public keys have been discovered, XMPP
    clients engage in an OpenPGP secured IM
    conversation by exchanging &lt;openpgp/&gt; extension elements. They MUST
    use the &lt;signcrypt/&gt; OpenPGP content element specified in
    <span class="ref"><link url="https://xmpp.org/extensions/xep-0373.html">OpenPGP for XMPP (XEP-0373)</link></span> <note>XEP-0373: OpenPGP for XMPP &lt;<link url="https://xmpp.org/extensions/xep-0373.html">https://xmpp.org/extensions/xep-0373.html</link>&gt;.</note><link url="./xep-0373.html#exchange">§ 3.1</link>.</p>

    <p>The child elements of the OpenPGP content element's &lt;payload/&gt;
    can be seen as stanza extension elements which are encrypted and
    signed. After the &lt;openpgp/&gt; element and the including &lt;signcrypt/&gt;,
    element was verified, they SHOULD be processed similar as if they
    had been direct extension elements of the stanza. For example,
    direct child elements found in &lt;payload/&gt; in the context of IM
    could be:</p>

    <ul>
      <li>Message bodies (<span class="ref"><link url="http://tools.ietf.org/html/rfc6121">RFC 6121</link></span> <note>RFC 6121: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence &lt;<link url="http://tools.ietf.org/html/rfc6121">http://tools.ietf.org/html/rfc6121</link>&gt;.</note> § 5.2.3): &lt;body xmlns='jabber:client'/&gt; </li>
      <li><span class="ref"><link url="https://xmpp.org/extensions/xep-0085.html">Chat State Notifications (XEP-0085)</link></span> <note>XEP-0085: Chat State Notifications &lt;<link url="https://xmpp.org/extensions/xep-0085.html">https://xmpp.org/extensions/xep-0085.html</link>&gt;.</note>: &lt;active xmlns='http://jabber.org/protocol/chatstates'/&gt;</li>
      <li><span class="ref"><link url="https://xmpp.org/extensions/xep-0071.html">XHTML-IM (XEP-0071)</link></span> <note>XEP-0071: XHTML-IM &lt;<link url="https://xmpp.org/extensions/xep-0071.html">https://xmpp.org/extensions/xep-0071.html</link>&gt;.</note>: &lt;html xmlns='http://jabber.org/protocol/xhtml-im'/&gt;</li>
    </ul>

    <p>But just as with stanza extension elements, child elements of
    &lt;payload/&gt; can be any extension element. The example above uses
    the &lt;body/&gt; element as defined in RFC 6121. Note that it
    uses 'jabber:client' as namespace, but since the same
    &lt;body/&gt; element is also defined in the 'jabber:server'
    namespace, recipients MUST accept both.</p>

  </section2>

  <section2 topic="OpenPGP Key Handling" anchor="openpgp-key-handling">

    <section3 topic="Choosing Public Keys" anchor="choose-pubkey">

      <p>Clients MUST expect multiple public keys to be announced for a single remote entity. In this case all keys MUST be used for encryption.</p>

    </section3>

      <section3 topic="OpenPGP Secret Key Synchronization" anchor="openpgp-secret-key-sync">

      <p>Clients MAY want to use the mechanism in <cite>XEP-0373 § 5</cite> to
      synchronize their secret key(s) over multiple devices. Thus, they
      should query the user's PEP service for an eventually stored
      encrypted secret key.</p>

    </section3>

  </section2>

</section1>

<section1 topic="Business Rules" anchor="rules">

  <section2 topic="Always Use &lt;signcrypt/&gt;" anchor="signcrypt-im-use-case">

    <p>Only &lt;signcrypt/&gt; MUST be used for the IM
    use case. Encrypted but unsigned messages (&lt;crypt/&gt;) do not provide
    an advantage over unencrypted ones since the sender can not be
    verified. As result of this rule, the user interface of
    IM clients implementing the protocol defined herein MUST NOT
    provide an option for the user to select between sign+crypt, sign
    or crypt. This also increases the usability.</p>

  </section2>

  <section2 topic="Provide Hints" anchor="hint-im-use-case">

    <p>In the IM use case every &lt;message/&gt; equipped with &lt;openpgp/&gt;
    SHOULD include an unencrypted &lt;body/&gt; explaining that the actual
    message is encrypted. Furthermore the message SHOULD contain a
    'store' hint as defined in <span class="ref"><link url="https://xmpp.org/extensions/xep-0334.html">Message Processing Hints (XEP-0334)</link></span> <note>XEP-0334: Message Processing Hints &lt;<link url="https://xmpp.org/extensions/xep-0334.html">https://xmpp.org/extensions/xep-0334.html</link>&gt;.</note> <link url="https://xmpp.org/extensions/xep-0334.html#sect-idp1502160">§
    4.4</link> and a "this message contains an encrypted body text" hint
	in form of an &lt;encryption/&gt; extension element as specified by
	<span class="ref"><link url="https://xmpp.org/extensions/xep-0380.html">Explicit Message Encryption (XEP-0380)</link></span> <note>XEP-0380: Explicit Message Encryption &lt;<link url="https://xmpp.org/extensions/xep-0380.html">https://xmpp.org/extensions/xep-0380.html</link>&gt;.</note>.</p>

    <example caption="An encrypted and signed message with hints."><![CDATA[
<message to='juliet@example.org'>
  <body>This message is encrypted using OpenPGP.</body>
  <store xmlns='urn:xmpp:hints'/>
  <encryption xmlns='urn:xmpp:eme:0' namespace='urn:xmpp:openpgp:0'/>
  <openpgp xmlns='urn:xmpp:openpgp:0'>
    BASE64_OPENPGP_MESSAGE_CONTAINING_CONTENT_ELEMENT
  </openpgp>
</message>]]></example>

  </section2>

</section1>

<section1 topic="IANA Considerations" anchor="iana">

  <p>This document requires no interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>

</section1>

<section1 topic="XMPP Registrar Considerations" anchor="registrar">

  <section2 topic="Protocol Namespaces" anchor="registrar-ns">

    <p>The <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note> includes 'urn:xmpp:openpgp:0' in its registry of protocol namespaces (see &lt;<link url="https://xmpp.org/registrar/namespaces.html">https://xmpp.org/registrar/namespaces.html</link>&gt;).</p>

  </section2>

</section1>

<section1 topic="XML Schema" anchor="schema">

  <p>This XEP does not define a Schema, since it exclusively uses elements from
  <span class="ref"><link url="https://xmpp.org/extensions/xep-0373.html">OpenPGP for XMPP (XEP-0373)</link></span> <note>XEP-0373: OpenPGP for XMPP &lt;<link url="https://xmpp.org/extensions/xep-0373.html">https://xmpp.org/extensions/xep-0373.html</link>&gt;.</note> and other XEPs.</p>

</section1>

<section1 topic="Acknowledgements" anchor="acknowledgements">
  <p>
    Please refer to the
    <link url="./xep-0373.html#acknowledgements">Acknowledgements section</link>
    of <span class="ref"><link url="https://xmpp.org/extensions/xep-0373.html">OpenPGP for XMPP (XEP-0373)</link></span> <note>XEP-0373: OpenPGP for XMPP &lt;<link url="https://xmpp.org/extensions/xep-0373.html">https://xmpp.org/extensions/xep-0373.html</link>&gt;.</note> since the two XEPs where designed together.
  </p>
</section1>
</xep>
