You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0116.xml 70KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. <!ENTITY esupy "e<span class='super'>y</span>">
  6. <!ENTITY dsupx "d<span class='super'>x</span>">
  7. <!ENTITY gsupx "g<span class='super'>x</span>">
  8. <!ENTITY gsupy "g<span class='super'>y</span>">
  9. <!ENTITY NsubA "N<span class='sub'>A</span>">
  10. <!ENTITY NsubB "N<span class='sub'>B</span>">
  11. <!ENTITY CsubA "C<span class='sub'>A</span>">
  12. <!ENTITY CsubB "C<span class='sub'>B</span>">
  13. <!ENTITY MsubA "M<span class='sub'>A</span>">
  14. <!ENTITY MsubB "M<span class='sub'>B</span>">
  15. <!ENTITY KMsubA "KM<span class='sub'>A</span>">
  16. <!ENTITY KMsubB "KM<span class='sub'>B</span>">
  17. <!ENTITY KCsubA "KC<span class='sub'>A</span>">
  18. <!ENTITY KCsubB "KC<span class='sub'>B</span>">
  19. <!ENTITY KSsubA "KS<span class='sub'>A</span>">
  20. <!ENTITY KSsubB "KS<span class='sub'>B</span>">
  21. <!ENTITY twosup32 "2<span class='super'>32</span>">
  22. <!ENTITY twosup2n "2<span class='super'>2n-1</span>">
  23. <!ENTITY CBeCAx2n1 "&CsubB; = &CsubA; XOR 2<span class='super'>n-1</span>">
  24. <!ENTITY IDA "ID<span class='sub'>A</span>">
  25. <!ENTITY IDB "ID<span class='sub'>B</span>">
  26. <!ENTITY formA "form<span class='sub'>A</span>">
  27. <!ENTITY formB "form<span class='sub'>B</span>">
  28. <!ENTITY macA "mac<span class='sub'>A</span>">
  29. <!ENTITY macB "mac<span class='sub'>B</span>">
  30. <!ENTITY signA "sign<span class='sub'>A</span>">
  31. <!ENTITY signB "sign<span class='sub'>B</span>">
  32. <!ENTITY signsA "signs<span class='sub'>A</span>">
  33. <!ENTITY signsB "signs<span class='sub'>B</span>">
  34. <!ENTITY pubKeyA "pubKey<span class='sub'>A</span>">
  35. <!ENTITY pubKeyB "pubKey<span class='sub'>B</span>">
  36. <!ENTITY signKeyA "signKey<span class='sub'>A</span>">
  37. <!ENTITY signKeyB "signKey<span class='sub'>B</span>">
  38. <!ENTITY pubKeysA "pubKeys<span class='sub'>A</span>">
  39. <!ENTITY signKeysA "signKeys<span class='sub'>A</span>">
  40. <!ENTITY x1xZ "x<span class='sub'>1</span>...x<span class='sub'>Z</span>">
  41. <!ENTITY e1eZ "e<span class='sub'>1</span>...e<span class='sub'>Z</span>">
  42. ]>
  43. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  44. <xep>
  45. <header>
  46. <title>Encrypted Sessions</title>
  47. <abstract>This document specifies an XMPP protocol extension for session-based, end-to-end encryption.</abstract>
  48. &LEGALNOTICE;
  49. <number>0116</number>
  50. <status>Experimental</status>
  51. <type>Standards Track</type>
  52. <jig>Standards JIG</jig>
  53. <dependencies>
  54. <spec>XMPP Core</spec>
  55. <spec>RFC 2104</spec>
  56. <spec>RFC 2409</spec>
  57. <spec>RFC 3526</spec>
  58. <spec>RFC 3548</spec>
  59. <spec>xml-c14n</spec>
  60. <spec>XEP-0004</spec>
  61. <spec>XEP-0020</spec>
  62. <spec>XEP-0030</spec>
  63. <spec>XEP-0068</spec>
  64. <spec>XEP-0155</spec>
  65. </dependencies>
  66. <supersedes>None</supersedes>
  67. <supersededby>None</supersededby>
  68. <shortname>esession</shortname>
  69. &ianpaterson;
  70. &stpeter;
  71. &dizzyd;
  72. <revision>
  73. <version>0.11</version>
  74. <date>2006-10-02</date>
  75. <initials>ip</initials>
  76. <remark><p>Harmonised session termination with the protocol added to XEP-0155; added XML schema; minor clarifications</p></remark>
  77. </revision>
  78. <revision>
  79. <version>0.10</version>
  80. <date>2006-07-18</date>
  81. <initials>ip</initials>
  82. <remark><p>Added Upgradability requirement; added expires field to offline options; updated in line with latest version of PEP; moved some content to new XEPs (0187, 0188 and 0189)</p></remark>
  83. </revision>
  84. <revision>
  85. <version>0.9</version>
  86. <date>2005-11-29</date>
  87. <initials>ip</initials>
  88. <remark><p>Modified protocol in line with SIGMA: added Identity Protection requirement, no pre-indication of acceptable keys, send multiple values of e with ESession request, offline options published via SPPS, added LZW compression</p></remark>
  89. </revision>
  90. <revision>
  91. <version>0.8</version>
  92. <date>2005-09-27</date>
  93. <initials>ip</initials>
  94. <remark><p>Added diagramatic synopses; Added match_resource field; replaced req_mac and kid fields with prev_hash; Alice specifies initial counter (doubles as nonce); many other improvements</p></remark>
  95. </revision>
  96. <revision>
  97. <version>0.7</version>
  98. <date>2005-08-26</date>
  99. <initials>ip</initials>
  100. <remark><p>Simplified XML normalization; added Synopsis and Efficiency requirement; defined signature formats</p></remark>
  101. </revision>
  102. <revision>
  103. <version>0.6</version>
  104. <date>2005-08-12</date>
  105. <initials>ip</initials>
  106. <remark><p>Extended termination procedure; added object encryption/signing requirement and special case; clarified expired MAC publishing; added Flexible Offline Message Retrieval to Open Issues.</p></remark>
  107. </revision>
  108. <revision>
  109. <version>0.5</version>
  110. <date>2005-08-10</date>
  111. <initials>ip</initials>
  112. <remark><p>Added flexibility requirement; added late signature of initial request; added termination MAC.</p></remark>
  113. </revision>
  114. <revision>
  115. <version>0.4</version>
  116. <date>2005-08-09</date>
  117. <initials>ip</initials>
  118. <remark><p>Added (offline) replay protection; required offline Created header; compression is NOT RECOMMENDED; added second set of offline options for subscribers; added JIDs to session key generation; unencrypted sessions; added secure option; sign whole data form; HMAC whole &lt;encrypted/&gt; element; added ESession termination; option to distribute public keys within session negotiation; added Integrity requirement; several clarifications</p></remark>
  119. </revision>
  120. <revision>
  121. <version>0.3</version>
  122. <date>2005-08-02</date>
  123. <initials>ip/psa</initials>
  124. <remark><p>Restored status to Experimental; complete rewrite; new Introduction, Background, Requirements and Security Considerations; new OTR-inspired protocol; XEP-0155-based negotiation; counter mode encryption; more secure hashes; offline sessions; re-keying; mac publishing; preliminary key and options publishing protocol.</p></remark>
  125. </revision>
  126. <revision>
  127. <version>0.2</version>
  128. <date>2004-07-26</date>
  129. <initials>psa</initials>
  130. <remark><p>At the request of the author, changed status to Retracted.</p></remark>
  131. </revision>
  132. <revision>
  133. <version>0.1</version>
  134. <date>2003-09-09</date>
  135. <initials>dss/psa</initials>
  136. <remark><p>Initial version.</p></remark>
  137. </revision>
  138. </header>
  139. <section1 topic='Introduction' anchor='intro'>
  140. <p>End-to-end encryption is a desirable feature for any communication technology. Ideally, such a technology would design encryption in from the beginning and would forbid unencrypted communications. Realistically, most communication technologies have not been designed in that manner, and Jabber/XMPP technologies are no exception. In particular, the original Jabber technologies developed in 1999 did not include end-to-end encryption by default. PGP-based encryption of message bodies and signing of presence information was added as an extension to the core protocols in the year 2000; this extension is documented in &xep0027;. When the core protocols were formalized within the Internet Standards Process by the IETF's XMPP Working Group in 2003, a different extension was defined using S/MIME-based signing and encryption of CPIM-formatted messages (see &rfc3862;) and PIDF-formatted presence information (see &rfc3863;); this extension is specified in &rfc3923;.</p>
  141. <p>For reasons described in &xep0188;, the foregoing proposals (and others not mentioned) have not been widely implemented and deployed. This is unfortunate, since an open communication protocol needs to enable end-to-end encryption in order to be seriously considered for deployment by a broad range of users.</p>
  142. <p>This proposal describes a different approach to end-to-end encryption for use by entities that communicate using XMPP. The requirements and the consequent cryptographic design that underpin this protocol are described in <cite>Cryptographic Design of Encrypted Sessions</cite>. The basic concept is that of an encrypted session which acts as a secure tunnel between two endpoints. Once the tunnel is established, the content of each one-to-one XML stanza exchanged between the endpoints will be encrypted and then transmitted within a "wrapper" stanza.</p>
  143. </section1>
  144. <section1 topic="Dramatis Personae" anchor='personae'>
  145. <p>This document introduces two characters to help the reader follow the necessary exchanges:</p>
  146. <ol start='1'>
  147. <li>"Alice" is the name of the initiator of the ESession. Within the scope of this document, we stipulate that her fully-qualified JID is: &lt;alice@example.org/pda&gt;.</li>
  148. <li>"Bob" is the name of the other participant in the ESession started by Alice. Within the scope of this document, his fully-qualified JID is: &lt;bob@example.com/laptop&gt;.</li>
  149. <li>"Aunt Tillie" the archetypal typical user (i.e. non-technical, with only very limited knowledge of how to use a computer, and averse to performing any procedures that are not familiar).</li>
  150. </ol>
  151. <p>While Alice and Bob are introduced as "end users", they are simply meant to be examples of Jabber entities. Any directly addressable Jabber entity may participate in an ESession.</p>
  152. </section1>
  153. <section1 topic='Discovering Support' anchor='disco'>
  154. <p>Before attempting to engage in an ESession with Bob, Alice SHOULD discover whether he supports this protocol, using either &xep0030; or the presence-based profile of <cite>XEP-0030</cite> specified in &xep0115;.</p>
  155. <p>The normal course of events is for Alice to authenticate with her server, retrieve her roster (see <cite>RFC 3921</cite>), send initial presence to her server, and then receive presence information from all the contacts in her roster. If the presence information she receives from some contacts does not include capabilities data (per <cite>XEP-0115</cite>), Alice SHOULD then send a service discovery information ("disco#info") request to each of those contacts (in accordance with <cite>XEP-0030</cite>). Such initial service discovery stanzas MUST NOT be considered part of encrypted communication sessions for the purposes of this document, since they perform a "bootstrapping" function that is a prerequisite to encrypted communications. The disco#info request sent from Alice to Bob might look as follows:</p>
  156. <example caption='Alice Queries Bob for ESession Support via Disco'><![CDATA[
  157. <iq type='get'
  158. from='alice@example.org/pda'
  159. to='bob@example.com/laptop'
  160. id='disco1'>
  161. <query xmlns='http://jabber.org/protocol/disco#info'/>
  162. </iq>
  163. ]]></example>
  164. <p>If Bob sends a disco#info reply and he supports the protocol defined herein, then he MUST include a service discovery feature variable of "http://jabber.org/protocol/esession".</p>
  165. <example caption='Bob Returns disco#info Data'><![CDATA[
  166. <iq type='result'
  167. from='bob@example.com/laptop'
  168. to='alice@example.org/pda'
  169. id='disco1'>
  170. <query xmlns='http://jabber.org/protocol/disco#info'>
  171. <identity category='client' type='pc'/>
  172. ...
  173. <feature var='http://jabber.org/protocol/esession'/>
  174. ...
  175. </query>
  176. </iq>
  177. ]]></example>
  178. </section1>
  179. <section1 topic="Online ESession Negotiation" anchor='init'>
  180. <p>The process for establishing a secure session over an insecure transport is essentially a negotiation of various ESession algorithms and other parameters, combined with a translation into XMPP syntax of the &sigma; approach to key exchange (see <cite>Cryptographic Design of Encrypted Sessions</cite>).</p>
  181. <p>If Alice believes Bob may be online then she SHOULD use the protocol specified in &xep0155; and in this section to negotiate the ESession options and the keys.</p>
  182. <p>Note: If Alice believes Bob is offline then she SHOULD NOT use this negotiation protocol. However, she MAY use the protocol specified in <cite>Offline Encrypted Sessions</cite> to establish the ESession options and keys. Alternatively, she MAY send stanzas without encryption - in which case her client MUST make absolutely clear to her that the stanzas will not be protected and give her the option not to send the stanzas.</p>
  183. <p>Note: In any case, Alice MUST NOT initiate a new ESession with Bob if she already has one established with him.</p>
  184. <section2 topic="ESession Request" anchor='init-online-request'>
  185. <p>In addition to the "accept", "otr" and "secure" fields specified in <cite>Chat Session Negotiation</cite>, Alice MUST send to Bob each of the ESession options (see list below) that she is willing to use, in her order of preference (see <link url='#sec-mandatory'>Mandatory to Implement Technologies</link>). Note: Alice SHOULD NOT include a "reason" field since Aunt Tillie may not be aware the ESession request is <em>not</em> encrypted.</p>
  186. <ol>
  187. <li><p>The list of Modular Exponential (MODP) group numbers (as specified in &rfc2409; or &rfc3526;) that MAY be used for Diffie-Hellman key exchange (valid group numbers include 1,2,3,4,5,14,15,16,17 and 18)</p></li>
  188. <li><p>Symmetric block cipher algorithm names</p></li>
  189. <li><p>Hash algorithm names</p></li>
  190. <li><p>Signature algorithm names</p></li>
  191. <li><p>Compression algorithm names</p></li>
  192. <li><p>The list of stanza types that MAY be encrypted and decrypted</p></li>
  193. <li><p>Whether or not the other entity MUST send the fingerprint of its public signature-verification key instead of the full key <note>If the entity already possesses one of the other entity's public keys then it is RECOMMENDED that only the fingerprint is requested from the other entity - since this saves bandwidth.</note></p></li>
  194. <li><p>The different versions of this protocol that are supported <note>This version of this document describes version 1.0 of this protocol.</note></p></li>
  195. <li><p>The minimum number of stanzas that MUST be exchanged before an entity MAY initiate a key re-exchange (1 - every stanza, 100 - every hundred stanzas). Note: This value MUST be less than &twosup32; (see <link url='#sec-rekey'>Re-Keying Limits</link>)</p></li>
  196. </ol>
  197. <p>Each MODP group has at least two well known constants: a large prime number p, and a generator g for a subgroup of GF(p). For each MODP group that Alice specifies she MUST perform the following computations to calculate her Diffie-Hellman keys (where n is the number of bits per cipher block for the block cipher algorithm with the largest block size out of those she specified):</p>
  198. <ol>
  199. <li><p>Generate a secret random number x (where &twosup2n; &lt; x &lt; p - 1)</p></li>
  200. <li><p>Calculate e = &gsupx; mod p</p></li>
  201. </ol>
  202. <p>Alice MUST send all her calculated values of e to Bob (in the same order as the associated MODP groups are being sent). She MUST also specify randomly generated Base64 encoded (in accordance with Section 3 of &rfc3548;) value of &NsubA; (her ESession ID).</p>
  203. <example caption='Alice Requests an ESession'><![CDATA[
  204. <message from='alice@example.org/pda' to='bob@example.com'>
  205. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  206. <x type='form' xmlns='jabber:x:data'>
  207. <field type="hidden" var="FORM_TYPE">
  208. <value>http://jabber.org/protocol/chatneg</value>
  209. </field>
  210. <field type="boolean" var="accept">
  211. <value>1</value>
  212. </field>
  213. <field type="boolean" var="otr">
  214. <value>0</value>
  215. </field>
  216. <field type="boolean" var="secure">
  217. <value>0</value>
  218. </field>
  219. <field type="list-single" var="modp">
  220. <option><value>5</value></option>
  221. <option><value>14</value></option>
  222. <option><value>2</value></option>
  223. </field>
  224. <field type="list-single" var="crypt_algs">
  225. <option><value>aes256-ctr</value></option>
  226. <option><value>twofish256-ctr</value></option>
  227. <option><value>aes128-ctr</value></option>
  228. </field>
  229. <field type="list-single" var="hash_algs">
  230. <option><value>whirlpool</value></option>
  231. <option><value>sha256</value></option>
  232. </field>
  233. <field type="list-single" var="sign_algs">
  234. <option><value>rsa</value></option>
  235. <option><value>dsa</value></option>
  236. </field>
  237. <field type="list-single" var="compress">
  238. <option><value>none</value></option>
  239. </field>
  240. <field type="list-multi" var="stanzas">
  241. <option><value>message</value></option>
  242. <option><value>iq</value></option>
  243. <option><value>presence</value></option>
  244. </field>
  245. <field type="boolean" var="pk_hash">
  246. <value>0</value>
  247. </field>
  248. <field type="list-single" var="ver">
  249. <option><value>1.3</value></option>
  250. <option><value>1.2</value></option>
  251. </field>
  252. <field type="text-single" var="rekey_freq">
  253. <value>1</value>
  254. </field>
  255. <field var="my_nonce">
  256. <value> ** Base64 encoded ESession ID ** </value>
  257. </field>
  258. <field var="keys">
  259. <value> ** Base64 encoded value of e5 ** </value>
  260. <value> ** Base64 encoded value of e14 ** </value>
  261. <value> ** Base64 encoded value of e2 ** </value>
  262. </field>
  263. </x>
  264. </feature>
  265. <amp xmlns='http://jabber.org/protocol/amp' per-hop='true'>
  266. <rule action='drop' condition='deliver' value='stored'/>
  267. </amp>
  268. </message>
  269. ]]></example>
  270. <p>If Bob does not support one or more of the options in each ESession field, then he SHOULD return a &feature; error (but he MAY return no error if, for example, he does not want to reveal his presence to Alice for whatever reason):</p>
  271. <example caption='Bob Informs Alice that Her Options Are Not Supported'><![CDATA[
  272. <message type='error'
  273. from='bob@example.com/laptop'
  274. to='alice@example.org/pda'>
  275. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  276. ...
  277. </feature>
  278. <error type='cancel'>
  279. <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  280. <unsupported-options xmlns='http://jabber.org/protocol/esession#error'/>
  281. </error>
  282. </message>
  283. ]]></example>
  284. <p>Either Bob or Alice MAY attempt to initiate a new ESession after any error during the negotiation process. However, both MUST consider the previous negotiation to have failed and MUST discard any information learned through the previous negotiation.</p>
  285. <p>If Bob is unwilling to start an ESession, but he <em>is</em> ready to initiate a one-to-one chat session with Alice (see <cite>Chat Session Negotiation</cite>), then he SHOULD accept the Chat Session and terminate the ESession negotiation by <em>not</em> including a 'nonce' field in his response.</p>
  286. <example caption='Bob Accepts Chat Session'><![CDATA[
  287. <message from='bob@example.com/laptop' to='alice@example.org/pda'>
  288. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  289. <x type='submit' xmlns='jabber:x:data'>
  290. <field var="FORM_TYPE">
  291. <value>http://jabber.org/protocol/chatneg</value>
  292. </field>
  293. <field var="accept"><value>1</value></field>
  294. <field var="otr"><value>1</value></field>
  295. <field var="secure"><value>0</value></field>
  296. </x>
  297. </feature>
  298. </message>
  299. ]]></example>
  300. </section2>
  301. <section2 topic="Diffie-Hellman Preparation (Bob)" anchor='init-online-bobprep'>
  302. <p>If Bob supports one or more of each of Alice's ESession options and is willing to start an ESession with Alice, then he MUST select one of the options from each of the ESession fields he received from Alice including one hash algorithm ("HASH"), and one of the MODP groups and Alice's corresponding value of e (see &rfc3766; or <cite>RFC 3526</cite> for recommendations regarding balancing the sizes of symmetric cipher blocks and Diffie-Hellman moduli).</p>
  303. <p>Each MODP group has at least two well known constants: a large prime number p, and a generator g for a subgroup of GF(p). Bob SHOULD return a &feature; error unless: 1 &lt; e &lt; p - 1</p>
  304. <p>Bob MUST then perform the following computations (where n is the number of bits per cipher block for the selected block cipher algorithm):</p>
  305. <ol start='1'>
  306. <li><p>Generate a random number &NsubB; (his ESession ID)</p></li>
  307. <li><p>Generate an n-bit random number &CsubA; (the block cipher counter for stanzas sent from Alice to Bob)</p></li>
  308. <li><p>Set &CBeCAx2n1; (where &CsubB; is the block counter for stanzas sent from Bob to Alice)</p></li>
  309. <li><p>Generate a secret random number y (where &twosup2n; &lt; y &lt; p - 1)</p></li>
  310. <li><p>Calculate d = &gsupy; mod p</p></li>
  311. <li><p>Calculate K = HASH(&esupy; mod p) (the shared secret)</p></li>
  312. </ol>
  313. </section2>
  314. <section2 topic="Generating Session Keys" anchor='init-keys'>
  315. <p>Bob MUST use the shared secret ("K") and the selected hash algorithm ("HASH") to generate two sets of three keys, one set for each direction of the ESession.</p>
  316. <p>For stanzas that Alice will send to Bob, the keys are calculated as:</p>
  317. <ol>
  318. <li><p>Encryption key &KCsubA; = HASH(K, 0)</p></li>
  319. <li><p>Integrity key &KMsubA; = HASH(K, 2)</p></li>
  320. <!-- <note>&KMsubA; is a hash of &KCsubA; (not K) to ensure that if an attacker recovers the decryption key she will not be able to cryptographically convince anyone that it was not her who created the stanza.</note> -->
  321. <li><p>SIGMA key &KSsubA; = HASH(K, 4)</p></li>
  322. </ol>
  323. <p>For stanzas that Bob will send to Alice the keys are calculated as:</p>
  324. <ol start='4'>
  325. <li><p>Encryption key &KCsubB; = HASH(K, 1)</p></li>
  326. <li><p>Integrity key &KMsubB; = HASH(K, 3)</p></li>
  327. <li><p>SIGMA key &KSsubB; = HASH(K, 5)</p></li>
  328. </ol>
  329. <p>Once the sets of keys have been calculated the value of K MUST be securely destroyed.</p>
  330. <p>Note: As many bits of key data as are needed for each key MUST be taken from the least significant bits of the hash output. When negotiating a hash, entities MUST ensure that the hash output is no shorter than the required key data. For algorithms with variable-length keys the maximum length (up to the hash output length) SHOULD be used.</p>
  331. </section2>
  332. <section2 topic="Hiding Identity" anchor='init-hide'>
  333. <p>Bob MUST perform the following steps before he can prove his identity to Alice while protecting it from third parties.</p>
  334. <ol>
  335. <li><p>Select &pubKeyB;, the public key Alice should use to authenticate his signature with the signature algorithm he selected ("SIGN").</p></li>
  336. <li><p>Set &formB; to the <link url='#sign-normal'>Normalized</link>&#160;<em>content</em> of the reponse data form he will send back to Alice (including his responses for all the fields he received from Alice).</p>
  337. <p>Bob MUST encapsulate the Base64 encoded values of &CsubA; and Alice's &NsubA; in two new 'counter' and 'nonce' fields and add them to &formB;. Note: The 'pk_hash' field specifies whether or not Alice MUST send the fingerprint of her public signature-verification key instead of her full key. Note: The value of the 'rekey_freq' field MUST be less than &twosup32; and greater than or equal to the value specified by Alice. Note: Bob MUST place his Base64 encoded values of &NsubB; and d in the 'my_nonce' and 'keys' fields. Bob MUST NOT return Alice's values of e.</p></li>
  338. <li><p>Concatenate Alice's ESession ID, Bob's ESession ID, d, &pubKeyB; and &formB;, and calculate the HMAC (as defined in Section 2 of &rfc2104;) of the resulting byte string using the selected hash algorithm ("HASH") and the key &KSsubB;.</p>
  339. <code>&macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &formB;})</code></li>
  340. <li><p>Calculate &signB;, the signature of the HMAC result using his private signature key that corresponds to &pubKeyB;</p>
  341. <code>&signB; = SIGN(&signKeyB;, &macB;)</code></li>
  342. <li><p>If the value of the 'pk_hash' field that Alice sent Bob was true then Bob SHOULD set &pubKeyB; to the key's fingerprint</p>
  343. <code>if (pk_hash) &pubKeyB; = HASH(&pubKeyB;)</code></li>
  344. <li><p>Concatenate &pubKeyB; and &signB; and encrypt the resulting byte string with the agreed algorithm ("CIPHER") in counter mode (see &nistfips800-38a;), using the encryption key &KCsubB; and block counter &CsubB;. Note: &CsubB; MUST be incremented by 1 for each encrypted block or partial block (i.e. &CsubB; = (&CsubB; + 1) mod 2<span class='super'>n</span>, where n is the number of bits per cipher block for the agreed block cipher algorithm).</p>
  345. <code>&IDB; = CIPHER(&KCsubB;, &CsubB;, {&pubKeyB;, &signB;})</code></li>
  346. <li><p>Calculate the HMAC of the encrypted identity (&IDB;) and the value of Bob's block cipher counter &CsubB;&#160;<em>before</em> the encryption above using the selected hash algorithm ("HASH") and the integrity key &KMsubB;.</p>
  347. <code>&MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)</code></li>
  348. </ol>
  349. </section2>
  350. <section2 topic="ESession Response" anchor='init-online-response'>
  351. <p>Bob responds to Alice by sending her &formB;.</p>
  352. <example caption='Bob Responds to Alice (4-Message Negotiation)'><![CDATA[
  353. <message from='bob@example.com/laptop' to='alice@example.org/pda'>
  354. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  355. <x type='submit' xmlns='jabber:x:data'>
  356. <field var="FORM_TYPE">
  357. <value>http://jabber.org/protocol/chatneg</value>
  358. </field>
  359. <field var="accept"><value>1</value></field>
  360. <field var="otr"><value>1</value></field>
  361. <field var="secure"><value>0</value></field>
  362. <field var="modp"><value>5</value></field>
  363. <field var="crypt_algs"><value>aes256-ctr</value></field>
  364. <field var="hash_algs"><value>sha256</value></field>
  365. <field var="sign_algs"><value>rsa</value></field>
  366. <field var="compress"><value>none</value></field>
  367. <field var="stanzas"><value>message</value></field>
  368. <field var="pk_hash"><value>1</value></field>
  369. <field var="ver"><value>1.3</value></field>
  370. <field var="rekey_freq"><value>50</value></field>
  371. <field var="my_nonce">
  372. <value> ** Base64 encoded ESession ID ** </value>
  373. </field>
  374. <field var="keys">
  375. <value> ** Base64 encoded value of d ** </value>
  376. </field>
  377. <field var="nonce">
  378. <value> ** Base64 encoded ESession ID ** </value>
  379. </field>
  380. <field var="counter">
  381. <value> ** Base64 encoded block counter ** </value>
  382. </field>
  383. </x>
  384. </feature>
  385. </message>
  386. ]]></example>
  387. <p>If Bob prefers the RECOMMENDED 3-message ESession negotiation, where Alice's identity is protected from active attacks instead of his own, then he should encapsulate the Base64 encoded values of &IDB; and &MsubB; in data form fields ('identity' and 'mac'), and append the new fields to &formB; before sending it to Alice.</p>
  388. <example caption='Bob Responds to Alice (3-Message Negotiation)'><![CDATA[
  389. <message from='bob@example.com/laptop' to='alice@example.org/pda'>
  390. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  391. <x type='submit' xmlns='jabber:x:data'>
  392. <field var="FORM_TYPE">
  393. <value>http://jabber.org/protocol/chatneg</value>
  394. </field>
  395. <field var="accept"><value>1</value></field>
  396. <field var="otr"><value>1</value></field>
  397. <field var="secure"><value>0</value></field>
  398. <field var="modp"><value>5</value></field>
  399. <field var="crypt_algs"><value>aes256-ctr</value></field>
  400. <field var="hash_algs"><value>sha256</value></field>
  401. <field var="sign_algs"><value>rsa</value></field>
  402. <field var="compress"><value>none</value></field>
  403. <field var="stanzas"><value>message</value></field>
  404. <field var="pk_hash"><value>1</value></field>
  405. <field var="ver"><value>1.3</value></field>
  406. <field var="rekey_freq"><value>50</value></field>
  407. <field var="my_nonce">
  408. <value> ** Base64 encoded ESession ID ** </value>
  409. </field>
  410. <field var="keys">
  411. <value> ** Base64 encoded value of d ** </value>
  412. </field>
  413. <field var="nonce">
  414. <value> ** Base64 encoded ESession ID ** </value>
  415. </field>
  416. <field var="counter">
  417. <value> ** Base64 encoded block counter ** </value>
  418. </field>
  419. <field var="identity">
  420. <value> ** Encrypted identity ** </value>
  421. </field>
  422. <field var="mac">
  423. <value> ** Integrity of identity ** </value>
  424. </field>
  425. </x>
  426. </feature>
  427. </message>
  428. ]]></example>
  429. </section2>
  430. <section2 topic="Diffie-Hellman Preparation (Alice)" anchor='init-online-aliceprep'>
  431. <p>After Alice receives Bob's response, she MUST use the value of d and the ESession options specified in Bob's response to perform the following steps (where p and g are the constants associated with the selected MODP group, HASH is the selected hash algorithm, and n is the number of bits per cipher block for the agreed block cipher algorithm):</p>
  432. <ol start='1'>
  433. <li><p>Return a &feature; error to Bob if she is not prepared to support any of the ESession options specified by Bob (if any of the options were not included in her initial ESession request)</p></li>
  434. <li><p>Return a &feature; error to Bob unless: 1 &lt; d &lt; p - 1</p></li>
  435. <li><p>Set &CBeCAx2n1; (where &CsubB; is the block counter for stanzas sent from Bob to Alice)</p></li>
  436. <li><p>Select her values of x and e that correspond to the selected MODP group (from all the values of x and e she calculated previously)</p></li>
  437. <li><p>Calculate K = HASH(&dsupx; mod p) (the shared secret)</p></li>
  438. <li><p>Generate the session keys (&KCsubA;, &KMsubA;, &KSsubA;, &KCsubB;, &KMsubB; and &KSsubB;) in the same way as Bob did (see <link url='#init-keys'>Generating Session Keys</link>)</p></li>
  439. </ol>
  440. </section2>
  441. <section2 topic="Verifying Bob's Identity" anchor='init-online-bobid'>
  442. <p>If Bob included 'identity' and 'mac' fields in his response then Alice MUST also perform the following steps:</p>
  443. <ol start='1'>
  444. <li><p>Calculate the HMAC of the encrypted identity (&IDB;) and the value of Bob's block cipher counter using HASH and the integrity key &KMsubB;.</p>
  445. <code>&MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)</code></li>
  446. <li><p>Return a &feature; error to Bob unless the value of &MsubB; she calculated matches the one she received in the 'mac' field</p></li>
  447. <li><p>Obtain &pubKeyB; and &signB; by decrypting &IDB; with the agreed symmetric block cipher algorithm ("DECIPHER") in counter mode, using the encryption key &KCsubB; and block counter &CsubB;. Note: &CsubB; MUST be incremented by 1 for each encrypted block or partial block (i.e. &CsubB; = (&CsubB; + 1) mod 2<span class='super'>n</span>, where n is the number of bits per cipher block for the agreed block cipher algorithm).</p>
  448. <code>{&pubKeyB;, &signB;} = DECIPHER(&KCsubB;, &CsubB;, &IDB;)</code></li>
  449. <li><p>If the value of the 'pk_hash' field she sent to Bob in her <link url='#init-online-request'>ESession Request</link> was true, then Alice SHOULD change the value of &pubKeyB; to be her copy of the public key whose HASH matches the value of &pubKeyB; that she received from Bob. Note: If she cannot find a copy of the public key then Alice MUST terminate the ESession. She MAY then request a new ESession with the 'pk_hash' field set to false.</p></li>
  450. <li><p>Return a &feature; error to Bob unless she can confirm (or has previously confirmed) that &pubKeyB; really is Bob's public key, for examples, via secure out-of-band communication, or through a third-party authority (see <link url='#sec-keys'>Verifying Keys</link>).</p></li>
  451. <li><p>Set the value of &formB; to be the <link url='#sign-normal'>Normalized</link>&#160;<em>content</em> of the form she received from Bob without any 'identity' or 'mac' fields.</p></li>
  452. <li><p>Concatenate Alice's ESession ID, Bob's ESession ID, d, &pubKeyB; and &formB;, and calculate the HMAC of the resulting byte string using HASH and the key &KSsubB;.</p>
  453. <code>&macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &formB;})</code></li>
  454. <li><p>Return a &feature; error to Bob unless she can use &pubKeyB; with the selected signature verification algorithm ("VERIFY") to confirm that &signB; is the signature of the HMAC result (see <link url='#sign'>Signature Verification</link>).</p>
  455. <code>VERIFY(&signB;, &pubKeyB;, &macB;)</code></li>
  456. </ol>
  457. </section2>
  458. <section2 topic="ESession Completion" anchor='init-online-complete'>
  459. <p>Alice MUST then prove her identity to Bob while protecting it from third parties. She MUST perform the steps equivalent to those Bob performed above (see <link url='#init-hide'>Hiding Identity</link> for a more detailed description). Alice's calculations are summarised below (pay attention to the order of &NsubB; and &NsubA; when calculating &macA;). Note: &formA; is the <link url='#sign-normal'>Normalized</link>&#160;<em>content</em> of the <link url='#init-online-request'>ESession Request</link> data form that she sent to Bob previously.</p>
  460. <code>&macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;, &formA;})</code>
  461. <code>&signA; = SIGN(&signKeyA;, &macA;)</code>
  462. <code>if (pk_hash) &pubKeyA; = HASH(&pubKeyA;)</code>
  463. <code>&IDA; = CIPHER(&KCsubA;, &CsubA;, {&pubKeyA;, &signA;})</code>
  464. <code>&MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)</code>
  465. <p>Alice MUST send the Base64 encoded values of &NsubB;, &IDA; and &MsubA; to Bob. If Alice has already confirmed Bob's identity (i.e. if Bob included 'identity' and 'mac' fields in his response), then she MAY also send encrypted content (see <link url='#exchange'>Exchanging Stanzas</link>) in the same stanza as the proof of her identity.</p>
  466. <example caption='Alice Sends Bob Her Identity'><![CDATA[
  467. <message from='alice@example.org/pda' to='bob@example.com/laptop'>
  468. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  469. <x type='result' xmlns='jabber:x:data'>
  470. <field var="FORM_TYPE"><value>http://jabber.org/protocol/chatneg</value></field>
  471. <field var="nonce"><value> ** Base64 encoded ESession ID ** </value></field>
  472. <field var="identity"><value> ** Encrypted identity ** </value></field>
  473. <field var="mac"><value> ** Integrity of identity ** </value></field>
  474. </x>
  475. </feature>
  476. <encrypted xmlns='http://jabber.org/protocol/esession'>
  477. <data> ** Base64 encoded m_final ** </data>
  478. <mac> ** Base64 encoded a_mac ** </mac>
  479. </encrypted>
  480. </message>
  481. ]]></example>
  482. <p>If Alice also includes a 'terminate' field with its value set to "1" or "true" (see <link url='#terminate'>ESession Termination</link>) within the form then the ESession is terminated immediately. Note: This special case, where a single stanza is encrypted and sent in isolation, is equivalent to object encryption (or object signing if no encryption is specified) and offers several significant advantages over non-session approaches - including perfect forward secrecy.</p>
  483. <p>After receiving Alice's identity Bob MUST verify it by performing steps equivalent to those described in the section <link url='#init-online-bobid'>Verifying Bob's Identity</link> above. Some of Bob's calculations are summarised below (pay attention to the order of &NsubB; and &NsubA; when calculating &macA;). Note: &formA; is the <link url='#sign-normal'>Normalized</link>&#160;<em>content</em> of the <link url='#init-online-request'>ESession Request</link> data form (the <em>first</em> form) that Alice sent him. Note: If Bob sends an error to Alice then he SHOULD ignore any encrypted content he received in the stanza.</p>
  484. <code>&MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)</code>
  485. <code>{&pubKeyA;, &signA;} = DECIPHER(&KCsubA;, &CsubA;, &IDA;)</code>
  486. <code>&macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;, &formA;})</code>
  487. <code>VERIFY(&signA;, &pubKeyA;, &macA;)</code>
  488. <p>If Alice has already confirmed Bob's identity (i.e. if Bob included 'identity' and 'mac' fields in his response above), then the ESession negotiation is complete.</p>
  489. <p>Otherwise, one more step is necessary. Bob MUST send Alice the Base64 encoded values of &NsubA;, &IDB; and &MsubB; that he calculated previously (see <link url='#init-hide'>Hiding Identity</link>). Note: He MAY also send encrypted content (see <link url='#exchange'>Exchanging Stanzas</link>) in the same stanza.</p>
  490. <example caption='Bob Sends Alice His Identity'><![CDATA[
  491. <message from='bob@example.com/laptop' to='alice@example.org/pda'>
  492. <init xmlns='http://jabber.org/protocol/esession#init'>
  493. <x type='result' xmlns='jabber:x:data'>
  494. <field var="FORM_TYPE"><value>http://jabber.org/protocol/chatneg</value></field>
  495. <field var="nonce"><value> ** Base64 encoded ESession ID ** </value></field>
  496. <field var="identity"><value> ** Encrypted identity ** </value></field>
  497. <field var="mac"><value> ** Integrity of identity ** </value></field>
  498. </x>
  499. </init>
  500. </message>
  501. ]]></example>
  502. <p>After receiving Bob's identity Alice MUST verify it by performing steps described in the section <link url='#init-online-bobid'>Verifying Bob's Identity</link> above. Note: If Alice sends an error to Bob then she SHOULD ignore any encrypted content she received in the stanza.</p>
  503. </section2>
  504. </section1>
  505. <section1 topic="Exchanging Stanzas" anchor='exchange'>
  506. <section2 topic="Encryptable Content" anchor='exchange-separate'>
  507. <p>Once ESession negotiation is complete, Alice and Bob MUST exchange only encrypted forms of the one-to-one stanza types they agreed upon (e.g., &MESSAGE; and &IQ; stanzas).</p>
  508. <p>Either Alice or Bob MAY send encrypted stanzas. Here we describe the process where Alice sends Bob an encrypted stanza. She MUST only encrypt the XML content that would normally be ignored by the intermediate servers. She MUST NOT encrypt stanza wrapper elements or <cite>Advanced Message Processing</cite> elements.</p>
  509. <example caption='Unencrypted Stanza'><![CDATA[
  510. <message from='alice@example.org/pda'
  511. to='bob@example.com/laptop'
  512. type='chat'>
  513. <body>Hello, Bob!</body>
  514. <amp xmlns='http://jabber.org/protocol/amp'>
  515. <rule action='error' condition='match-resource' value='exact'/>
  516. </amp>
  517. <active xmlns='http://jabber.org/protocol/chatstates'/>
  518. </message>
  519. ]]></example>
  520. <example caption='XML Content to be Encrypted'><![CDATA[
  521. <body>Hello, Bob!</body>
  522. <active xmlns='http://jabber.org/protocol/chatstates'/>
  523. ]]></example>
  524. </section2>
  525. <section2 topic="Encryption" anchor='exchange-encrypt'>
  526. <p>Alice MUST perform the following steps to encrypt the XML content. Note: if there is no XML content to be encrypted (e.g. if this is an empty <link url='#rekey'>Re-Keying</link> stanza), then &CsubA; MUST be incremented by 1 (see below), and only the last two steps (normalization and MAC calculation) should be performed.</p>
  527. <ol start='1'>
  528. <li><p>Serialize the XML content she wishes to send into an array of UTF-8 bytes, m. <note>Although counter mode encryption requires no padding, implementations MAY still disguise the length of m by appending a random number of white-space characters.</note></p></li>
  529. <li>
  530. <p>Compress m using the negotiated algorithm. If a compression algorithm other than 'none' was agreed, the compression context is typically initialized after key exchange and passed from one stanza to the next, with only a partial flush at the end of each stanza. <note>If Bob were to receive a stanza out-of-order, then he would fail to decrypt the stanza and be forced to terminate the ESession.</note></p>
  531. <code>m_compressed = compress(m)</code>
  532. </li>
  533. <li>
  534. <p>Encrypt the data with the agreed algorithm in counter mode, using the encryption key &KCsubA;. Note: &CsubA; MUST be incremented by 1 for each encrypted block or partial block (i.e. &CsubA; = (&CsubA; + 1) mod 2<span class='super'>n</span>, where n is the number of bits per cipher block for the agreed block cipher algorithm). Note: if the block cipher algorithm 'none' was agreed (see <link url='#sec-unencrypted'>Unencrypted ESessions</link>) then encryption MUST NOT be performed and &CsubA; MUST be incremented by 1 (for replay protection).</p>
  535. <code>m_final = encrypt(&KCsubA;, &CsubA;, m_compressed)</code>
  536. </li>
  537. <li>
  538. <p>Alice MUST now create the <link url='#sign-normal'>Normalized</link> XML <em>content</em> of the &lt;encrypted/&gt; XML element. If there is encrypted XML content, the XML MUST include the Base64 encoded value of m_final wrapped in a &lt;data/&gt; element. Note: the &lt;encrypted/&gt; element MAY also contain one &lt;key/&gt; element and one or more &lt;old/&gt; elements (see <link url='#rekey'>Re-Keying</link>).</p>
  539. <code>m_content = '&lt;data&gt; ** Base64 encoded m_final ** &lt;/data&gt;'</code>
  540. </li>
  541. <li>
  542. <p>The XML content and the value of Alice's block cipher counter &CsubA; <em>before</em> the data was encrypted, are now processed through the HMAC algorithm, along with the agreed hash algorithm ("HASH") and the integrity key &KMsubA;.</p>
  543. <code>a_mac = <em>HMAC</em>(HASH, &KMsubA;, m_content, &CsubA;)</code>
  544. </li>
  545. </ol>
  546. </section2>
  547. <section2 topic="Sending an Encrypted Stanza" anchor='exchange-send'>
  548. <p>Before sending the stanza to Bob, Alice MUST wrap m_content and the Base64 encoded value of a_mac (wrapped in a &lt;mac/&gt; element) inside an &lt;encrypted/&gt; element and insert it into the stanza in place of the original content. There MUST NOT be more than one &lt;encrypted/&gt; element per stanza.</p>
  549. <example caption='Message Stanza with Encrypted Content'><![CDATA[
  550. <message from='alice@example.org/pda'
  551. to='bob@example.com/laptop'
  552. type='chat'>
  553. <encrypted xmlns='http://jabber.org/protocol/esession'>
  554. <data> ** Base64 encoded m_final ** </data>
  555. <mac> ** Base64 encoded a_mac ** </mac>
  556. </encrypted>
  557. <amp xmlns='http://jabber.org/protocol/amp' per-hop='true'>
  558. <rule action='error' condition='match-resource' value='exact'/>
  559. </amp>
  560. </message>
  561. ]]></example>
  562. </section2>
  563. <section2 topic="Decryption" anchor='exchange-decrypt'>
  564. <p>When Bob receives the stanza from Alice, he extracts and Base64 decodes the values of m_final and a_mac from the content and performs the following steps.</p>
  565. <ol start='1'>
  566. <li>
  567. <p>Remove the &lt;mac/&gt; element from the &lt;encrypted/&gt; element and <link url='#sign-normal'>Normalize</link> the remaining XML <em>content</em>. Calculate the Message Authentication Code (MAC) for the content.</p>
  568. <code>b_mac = <em>HMAC</em>(HASH, &KMsubA;, m_content, &CsubA;)</code>
  569. </li>
  570. <li>
  571. <p>Verify that b_mac and a_mac match. If they are not identical, the content has been tampered with and Bob MUST terminate the ESession, he MAY send a &notacceptable; error to Alice. <note>If Bob were to receive a stanza out-of-order, then the MACs would not match because the values of &CsubA; would not be synchronized.</note></p>
  572. </li>
  573. <li>
  574. <p>Decrypt m_final using the agreed algorithm, &KCsubA; and &CsubA;. Note: &CsubA; MUST be incremented by 1 for each decrypted block (see <link url='#exchange-encrypt'>Encryption</link>). Note: if the block cipher algorithm 'none' was agreed decryption MUST NOT be performed and &CsubA; MUST be incremented by 1.</p>
  575. <code>m_compressed = decrypt(&KCsubA;, &CsubA;, m_final)</code>
  576. </li>
  577. <li>
  578. <p>Decompress m_compressed using the negotiated algorithm (usually 'none').</p>
  579. <code>m = decompress(m_compressed)</code>
  580. </li>
  581. <li>
  582. <p>Replace the &lt;encrypted/&gt; element in the serialized XML stanza with m and feed the stanza into an XML parser. If the parser returns an XML format error then Bob MUST terminate the ESession, he MAY send a &notacceptable; error to Alice. <note>Bob MUST NOT send a stream error to his server since intermediate entities are not responsible for encoded content.</note></p>
  583. </li>
  584. </ol>
  585. </section2>
  586. </section1>
  587. <section1 topic='Re-Key Exchange' anchor='rekey'>
  588. <p>Once an attacker has discovered an encryption key it could be used to decrypt all stanzas within a session, including stanzas that were intercepted <em>before</em> the key was discovered. To reduce the window of vulnerability, both Alice and Bob SHOULD change their values of x and y and re-exchange the encryption key as regularly as possible. They MUST also destroy all copies of keys as soon as they are no longer needed.</p>
  589. <p>Note: Although most entities are capable of re-keying after each stanza, clients running in constrained runtime environments may require a few seconds to re-key. During ESession negotiation these clients MAY negotiate the minimum number of stanzas to be exchanged between re-keys at the cost of a larger window of vulnerability. Entities MUST NOT initiate key re-exchanges more frequently than the agreed limit.</p>
  590. <section2 topic='Re-Key Initiation' anchor='rekey-init'>
  591. <p>Either Alice or Bob MAY initiate a key re-exchange. Here we describe the process initiated by Alice. First she MUST calculate new values for the encryption parameters:</p>
  592. <ol start='1'>
  593. <li><p>Generate a secret random number x (where &twosup2n; &lt; x &lt; p - 1, where n is the number of bits per cipher block for the agreed block cipher algorithm)</p></li>
  594. <li><p>Calculate e = &gsupx; mod p</p></li>
  595. <li><p>Calculate K = &dsupx; mod p (the new shared secret)</p></li>
  596. <li><p>Calculate &KCsubA;, &KMsubA;, &KCsubB;, &KMsubB; from K (see <link url='#init-keys'>Generating Session Keys</link>)</p></li>
  597. </ol>
  598. <p>To avoid extra stanzas, the new value of e SHOULD be sent to Bob along with an encrypted stanza. Note: Alice MUST NOT use the new &KCsubA; and &KMsubA; to encrypt this stanza or to calculate the MAC. However, she MUST use them when sending subsequent stanzas.</p>
  599. <p>Note: There is no need for Alice to provide a signature because the calculation of the MAC includes the new value of e, see <link url='#exchange'>Exchanging Stanzas</link>).</p>
  600. <example caption='Alice Sends Re-Key Stanza'><![CDATA[
  601. <message from='alice@example.org/pda' to='bob@example.com/laptop'>
  602. <encrypted xmlns='http://jabber.org/protocol/esession'>
  603. <data> ** Base64 encoded m_final ** </data>
  604. <key> ** Base64 encoded value of new e ** </key>
  605. <mac> ** Base64 encoded a_mac ** </mac>
  606. </encrypted>
  607. </message>
  608. ]]></example>
  609. <p>Note: Bob may not receive the new key before he sends his next stanzas (they may cross in transit). So, before destroying her old values of &KCsubB; and &KMsubB;, Alice MUST wait until either she receives a stanza encrypted with the new key, or a reasonable time has passed (60 seconds should cover a network round-trip and calculations by a constrained client). Similarly she MUST wait before destroying her old value of x, in case Bob sends two stanzas before receiving Alice's new key (the first stanza might include a re-key).</p>
  610. </section2>
  611. <section2 topic='Re-Key Acceptance' anchor='rekey-accept'>
  612. <p>After Bob has received a stanza with a new value of e, has confirmed it is greater than one, and has decrypted the stanza with the old value of &KCsubA;, he MUST securely destroy all copies of &KCsubA; and &KCsubB; and perform the following calculations with the new value of e:</p>
  613. <ol start='1'>
  614. <li><p>Calculate K = &esupy; mod p</p></li>
  615. <li><p>Calculate &KCsubA;, &KMsubA;, &KCsubB;, &KMsubB; from K (see <link url='#init-keys'>Generating Session Keys</link>)</p></li>
  616. </ol>
  617. <p>He MUST use these new values to encrypt and decrypt all subsequent stanzas. <note>If an entity fails to receive any stanza that includes a new key in the correct order, then it will fail to decrypt the next stanza it receives and be forced to terminate the ESession.</note></p>
  618. <p>The next time Bob sends Alice a stanza he MUST specify the number of rekeys he has received from her since he sent her his last stanza. He does that by setting the 'rekeys' attribute of the &lt;data/&gt; element. Note: The default value of the 'rekeys' attribute is zero.</p>
  619. <example caption="Bob's First Stanza After Receiving a Re-Key"><![CDATA[
  620. <message from='bob@example.com/laptop' to='alice@example.org/pda'>
  621. <encrypted xmlns='http://jabber.org/protocol/esession'>
  622. <data rekeys='1'> ** Base64 encoded m_final ** </data>
  623. <mac> ** Base64 encoded b_mac ** </mac>
  624. </encrypted>
  625. </message>
  626. ]]></example>
  627. <p>When Alice receives the stanza from Bob she MUST use the 'rekeys' attribute to decide which of her values of &KCsubB; and &KMsubB; (or x) she should use to decrypt the stanza - otherwise she would not know if Bob received her rekey(s) before he sent the stanza. Once she is sure Bob has received her rekey(s) she MUST discard all her older values of &KCsubB;, &KMsubB; and x.</p>
  628. </section2>
  629. <section2 topic='Publishing Old MAC Values' anchor='rekey-publish'>
  630. <p>Once the expired MAC keys have been published, anyone could create valid arbitrary stanzas with them. This prevents anyone being able to prove the authenticity of a transcript of the ESession in the future.</p>
  631. <p>Either entity MAY publish old values of &KMsubA; and/or &KMsubB; within any encrypted stanza as long as it knows that all the stanzas that MAY use the old values have been received and validated. Note: A 'man-in-the-middle' could delay the delivery of stanzas indefinitely. So, before Alice publishes &KMsubA; (and &KMsubB;), she MUST wait until she has both sent a re-key to Bob and received a stanza from Bob encrypted with her new key. (She MAY also publish &KMsubB; after she has received a re-key from Bob.)</p>
  632. <example caption='Publishing Expired MAC Keys'><![CDATA[
  633. <message from='alice@example.org/pda' to='bob@example.com/laptop'>
  634. <encrypted xmlns='http://jabber.org/protocol/esession'>
  635. <data> ** Base64 encoded m_final ** </data>
  636. <old> ** Base64 encoded old MAC key ** </old>
  637. <old> ** Base64 encoded old MAC key ** </old>
  638. <mac> ** Base64 encoded a_mac ** </mac>
  639. </encrypted>
  640. </message>
  641. ]]></example>
  642. <p>Entities SHOULD ignore any &lt;old/&gt; elements they receive.</p>
  643. </section2>
  644. </section1>
  645. <section1 topic='ESession Termination' anchor='terminate'>
  646. <p>Either entity MAY terminate an ESession at any time. Entities MUST terminate all open ESessions before they go offline. To terminate an ESession Alice MUST send an encrypted stanza to Bob including within the encrypted XML of the &lt;data/&gt; element a chat negotiation form with a "terminate" field (as specified in the Termination section of <cite>Chat Session Negotiation</cite>). Note: She MAY publish old values of &KMsubA; and/or &KMsubB; within her termination stanza as long as she is sure all the stanzas that MAY use the old values have been received and validated (see <link url='#rekey-publish'>Publishing Old MAC Values</link>). She MUST then securely destroy all keys associated with the ESession.</p>
  647. <example caption='Alice Terminates an ESession'><![CDATA[
  648. <message from='alice@example.org/pda' to='bob@example.com/laptop'>
  649. <encrypted xmlns='http://jabber.org/protocol/esession'>
  650. <data> ** Base64 encoded encrypted terminate form ** </data>
  651. <old> ** Base64 encoded old MAC key ** </old>
  652. <mac> ** Base64 encoded a_mac ** </mac>
  653. </encrypted>
  654. </message>
  655. ]]></example>
  656. <p>When Bob receives a termination stanza he MUST verify the MAC (to be sure he received all the stanzas Alice sent him during the ESession) and immediately send an encrypted termination acknowledgement form (as specified in the Termination section of <cite>Chat Session Negotiation</cite>) back to Alice. Note: He MAY publish <em>any</em> old values of &KMsubA; or &KMsubB; within the acknowledgement stanza. He MUST then securely destroy all keys associated with the ESession.</p>
  657. <example caption='Bob Acknowledges ESession Termination'><![CDATA[
  658. <message from='bob@example.com/laptop' to='alice@example.org/pda'>
  659. <encrypted xmlns='http://jabber.org/protocol/esession'>
  660. <data> ** Base64 encoded encrypted acknowledgement form ** </data>
  661. <old> ** Base64 encoded old MAC key ** </old>
  662. <mac> ** Base64 encoded b_mac ** </mac>
  663. </encrypted>
  664. </message>
  665. ]]></example>
  666. <p>When Alice receives the stanza she MUST verify the MAC to be sure she received all the stanzas Bob sent her during the ESession. Once an entity has sent a termination or termination acknowledgement stanza it MUST NOT send another stanza within the ESession.</p>
  667. </section1>
  668. <section1 topic='Signature Generation and Verification' anchor='sign'>
  669. <section2 topic='XML Normalization' anchor='sign-normal'>
  670. <p>Before the signature or MAC of a block of XML is generated or verified, all character data <em>between</em> all elements MUST be removed and the XML MUST be converted to canonical form (see &w3canon;).</p>
  671. <p>All the XML this protocol requires to be signed or MACed is very simple, so in this case, canonicalization SHOULD only require the following changes:</p>
  672. <ul>
  673. <li>Set attribute value delimiters to quotation marks (i.e. simply replace all single quotes in the serialized XML with double quotes)</li>
  674. <li>Impose lexicographic order on the attributes of "field" elements (i.e. ensure "type" is before "var")</li>
  675. </ul>
  676. <p>Implementations MAY conceivably also need to make the following changes. Note: Empty elements and special characters SHOULD NOT appear in the signed or MACed XML specified in this protocol.</p>
  677. <ul>
  678. <li>Ensure there are no character references</li>
  679. <li>Convert empty elements to start-end tag pairs</li>
  680. <li>Ensure there is no whitespace except for single spaces before attributes</li>
  681. </ul>
  682. </section2>
  683. <section2 topic='Hash' anchor='sign-hash'>
  684. <p>Before the signature or MAC of a block of XML is generated or verified, the agreed hash algorithm MUST be used to generate the hash of the normalized XML.</p>
  685. <code>m_hash = HASH(m_content)</code>
  686. </section2>
  687. <section2 topic='Generation' anchor='sign-calc'>
  688. <p>The signature generation depends on the type of private key being used.</p>
  689. <section3 topic='RSA' anchor='sign-rsa-gen'>
  690. <code>signature_rsa = rsa_sign(rsa_private_key, m_hash, hashOID)</code>
  691. <p>The multiprecision integer signature_rsa is the signature (see &rfc3447;).</p>
  692. </section3>
  693. <section3 topic='DSA' anchor='sign-dsa-gen'>
  694. <code>sig_dsa_r, sig_dsa_s = dsa_sign(dsa_private_key, m_hash)</code>
  695. <p>The multiprecision integers sig_dsa_r and sig_dsa_s are the signature (see &nistfips186-2;).</p>
  696. </section3>
  697. </section2>
  698. <section2 topic='Signature Format' anchor='sign-format'>
  699. <p>The signature formats are the same for all public key formats. All integers are stored in big-endian byte order.</p>
  700. <section3 topic='RSA' anchor='sign-rsa-format'>
  701. <p>Base64 encoding of the signature_rsa multiprecision integer (without any header or length prefix).</p>
  702. </section3>
  703. <section3 topic='DSA' anchor='sign-dsa-format'>
  704. <p>Base64 encoding of the following structure:</p>
  705. <ul>
  706. <li>number of bytes in sig_dsa_r (2-byte integer)</li>
  707. <li>sig_dsa_r</li>
  708. <li>number of bytes in sig_dsa_s (2-byte integer)</li>
  709. <li>sig_dsa_s</li>
  710. </ul>
  711. </section3>
  712. </section2>
  713. <section2 topic='Verification' anchor='sign-calc'>
  714. <p>The signature verification depends on the type of public key being used.</p>
  715. <section3 topic='RSA' anchor='sign-rsa-verify'>
  716. <p>The rsa_modulus and rsa_public_exponent multiprecision integers are extracted from the other entity's authenticated public key. The signature_rsa multiprecision integer is the signature received from the other entity.</p>
  717. <code>boolean = rsa_verify(signature_rsa, m_hash, hashOID, rsa_modulus, rsa_public_exponent)</code>
  718. </section3>
  719. <section3 topic='DSA' anchor='sign-dsa-verify'>
  720. <p>The dsa_p, dsa_q, dsa_g and dsa_y multiprecision integers are extracted from the other entity's authenticated public key. The sig_dsa_r and sig_dsa_s multiprecision integers are the signature received from the other entity.</p>
  721. <code>boolean = dsa_verify(sig_dsa_r, sig_dsa_s, m_hash, dsa_p, dsa_q, dsa_g, dsa_y)</code>
  722. </section3>
  723. </section2>
  724. </section1>
  725. <section1 topic='Security Considerations' anchor='sec'>
  726. <section2 topic='Random Numbers' anchor='sec-prng'>
  727. <p>Weak pseudo-random number generators (PRNG) enable successful attacks. Implementors MUST use a cryptographically strong PRNG to generate all random numbers (see &rfc1750;).</p>
  728. </section2>
  729. <section2 topic='Re-Keying Limits' anchor='sec-rekey'>
  730. <p>After a key exchange an entity MUST NOT exchange a total of &twosup32; encrypted blocks before it initiates a key re-exchange (see &rfc4344;). Note: This limitation also ensures the same key and counter values are never used to encrypt two different blocks using counter mode (thus preventing simple attacks).</p>
  731. <p>In order to reduce the Perfect Forward Secrecy window of vulnerability, after an extended period of activity, entities SHOULD either re-key or terminate the ESession.</p>
  732. </section2>
  733. <section2 topic='Verifying Keys' anchor='sec-keys'>
  734. <p>The trust system outlined in this document is based on Alice trusting that the public key presented by Bob is <em>actually</em> Bob's key (and vice versa). Determining this trust may be done in a variety of ways depending on the entities' support for different public key (certificate) formats, signing algorithms and signing authorities. For instance, if Bob publishes a PGP/GPG public key, Alice MAY verify that his key is signed by another key that she knows to be good. Or, if Bob provides an X.509 certificate, she MAY check that his key has been signed by a Certificate Authority that she trusts.</p>
  735. <p>When trust cannot be achieved automatically, methods that are not transparent to the users may be employed. For example, Bob could communicate the SHA-256 fingerprint of his public key to Alice via secure out-of-band communication (e.g. face-to-face). This would enable Alice to confirm that the public key she receives in-band is valid. Note however that very few people bother to verify fingerprints in this way. So this method is exceptionally vulnerable to 'man-in-the-middle' attacks. In order to reduce the window of vulnerability, an entity SHOULD remember the fingerprints of all user-validated public keys and alert the user in the future if ever the fingerprint(s) it stored for an entity do not match any of the received public keys.</p>
  736. <p>Alternatively Alice and Bob could agree a shared secret via secure out-of-band communication, Bob could then use it to create an HMAC of his public key that only Alice could verify.</p>
  737. <p>Note: If no keys are acceptable to Alice (because Alice has never verified any of the keys, and because either the keys are not signed, or Alice does not support the signature algorithms of the keys, or she cannot parse the certificate formats, or she does not recognise the authorities that signed the keys) then, although the ESession can still be encrypted, she cannot be sure she is communicating with Bob.</p>
  738. </section2>
  739. <section2 topic='Replay Attacks' anchor='sec-replay'>
  740. <p>The block cipher counters maintained implicitly by Alice and Bob (&CsubA; and &CsubB;) prevent stanzas being replayed within any ESession. They ensure that the MAC will be different for all stanzas, even if the HMAC key and the content of the stanza are identical.</p>
  741. <p>Alice and Bob MUST ensure that the value of e or d they provide when negotiating each online ESession is unique. This prevents complete online ESessions being replayed.</p>
  742. </section2>
  743. <section2 topic='Unencrypted ESessions' anchor='sec-unencrypted'>
  744. <p>Organisations with full disclosure policies may require entities to disable encryption to enable the logging of all messages on their server. Unencrypted ESessions meet all the <link url='#reqs-sec'>Security Requirements</link> except for Confidentiality. Unencrypted ESessions enable Alice to to confirm <em>securely</em> with Bob that both client-server connections are secure. i.e. that the value of the 'secure' option (as specified in <cite>Chat Session Negotiation</cite>) has not been tampered with.</p>
  745. </section2>
  746. <section2 topic='Storage' anchor='sec-storage'>
  747. <p>If either entity stores a (re-encrypted) transcript of an ESession for future consultation then the Perfect Forward Secrecy offered by this protocol is lost. If the negotiated value of the 'otr' <cite>Chat Session Negotiation</cite> field is 'true' the entities SHOULD NOT store any part of the ESession content (not even in encrypted form).</p>
  748. </section2>
  749. <section2 topic='Extra Responsabilities of Implementors' anchor='sec-general'>
  750. <p>Cryptography plays only a small part in an entity's security. Even if it implements this protocol perfectly it may still be vulnerable to other attacks. For examples, an implementation might store ESession keys on swap space or save private keys to a file in cleartext! Implementors MUST take very great care when developing applications with secure technologies.</p>
  751. </section2>
  752. <section2 topic='Mandatory to Implement Technologies' anchor='sec-mandatory'>
  753. <p>An implementation of ESession MUST support the Diffie-Hellman Key Agreement and HMAC algorithms. Note: The parameter names mentioned below are related to secure shell; see <cite>SSH Transport Layer Encryption Modes</cite> for block cipher algorithm details; see the &ianassh; for other names.</p>
  754. <section3 topic='Block Cipher Algorithms' anchor='sec-mandatory-encryption'>
  755. <p>An implementation of ESession MUST support at least the following block cipher algorithm:</p>
  756. <ul>
  757. <li>aes128-ctr (see &nistfips197;)</li>
  758. </ul>
  759. <p>The block length of an block cipher algorithm's cipher SHOULD be at least 128 bits. An implementation of ESession MAY also support the following block cipher algorithms:</p>
  760. <ul>
  761. <li>aes256-ctr</li>
  762. <li>aes192-ctr</li>
  763. <li>twofish256-ctr (see &twofish;)</li>
  764. <li>twofish192-ctr</li>
  765. <li>twofish128-ctr</li>
  766. <li>serpent256-ctr (see &serpent;)</li>
  767. <li>serpent192-ctr</li>
  768. <li>serpent128-ctr</li>
  769. <li>none (no encryption, only signing)</li>
  770. </ul>
  771. </section3>
  772. <section3 topic='Key Signing Algorithms' anchor='sec-mandatory-sign'>
  773. <p>An implementation of ESession MUST support at least the following signing algorithm:</p>
  774. <ul>
  775. <li>rsa (see <cite>RFC 3447</cite>)</li>
  776. </ul>
  777. <p>An implementation of ESession SHOULD also support at least the following signing algorithm:</p>
  778. <ul>
  779. <li>dsa (see <cite>Digital Signature Standard</cite>)</li>
  780. </ul>
  781. </section3>
  782. <section3 topic='Public Signature-Verification-Key Formats' anchor='sec-mandatory-public'>
  783. <p>An implementation of ESession MUST support the following public key formats:</p>
  784. <ul>
  785. <li>ssh-rsa</li>
  786. </ul>
  787. <p>An implementation of ESession SHOULD also support at least the following public key formats:</p>
  788. <ul>
  789. <li>ssh-dss</li>
  790. <li>x509v3-sign-rsa (see &sshx509;)</li>
  791. <li>x509v3-sign-dss</li>
  792. <li>pgp-sign-rsa</li>
  793. <li>pgp-sign-dss</li>
  794. </ul>
  795. <p>An implementation of ESession MAY also support the following public key formats:</p>
  796. <ul>
  797. <li>spki-sign-rsa</li>
  798. <li>spki-sign-dss</li>
  799. </ul>
  800. </section3>
  801. <section3 topic='Hash Algorithms' anchor='sec-mandatory-hash'>
  802. <p>An implementation of ESession MUST support the following hash algorithm:</p>
  803. <ul>
  804. <li>sha256 (see &nistfips180-2;)</li>
  805. </ul>
  806. <p>An implementation of ESession SHOULD also support at least the following hash algorithm (sha1 and md5 are NOT RECOMMENDED):</p>
  807. <ul>
  808. <li>whirlpool (see &whirlpool;)</li>
  809. </ul>
  810. </section3>
  811. <section3 topic='Compression Algorithms' anchor='sec-mandatory-compress'>
  812. <p>An implementation of ESession MUST support the following compression algorithm:</p>
  813. <ul>
  814. <li>none (no compression, the output MUST be the same as the input)</li>
  815. </ul>
  816. <p>Support for other algorithms is NOT RECOMMENDED since compression partially defeats the <link url='#reqs-repudiate'>Repudiability</link> requirement of this document by making it more difficult for a third party (with some knowledge of the plaintext) to modify a transcript of an encrypted session in a meaningful way. However, encrypted content is pseudo-random and cannot be compressed, so, in those cases where bandwidth is severely constrained, an implementation of ESession MAY support the following algorithms to compress content before it is encrypted:</p>
  817. <ul>
  818. <li>lzw (see &ecma151;)</li>
  819. <li>zlib (see &rfc1950;)</li>
  820. </ul>
  821. </section3>
  822. </section2>
  823. </section1>
  824. <section1 topic='IANA Considerations' anchor='iana'>
  825. <p>This document requires no interaction with &IANA;. </p>
  826. </section1>
  827. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  828. <section2 topic='Namespaces' anchor='registrar-ns'>
  829. <p>Upon approval of this document, the &REGISTRAR; shall register the following namespaces:</p>
  830. <ul>
  831. <li>http://jabber.org/protocol/esession</li>
  832. <li>http://jabber.org/protocol/esession#init</li>
  833. <li>http://jabber.org/protocol/esession#error</li>
  834. </ul>
  835. </section2>
  836. <section2 topic='Field Standardization' anchor='registrar-formtype'>
  837. <p>&xep0068; defines a process for standardizing the fields used within Data Forms qualified by a particular namespace. The following fields shall be registered for use in <em>both</em> Encrypted Sessions and Chat Session Negotiation:</p>
  838. <code caption='Registry Submission'><![CDATA[
  839. <form_type>
  840. <name>http://jabber.org/protocol/esession</name>
  841. <jep>XEP-0116</jep>
  842. <desc>ESession negotiation forms</desc>
  843. <field
  844. var='match_resource'
  845. type='text-single'
  846. label='Target resource for offline ESessions'/>
  847. <field
  848. var='modp'
  849. type='list-single'
  850. label='MODP group number'/>
  851. <field
  852. var='crypt_algs'
  853. type='list-single'
  854. label='Symmetric block cipher options'/>
  855. <field
  856. var='hash_algs'
  857. type='list-single'
  858. label='Hash algorithm options'/>
  859. <field
  860. var='sign_algs'
  861. type='list-single'
  862. label='Signature algorithm options'/>
  863. <field
  864. var='compress'
  865. type='list-single'
  866. label='Compression algorithm options'/>
  867. <field
  868. var='stanzas'
  869. type='list-multi'
  870. label='Stanzas types to encrypt'/>
  871. <field
  872. var='pk_hash'
  873. type='boolean'
  874. label='Respond with public key fingerprint'/>
  875. <field
  876. var='ver'
  877. type='list-single'
  878. label='Supported versions of XEP-0116'/>
  879. <field
  880. var='rekey_freq'
  881. type='text-single'
  882. label='Minimum number of stanzas between key exchanges'/>
  883. <field
  884. var='keys'
  885. type='hidden'
  886. label='Diffie-Hellman keys'/>
  887. <field
  888. var='my_nonce'
  889. type='hidden'
  890. label='ESession ID of Sender'/>
  891. <field
  892. var='expires'
  893. type='hidden'
  894. label='Expiry time of offline ESession options'/>
  895. <field
  896. var='nonce'
  897. type='hidden'
  898. label='ESession ID of Receiver'/>
  899. <field
  900. var='counter'
  901. type='hidden'
  902. label='Initial block counter'/>
  903. <field
  904. var='signs'
  905. type='list-single'
  906. label='Data form signatures'/>
  907. </form_type>
  908. <form_type>
  909. <name>http://jabber.org/protocol/chatneg</name>
  910. <jep>XEP-0155</jep>
  911. ...
  912. </form_type>
  913. ]]></code>
  914. </section2>
  915. </section1>
  916. <section1 topic='XML Schemas' anchor='schema'>
  917. <code><![CDATA[
  918. <?xml version='1.0' encoding='UTF-8'?>
  919. <xs:schema
  920. xmlns:xs='http://www.w3.org/2001/XMLSchema'
  921. targetNamespace='http://jabber.org/protocol/esession'
  922. xmlns='http://jabber.org/protocol/esession'
  923. elementFormDefault='qualified'>
  924. <xs:element name='data'>
  925. <xs:complexType>
  926. <xs:simpleContent>
  927. <xs:extension base='xs:string'>
  928. <xs:attribute name='rekeys' type='xs:nonNegativeInteger' use='optional'/>
  929. </xs:extension>
  930. </xs:simpleContent>
  931. </xs:complexType>
  932. </xs:element>
  933. <xs:element name='encrypted'>
  934. <xs:complexType>
  935. <xs:sequence>
  936. <xs:element ref='data' minOccurs='0' maxOccurs='1'/>
  937. <xs:element ref='key' minOccurs='0' maxOccurs='1'/>
  938. <xs:element ref='mac' minOccurs='0' maxOccurs='1'/>
  939. <xs:element ref='old' minOccurs='0' maxOccurs='unbounded'/>
  940. </xs:sequence>
  941. </xs:complexType>
  942. </xs:element>
  943. <xs:element name='key' type='xs:string'/>
  944. <xs:element name='mac' type='xs:string'/>
  945. <xs:element name='old' type='xs:string'/>
  946. </xs:schema>
  947. ]]></code>
  948. </section1>
  949. <section1 topic='Open Issues' anchor='open'>
  950. <section2 topic='To Think About' anchor='open-tothink'>
  951. <ol>
  952. <li>Standardise on the X.509 public key and signature formats?</li>
  953. <li>What challenges exist to make the OTR Gaim Plugin use this protocol natively when talking to Jabber entities? Can these be mitigated by 'non-critical' protocol changes?</li>
  954. <li>Would anything in this protocol (e.g., its dependency on in-order stanza delivery) prevent an XMPP entity using it to exchange encrypted messages and presence with a user of a non-XMPP messaging system, assuming that the gateway both supports this protocol and is compatible with a purpose-built security plugin on the other user's client (e.g. a Gaim plugin connects to the gateway via a non-XMPP network)?</li>
  955. <li>Could use &xep0013; (FOMR) instead of AMP to prevent any offline ESessions Bob can't decrypt being delivered to him. (Each &lt;item/&gt; that corresponds to an ESession message would have to contain a &lt;ESessionID/&gt; child, to allow Bob to discover which of his stored values of y was used to encrypt the message.)</li>
  956. </ol>
  957. </section2>
  958. <section2 topic='To Do' anchor='open-todo'>
  959. <ol>
  960. <li>Ask the authors of AMP to explain how to achieve the match_resource functionality specified in XEP-0187.</li>
  961. <li>Define names for X.509 SubjectPublicKeyInfo public key formats (different to X.509 certificates). This format must be used when keys are distributed within session negotiation.</li>
  962. <li>Add non-repudiable signing option</li>
  963. <li>Perhaps the document needs to specify more carefully how block counters are handled between messages, especially in the event of partial blocks?</li>
  964. <li>Give examples of specific errors and discuss error scenarios throughout document (e.g., what should Bob do if he is not offline and he receives an offline key exchange stanza?).</li>
  965. <li>Define an <em>optional</em> protocol that would allow Alice to store values of &NsubA; and x (and the PKIDs she trusts) 'securely' on her own server (before she goes offline).</li>
  966. </ol>
  967. </section2>
  968. </section1>
  969. </xep>