No Description
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 80KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Encrypted Session Negotiation</title>
  10. <abstract>This document specifies an XMPP protocol extension for negotiating an end-to-end encrypted session.</abstract>
  11. &LEGALNOTICE;
  12. <number>0116</number>
  13. <status>Deferred</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. <spec>XMPP IM</spec>
  19. <spec>RFC 2104</spec>
  20. <spec>RFC 2409</spec>
  21. <spec>RFC 3526</spec>
  22. <spec>RFC 4648</spec>
  23. <spec>SHA256</spec>
  24. <spec>xml-c14n</spec>
  25. <spec>XEP-0004</spec>
  26. <spec>XEP-0020</spec>
  27. <spec>XEP-0030</spec>
  28. <spec>XEP-0068</spec>
  29. <spec>XEP-0115</spec>
  30. <spec>XEP-0155</spec>
  31. <spec>XEP-0200</spec>
  32. </dependencies>
  33. <supersedes/>
  34. <supersededby/>
  35. <shortname>TO BE ASSIGNED</shortname>
  36. &ianpaterson;
  37. &stpeter;
  38. &dizzyd;
  39. <revision>
  40. <version>0.16</version>
  41. <date>2007-05-30</date>
  42. <initials>ip</initials>
  43. <remark><p>Split pubkey field into init_pubkey and resp_pubkey fields; modified namespaces to reflect XMPP Registrar procedures regarding URN issuance.</p></remark>
  44. </revision>
  45. <revision>
  46. <version>0.15</version>
  47. <date>2007-03-16</date>
  48. <initials>ip</initials>
  49. <remark><p>Clarified procedure for identification of the shared retained secret</p></remark>
  50. </revision>
  51. <revision>
  52. <version>0.14</version>
  53. <date>2007-03-15</date>
  54. <initials>ip</initials>
  55. <remark><p>Clarified representation of Big Ints, incorporated whole forms into SAS calculation</p></remark>
  56. </revision>
  57. <revision>
  58. <version>0.13</version>
  59. <date>2006-11-27</date>
  60. <initials>ip</initials>
  61. <remark><p>Added optional public key independence, hash commitment, SAS authentication, retained secrets and other secrets to the 4-message key exchange; defined when 3- and 4-message negotiations should be used; added disclosure field; added Back Doors and Key Associations sections; employed HMAC instead of hash; required public keys to be in W3C xmldsig KeyValue format and signatures to be wrapped in a SignatureValue element; deleted Signature Generation and Verification section in favor of xmldsig; moved exchanging stanzas and rekeying sections to XEP-0200; changed namespace</p></remark>
  62. </revision>
  63. <revision>
  64. <version>0.12</version>
  65. <date>2006-10-05</date>
  66. <initials>ip</initials>
  67. <remark><p>Replaced secure field with security field; changed otr field to list-single</p></remark>
  68. </revision>
  69. <revision>
  70. <version>0.11</version>
  71. <date>2006-10-02</date>
  72. <initials>ip</initials>
  73. <remark><p>Harmonised session termination with the protocol added to XEP-0155; added XML schema; minor clarifications</p></remark>
  74. </revision>
  75. <revision>
  76. <version>0.10</version>
  77. <date>2006-07-18</date>
  78. <initials>ip</initials>
  79. <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>
  80. </revision>
  81. <revision>
  82. <version>0.9</version>
  83. <date>2005-11-29</date>
  84. <initials>ip</initials>
  85. <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>
  86. </revision>
  87. <revision>
  88. <version>0.8</version>
  89. <date>2005-09-27</date>
  90. <initials>ip</initials>
  91. <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>
  92. </revision>
  93. <revision>
  94. <version>0.7</version>
  95. <date>2005-08-26</date>
  96. <initials>ip</initials>
  97. <remark><p>Simplified XML normalization; added Synopsis and Efficiency requirement; defined signature formats</p></remark>
  98. </revision>
  99. <revision>
  100. <version>0.6</version>
  101. <date>2005-08-12</date>
  102. <initials>ip</initials>
  103. <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>
  104. </revision>
  105. <revision>
  106. <version>0.5</version>
  107. <date>2005-08-10</date>
  108. <initials>ip</initials>
  109. <remark><p>Added flexibility requirement; added late signature of initial request; added termination MAC.</p></remark>
  110. </revision>
  111. <revision>
  112. <version>0.4</version>
  113. <date>2005-08-09</date>
  114. <initials>ip</initials>
  115. <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>
  116. </revision>
  117. <revision>
  118. <version>0.3</version>
  119. <date>2005-08-02</date>
  120. <initials>ip/psa</initials>
  121. <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>
  122. </revision>
  123. <revision>
  124. <version>0.2</version>
  125. <date>2004-07-26</date>
  126. <initials>psa</initials>
  127. <remark><p>At the request of the author, changed status to Retracted.</p></remark>
  128. </revision>
  129. <revision>
  130. <version>0.1</version>
  131. <date>2003-09-09</date>
  132. <initials>dss/psa</initials>
  133. <remark><p>Initial version.</p></remark>
  134. </revision>
  135. </header>
  136. <section1 topic='Introduction' anchor='intro'>
  137. <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 (see &rfc3920; and &rfc3921;), 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>
  138. <p>For reasons described in &xep0210;, 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>
  139. <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>Requirements for Encrypted Sessions</cite> and &xep0188;. 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 using &xep0200;.</p>
  140. <p>&xep0217; describes a minimal subset of this protocol chosen to enable developers to produce working code before they have finished implementing the optional parts of this protocol.</p>
  141. </section1>
  142. <section1 topic="Dramatis Personae" anchor='personae'>
  143. <p>This document introduces two characters to help the reader follow the necessary exchanges:</p>
  144. <ol start='1'>
  145. <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>
  146. <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>
  147. <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>
  148. </ol>
  149. <p>While Alice and Bob are introduced as "end users", they are simply meant to be examples of XMPP entities. Any directly addressable XMPP entity may participate in an ESession.</p>
  150. </section1>
  151. <section1 topic='Discovering Support' anchor='disco'>
  152. <p>Before attempting to engage in an ESession with Bob, Alice MAY discover whether he supports this protocol, using either &xep0030; or the presence-based profile of <cite>XEP-0030</cite> specified in &xep0115;.</p>
  153. <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>
  154. <example caption='Alice Queries Bob for ESession Support via Disco'><![CDATA[
  155. <iq type='get'
  156. from='alice@example.org/pda'
  157. to='bob@example.com/laptop'
  158. id='disco1'>
  159. <query xmlns='http://jabber.org/protocol/disco#info'/>
  160. </iq>
  161. ]]></example>
  162. <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://www.xmpp.org/extensions/xep-0116.html#ns" &NSNOTE;.</p>
  163. <example caption='Bob Returns disco#info Data'><![CDATA[
  164. <iq type='result'
  165. from='bob@example.com/laptop'
  166. to='alice@example.org/pda'
  167. id='disco1'>
  168. <query xmlns='http://jabber.org/protocol/disco#info'>
  169. <identity category='client' type='pc'/>
  170. ...
  171. <feature var='http://www.xmpp.org/extensions/xep-0116.html#ns'/>
  172. ...
  173. </query>
  174. </iq>
  175. ]]></example>
  176. </section1>
  177. <section1 topic="Online ESession Negotiation" anchor='init'>
  178. <section2 topic="Introduction" anchor='init-intro'>
  179. <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>
  180. <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>
  181. <p>Note: If Alice believes Bob is offline then she SHOULD NOT use this negotiation protocol. However, she MAY use the protocol specified in &xep0187; 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>
  182. </section2>
  183. <section2 topic="Three- or Four-Message Negotiation?" anchor='init-variants'>
  184. <p>This protocol supports both 3- and 4-message key negotiations.</p>
  185. <p>The 3-message SIGMA-I-based key exchange (see <link url='http://www.xmpp.org/extensions/xep-0188.html#design-online-i'>useful summary of 3-message negotiation</link>) protects the identity of the <em>initiator</em> against active attacks. This SHOULD NOT be used to establish client-to-client sessions since the <em>responder's</em> identity is not protected against active attacks. However, it SHOULD be used to establish client-to-service (server) sessions, especially where the identity of the service is well known to third parties.</p>
  186. <p>The 4-message SIGMA-R-based key exchange (see <link url='http://www.xmpp.org/extensions/xep-0188.html#design-online-r'>useful summary of 4-message negotiation</link>) with hash commitment defends the <em>responder's</em> identity against active attacks and facilitates detection of a Man in the Middle attack. It SHOULD be used to establish client-to-client sessions. The 4-message key exchange also includes the following optional security enhancements:</p>
  187. <ul>
  188. <li><p>"Secret Retention": If retained secrets are employed <em>consistently</em> during key exchanges, then the Man in the Middle would need to be present for every session, including the first. Sessions remain secure even if a long-lived private signing key is compromised at some time <em>after</em> the first session.</p></li>
  189. <li><p>"Short-Authentication-String": Alice and Bob can use SAS once to quickly authenticate each other's public keys. Only a very short human-friendly string needs to be verified out-of-band (e.g. by recognizable voice communication).</p>
  190. <p>Alternatively, thanks to its protection against Man-in-the-Middle attacks, SAS can be used to eliminate the need to generate, distribute or authenticate any public keys. Note: When this protocol is being used without public keys Alice and Bob SHOULD employ Secret Retention, then the out-of-band verification only needs to be performed once to verify the absence of a Man in the Middle for all sessions (past, present and future). <note>This combination of techniques underpins the <cite>ZRTP</cite> key agreement protocol.</note></p></li>
  191. <li><p>"Other Secret": Alice and Bob agree a password out-of-band and their clients use it to authenticate each other every time a session is negotiated.</p></li>
  192. </ul>
  193. </section2>
  194. <section2 topic="ESession Request (Alice)" anchor='init-online-request'>
  195. <p>In addition to the "accept", "security", "logging" and "disclosure" fields (see <link url='#sec-backdoor'>Back Doors</link>) specified in <cite>Stanza Session Negotiation</cite>, Alice MUST send to Bob each of the ESession options (see list below) that she is willing to use (see <link url='#sec-mandatory'>Mandatory to Implement Technologies</link>).</p>
  196. <ol>
  197. <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 in a "modp" field (valid group numbers include 1,2,3,4,5,14,15,16,17 and 18) <note>Entities SHOULD offer even the lowest MODP groups since some entities are CPU-constrained, and security experts tend to agree that "longer keys do not protect against the most realistic security threats".</note></p></li>
  198. <li><p>Symmetric block cipher algorithm names in a "crypt_algs" field</p></li>
  199. <li><p>Hash algorithm names in a "hash_algs" field</p></li>
  200. <li><p>Compression algorithm names in a "compress" field</p></li>
  201. <li><p>Short Authentication String generation algorithm names in a "sas_algs" field</p></li>
  202. <li><p>The list of stanza types that MAY be encrypted and decrypted in a "stanzas" field (message, presence, iq)</p></li>
  203. <li><p>The different versions of this protocol that are supported in a "ver" field <note>This version of this document describes version 1.0 of this protocol.</note></p></li>
  204. <li><p>The minimum number of stanzas that MUST be exchanged before an entity MAY initiate a key re-exchange in a "rekey_freq" field (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>
  205. <li><p>The methods of identification of the other entity that would be acceptable, and the methods of identification that this entity is prepared to offer ("init_pubkey" and "resp_pubkey" parameters). The values of these two parameters MUST be either 'key' (a public signature-verification key wrapped in a &lt;KeyValue/&gt; element as specified in &w3xmlsig;), or 'hash' (a fingerprint of the public key - the result of processing the <link url='#sign-normal'>Normalized</link> &lt;KeyValue/&gt; element with the selected hash algorithm, "HASH") <note>If the entity already possesses one of the other entity's public keys then it is RECOMMENDED that the fingerprint is requested from the other entity instead of the public key - since this saves bandwidth.</note>, or 'none' (no authentication via public keys). Note: 'none' MUST NOT be specified with 3-message negotiation.</p></li>
  206. <li><p>Signature algorithm names (unless the values of the "init_pubkey" and "resp_pubkey" parameters are fixed to 'none')</p></li>
  207. </ol>
  208. <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 <em>each</em> 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>
  209. <ol>
  210. <li><p>Generate: a secret random number x (where &twosup2n; &lt; x &lt; p - 1)</p></li>
  211. <li><p>Calculate: e = &gsupx; mod p</p></li>
  212. <li><p>Calculate: He = SHA256(e) (see &nistfips180-2;)</p></li>
  213. </ol>
  214. <p>Note: The last step is not necessary for 3-message negotiations.</p>
  215. <p>Alice MUST send all her calculated values of 'He' (for 4-message negotiations) or 'e' (for 3-message negotiations) to Bob (in a "dhhashes" field in the same order as the associated MODP groups are being sent) Base64 encoded (in accordance with Section 4 of &rfc4648;). She MUST also specify a randomly generated Base64 encoded value of &NsubA; (her ESession ID in a "my_nonce" field).</p>
  216. <p>The options in each field MUST appear in Alice's order of preference.</p>
  217. <example caption='Initiates a 4-message ESession Negotiation'><![CDATA[
  218. <message from='alice@example.org/pda' to='bob@example.com'>
  219. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  220. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  221. <x type='form' xmlns='jabber:x:data'>
  222. <field type='hidden' var='FORM_TYPE'>
  223. <value>urn:xmpp:ssn</value>
  224. </field>
  225. <field type='boolean' var='accept'>
  226. <value>1</value>
  227. <required/>
  228. </field>
  229. <field type='list-single' var='logging'>
  230. <option><value>false</value></option>
  231. <option><value>true</value></option>
  232. <required/>
  233. </field>
  234. <field type='list-single' var='disclosure'>
  235. <option><value>never</value></option>
  236. <required/>
  237. </field>
  238. <field type='list-single' var='security'>
  239. <option><value>e2e</value></option>
  240. <option><value>c2s</value></option>
  241. <required/>
  242. </field>
  243. <field type='list-single' var='modp'>
  244. <option><value>5</value></option>
  245. <option><value>14</value></option>
  246. <option><value>2</value></option>
  247. <option><value>1</value></option>
  248. </field>
  249. <field type='list-single' var='crypt_algs'>
  250. <option><value>aes256-ctr</value></option>
  251. <option><value>twofish256-ctr</value></option>
  252. <option><value>aes128-ctr</value></option>
  253. </field>
  254. <field type='list-single' var='hash_algs'>
  255. <option><value>whirlpool</value></option>
  256. <option><value>sha256</value></option>
  257. </field>
  258. <field type='list-single' var='sign_algs'>
  259. <option><value>http://www.w3.org/2000/09/xmldsig#rsa-sha256</value></option>
  260. <option><value>http://www.w3.org/2000/09/xmldsig#dsa-sha256</value></option>
  261. </field>
  262. <field type='list-single' var='compress'>
  263. <option><value>none</value></option>
  264. </field>
  265. <field type='list-multi' var='stanzas'>
  266. <option><value>message</value></option>
  267. <option><value>iq</value></option>
  268. <option><value>presence</value></option>
  269. </field>
  270. <field type='list-single' var='init_pubkey'>
  271. <option><value>key</value></option>
  272. <option><value>hash</value></option>
  273. <option><value>none</value></option>
  274. </field>
  275. <field type='list-single' var='resp_pubkey'>
  276. <option><value>key</value></option>
  277. <option><value>hash</value></option>
  278. <option><value>none</value></option>
  279. </field>
  280. <field type='list-single' var='ver'>
  281. <option><value>1.3</value></option>
  282. <option><value>1.2</value></option>
  283. </field>
  284. <field type='text-single' var='rekey_freq'>
  285. <value>1</value>
  286. </field>
  287. <field type='hidden' var='my_nonce'>
  288. <value> ** Alice's Base64 encoded ESession ID ** </value>
  289. </field>
  290. <field type='list-single' var='sas_algs'>
  291. <option><value>sas28x5</value></option>
  292. </field>
  293. <field type='hidden' var='dhhashes'>
  294. <value> ** Base64 encoded value of He5 ** </value>
  295. <value> ** Base64 encoded value of He14 ** </value>
  296. <value> ** Base64 encoded value of He2 ** </value>
  297. <value> ** Base64 encoded value of He1 ** </value>
  298. </field>
  299. </x>
  300. </feature>
  301. <amp xmlns='http://jabber.org/protocol/amp' per-hop='true'>
  302. <rule action='drop' condition='deliver' value='stored'/>
  303. </amp>
  304. </message>
  305. ]]></example>
  306. <p>The first message of a 3-message negotiation is identical except there MUST be no 'sas_algs' field and a 'dhkeys' field MUST be included instead of the 'dhhashes' field:</p>
  307. <example caption='Alice Initiates a 3-message ESession Negotiation'><![CDATA[
  308. <message from='alice@example.org/pda' to='bob@example.com'>
  309. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  310. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  311. <x type='form' xmlns='jabber:x:data'>
  312. <field type='hidden' var='FORM_TYPE'>
  313. <value>urn:xmpp:ssn</value>
  314. </field>
  315. ...
  316. ...
  317. ...
  318. <field type='hidden' var='my_nonce'>
  319. <value> ** Alice's Base64 encoded ESession ID ** </value>
  320. </field>
  321. <field type='hidden' var='dhkeys'>
  322. <value> ** Base64 encoded value of e5 ** </value>
  323. <value> ** Base64 encoded value of e14 ** </value>
  324. <value> ** Base64 encoded value of e2 ** </value>
  325. </field>
  326. </x>
  327. </feature>
  328. <amp xmlns='http://jabber.org/protocol/amp' per-hop='true'>
  329. <rule action='drop' condition='deliver' value='stored'/>
  330. </amp>
  331. </message>
  332. ]]></example>
  333. </section2>
  334. <section2 topic="ESession Rejection (Bob)" anchor='init-online-reject'>
  335. <p>If Bob does not want to reveal presence to Alice for whatever reason then Bob SHOULD return no response or error.</p>
  336. <p>If Alice initiated a 3-message negotiation but Bob only supports 4-message negotiations (with Alice) then he SHOULD return a &feature; error specifying the 'dhkeys' field:</p>
  337. <example caption='Bob Informs Alice that 3-message Negotiation is Not Supported'><![CDATA[
  338. <message type='error'
  339. from='bob@example.com/laptop'
  340. to='alice@example.org/pda'>
  341. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  342. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  343. ...
  344. </feature>
  345. <error type='cancel'>
  346. <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  347. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  348. <field var='dhkeys'/>
  349. </feature>
  350. </error>
  351. </message>
  352. ]]></example>
  353. <p>If Bob supports <em>none</em> of the options for one or more ESession fields, then he SHOULD return a &notacceptable; error specifying the field(s) with unsupported options:</p>
  354. <example caption='Bob Informs Alice that Her Options are Not Supported'><![CDATA[
  355. <message type='error'
  356. from='bob@example.com/laptop'
  357. to='alice@example.org/pda'>
  358. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  359. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  360. ...
  361. </feature>
  362. <error type='cancel'>
  363. <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  364. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  365. <field var='modp'/>
  366. <field var='ver'/>
  367. </feature>
  368. </error>
  369. </message>
  370. ]]></example>
  371. <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>
  372. <p>If Bob is unwilling to start an ESession, but he <em>is</em> ready to initiate a one-to-one stanza session with Alice (see <cite>Stanza Session Negotiation</cite>), and if Alice included an option for the "security" field with the value "none" or "c2s", then Bob SHOULD accept the stanza session and terminate the ESession negotiation by specifying "none" or "c2s" for the value of the "security" field in his response.</p>
  373. <example caption='Bob Accepts Stanza Session'><![CDATA[
  374. <message from='bob@example.com/laptop' to='alice@example.org/pda'>
  375. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  376. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  377. <x type='submit' xmlns='jabber:x:data'>
  378. <field var='FORM_TYPE'>
  379. <value>urn:xmpp:ssn</value>
  380. </field>
  381. <field var='accept'><value>1</value></field>
  382. <field var='logging'><value>true</value></field>
  383. <field var='disclosure'><value>never</value></field>
  384. <field var='security'><value>c2s</value></field>
  385. </x>
  386. </feature>
  387. </message>
  388. ]]></example>
  389. </section2>
  390. <section2 topic="ESession Response (Bob)" anchor='init-response'>
  391. <section3 topic="Diffie-Hellman Preparation (Bob)" anchor='init-online-bobprep'>
  392. <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 (see &rfc3766; or <cite>RFC 3526</cite> for recommendations regarding balancing the sizes of symmetric cipher blocks and Diffie-Hellman moduli) and Alice's corresponding value of 'He' (for 4-message negotiations) or 'e' (for 3-message negotiations).</p>
  393. <p>Note: 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).</p>
  394. <p>For 3-message negotiations, Bob SHOULD return a &feature; error unless: 1 &lt; e &lt; p - 1</p>
  395. <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>
  396. <ol start='1'>
  397. <li><p>Generate a random number &NsubB; (his ESession ID)</p></li>
  398. <li><p>Generate an n-bit random number &CsubA; (the block cipher counter for stanzas sent from Alice to Bob)</p></li>
  399. <li><p>Set &CBeCAx2n1; (where &CsubB; is the block counter for stanzas sent from Bob to Alice)</p></li>
  400. <li><p>Generate a secret random number y (where &twosup2n; &lt; y &lt; p - 1)</p></li>
  401. <li><p>Calculate d = &gsupy; mod p</p></li>
  402. <li><p>Calculate K = HASH(&esupy; mod p) (the Diffie-Hellman shared secret)</p></li>
  403. </ol>
  404. <p>If this is a 4-message negotiation Bob MUST skip the last step above.</p>
  405. </section3>
  406. <section3 topic="Response Form" anchor='init-online-form'>
  407. <p>Bob SHOULD generate the form that he will send back to Alice, including his responses for all the fields Alice sent him except that he MUST NOT include a 'dhhashes' field.</p>
  408. <p>He MUST set the 'init_pubkey' field to specify what sort of identification he requires from Alice (see <link url='#init-online-request'>ESession Request</link>). He MUST set the value of the 'rekey_freq' field to be less than &twosup32; and greater than or equal to the value specified by Alice. Bob MUST place his Base64 encoded values of &NsubB; and d in the 'my_nonce' and 'dhkeys' fields. Note: Bob MUST NOT return Alice's values of &NsubA; and e in these fields.</p>
  409. <p>Bob MUST encapsulate the Base64 encoded values of &CsubA; and Alice's &NsubA; in two new 'counter' and 'nonce' fields and append them to the form.</p>
  410. <p>If this is a 4-message negotiation Bob SHOULD respond to Alice by sending her the form (&formB;) immediately - there is nothing more for him to do until he receives Alice's next message (i.e. he can skip the following sections). If this is a 3-message negotiation Bob MUST NOT send the form until he has completed the steps in the following sections.</p>
  411. <example caption='Bob Responds to Alice (4-Message Negotiation only)'><![CDATA[
  412. <message from='bob@example.com/laptop' to='alice@example.org/pda'>
  413. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  414. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  415. <x type='submit' xmlns='jabber:x:data'>
  416. <field var='FORM_TYPE'>
  417. <value>urn:xmpp:ssn</value>
  418. </field>
  419. <field var='accept'><value>1</value></field>
  420. <field var='logging'><value>true</value></field>
  421. <field var='disclosure'><value>never</value></field>
  422. <field var='security'><value>e2e</value></field>
  423. <field var='modp'><value>5</value></field>
  424. <field var='crypt_algs'><value>aes256-ctr</value></field>
  425. <field var='hash_algs'><value>sha256</value></field>
  426. <field var='sign_algs'><value>http://www.w3.org/2000/09/xmldsig#rsa-sha256</value></field>
  427. <field var='compress'><value>none</value></field>
  428. <field var='stanzas'><value>message</value></field>
  429. <field var='init_pubkey'><value>hash</value></field>
  430. <field var='resp_pubkey'><value>hash</value></field>
  431. <field var='ver'><value>1.3</value></field>
  432. <field var='rekey_freq'><value>50</value></field>
  433. <field var='my_nonce'>
  434. <value> ** Bob's Base64 encoded ESession ID ** </value>
  435. </field>
  436. <field var='sas_algs'><value>sas28x5</value></field>
  437. <field var='dhkeys'>
  438. <value> ** Base64 encoded value of d ** </value>
  439. </field>
  440. <field var='nonce'>
  441. <value> ** Alice's Base64 encoded ESession ID ** </value>
  442. </field>
  443. <field var='counter'>
  444. <value> ** Base64 encoded block counter ** </value>
  445. </field>
  446. </x>
  447. </feature>
  448. </message>
  449. ]]></example>
  450. </section3>
  451. <section3 topic="Generating Session Keys" anchor='init-keys'>
  452. <p>Bob MUST use HMAC with the selected hash algorithm ("HASH") and the shared secret ("K") to generate two sets of three keys, one set for each direction of the ESession.</p>
  453. <p>For stanzas that Alice will send to Bob, the keys are calculated as:</p>
  454. <ol>
  455. <li><p>Encryption key &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")</p></li>
  456. <li><p>Integrity key &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")</p></li>
  457. <!-- <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> -->
  458. <li><p>SIGMA key &KSsubA; = <em>HMAC</em>(HASH, K, "Initiator SIGMA Key")</p></li>
  459. </ol>
  460. <p>For stanzas that Bob will send to Alice the keys are calculated as:</p>
  461. <ol start='4'>
  462. <li><p>Encryption key &KCsubB; = <em>HMAC</em>(HASH, K, "Responder Cipher Key")</p></li>
  463. <li><p>Integrity key &KMsubB; = <em>HMAC</em>(HASH, K, "Responder MAC Key")</p></li>
  464. <li><p>SIGMA key &KSsubB; = <em>HMAC</em>(HASH, K, "Responder SIGMA Key")</p></li>
  465. </ol>
  466. <p>Note: As many bits of key data as are needed for each key MUST be taken from the least significant bits of the HMAC 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>
  467. <p>Once the sets of keys have been calculated the value of K MUST be securely destroyed, unless it will be used later to generate the final shared secret (see <link url='#init-finalbob'>Generating Bob's Final Session Keys</link>.</p>
  468. </section3>
  469. <section3 topic="Hiding Bob's Identity" anchor='init-hide'>
  470. <p>Bob MUST perform the following steps before he can prove his identity to Alice while protecting it from third parties.</p>
  471. <ol>
  472. <li><p>Bob MUST select one method of identification from the values in the 'resp_pubkey' field he received from Alice. If he selects the 'none' method of identification then he MUST set &pubKeyB; to a zero length string of characters. Otherwise Bob SHOULD select &pubKeyB;, which MUST be a <link url='#sign-normal'>Normalized</link> &lt;KeyValue/&gt; element (as specified in <cite>XML Signature</cite>). This is the public key Alice will use to authenticate his signature with the signature algorithm he selected ("SIGN").</p></li>
  473. <li><p>Set &formB; to be the full <link url='#sign-normal'>Normalized</link>&#160;<em>content</em> of the reponse data form he generated above (see <link url='#init-online-form'>Response Form</link>). Note: this MUST NOT include 'identity' or 'mac' fields.</p></li>
  474. <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 the selected hash algorithm ("HASH") and the key &KSsubB;.</p>
  475. <code>&macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &formB;})</code></li>
  476. <li><p>If the value of the 'resp_pubkey' field that Alice sent Bob was <em>not</em> 'none' then Bob MUST calculate &signB;, the signature (using his private signature key that corresponds to &pubKeyB;) of the HMAC result wrapped in a &lt;SignatureValue/&gt; element. Note: &signB; MUST be calculated as specified in <cite>XML Signature</cite> except that it is signature of the HMAC result, <em>not</em> of a &lt;SignedInfo/&gt; element.</p>
  477. <code>if (resp_pubkey != 'none') &signB; = SIGN(&signKeyB;, &macB;)</code></li>
  478. <li><p>If the value of the 'resp_pubkey' field that Alice sent Bob was 'hash' then Bob SHOULD set &pubKeyB; to the key's fingerprint wrapped in a &lt;fingerprint/&gt; element</p>
  479. <code>if (resp_pubkey == 'hash') &pubKeyB; = '&lt;fingerprint&gt;' + HASH(&pubKeyB;) + '&lt;/fingerprint&gt;'</code></li>
  480. <li><p>Encrypt the byte string resulting from the concatenation of &pubKeyB; and &signB; (or, if the value of the 'resp_pubkey' field that Alice sent Bob was 'none', encrypt just the HMAC result) 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>
  481. <code>&IDB; = CIPHER(&KCsubB;, &CsubB;, {&pubKeyB;, &signB;})</code>
  482. <p>or</p>
  483. <code>&IDB; = CIPHER(&KCsubB;, &CsubB;, &macB;)</code></li>
  484. <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>
  485. <code>&MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)</code></li>
  486. </ol>
  487. </section3>
  488. <section3 topic="Sending the Response (3-message negotiations)" anchor='init-online-send3'>
  489. <p>For 3-message negotiations Bob should append the Base64 encoded values of &IDB; and &MsubB; to &formB; wrapped in 'identity' and 'mac' fields, and send the resulting form to Alice:</p>
  490. <example caption='Bob Responds to Alice (3-Message Negotiation)'><![CDATA[
  491. <message from='bob@example.com/laptop' to='alice@example.org/pda'>
  492. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  493. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  494. <x type='submit' xmlns='jabber:x:data'>
  495. <field var='FORM_TYPE'>
  496. <value>urn:xmpp:ssn</value>
  497. </field>
  498. ...
  499. ...
  500. ...
  501. <field var='my_nonce'>
  502. <value> ** Bob's Base64 encoded ESession ID ** </value>
  503. </field>
  504. <field var='dhkeys'>
  505. <value> ** Base64 encoded value of d ** </value>
  506. </field>
  507. <field var='nonce'>
  508. <value> ** Alice's Base64 encoded ESession ID ** </value>
  509. </field>
  510. <field var='counter'>
  511. <value> ** Base64 encoded block counter ** </value>
  512. </field>
  513. <field var='identity'>
  514. <value> ** Encrypted identity ** </value>
  515. </field>
  516. <field var='mac'>
  517. <value> ** Integrity of identity ** </value>
  518. </field>
  519. </x>
  520. </feature>
  521. </message>
  522. ]]></example>
  523. </section3>
  524. </section2>
  525. <section2 topic="ESession Accept (Alice)" anchor='init-acceptalice'>
  526. <section3 topic="Diffie-Hellman Preparation (Alice)" anchor='init-acceptalice-prep'>
  527. <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>
  528. <ol start='1'>
  529. <li><p>Verify that the ESession options selected by Bob are acceptable</p></li>
  530. <li><p>Return a &notacceptable; error to Bob unless: 1 &lt; d &lt; p - 1</p></li>
  531. <li><p>Set &CBeCAx2n1; (where &CsubB; is the block counter for stanzas sent from Bob to Alice)</p></li>
  532. <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 - see <link url='#init-online-request'>ESession Request</link>)</p></li>
  533. <li><p>Calculate K = HASH(&dsupx; mod p) (the shared secret)</p></li>
  534. <li><p>Generate the session keys (&KCsubA;, &KMsubA;, &KSsubA;, &KCsubB;, &KMsubB; and &KSsubB;) in exactly the same way as Bob did (see <link url='#init-keys'>Generating Session Keys</link>). Note: In the case of 4-message negotiation it is only necessary to generate provisory keys for the messages Alice sends to Bob (&KCsubA;, &KMsubA;, &KSsubA;).</p></li>
  535. </ol>
  536. <p>If this is a 4-message negotiation then Alice MUST skip the next section and proceed by executing the steps in the <link url='#init-acceptalice-hide'>Hiding Alice's Identity</link> section.</p>
  537. </section3>
  538. <section3 topic="Verifying Bob's Identity" anchor='init-online-bobid'>
  539. <p>If this is a 3-message negotiation then Alice MUST also perform the following steps:</p>
  540. <ol start='1'>
  541. <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>
  542. <code>&MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)</code></li>
  543. <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>
  544. <li><p>Obtain &macB; (if the value of the 'resp_pubkey' field she sent to Bob in her <link url='#init-online-request'>ESession Request</link> was 'none') or &pubKeyB; and &signB; (otherwise) 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>
  545. <code>&macB; = DECIPHER(&KCsubB;, &CsubB;, &IDB;)</code>
  546. <p>or</p>
  547. <code>{&pubKeyB;, &signB;} = DECIPHER(&KCsubB;, &CsubB;, &IDB;)</code></li>
  548. <li><p>If the value of the 'resp_pubkey' field that Alice sent Bob was 'none' then Alice MUST set &pubKeyB; to be a zero length string of characters. Otherwise, if the value was 'hash', then Alice SHOULD change the value of &pubKeyB; to be her copy of the public key (a <link url='#sign-normal'>Normalized</link> &lt;KeyValue/&gt; element) whose HASH matches the value wrapped in the &pubKeyB; &lt;fingerprint/&gt; element that she received from Bob.</p>
  549. <p>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 'resp_pubkey' field set to 'key' or 'none'.</p></li>
  550. <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>
  551. <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>
  552. <code>&macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &formB;})</code></li>
  553. <li><p>If the value of the 'resp_pubkey' field that Alice sent Bob was 'none' then return a &feature; error to Bob if the two values of &macB; she calculated in the steps above do not match.</p>
  554. <p>If the value of the 'resp_pubkey' field was not 'none', return a &feature; error unless she can confirm (or has previously confirmed) that &pubKeyB; really is Bob's public key (see <link url='#sec-keys'>Verifying Keys</link>) and she can use &pubKeyB; with the selected signature verification algorithm ("VERIFY") to confirm that &signB; is the signature of the HMAC result (see <cite>XML Signature</cite>).</p>
  555. <code>VERIFY(&signB;, &pubKeyB;, &macB;)</code></li>
  556. </ol>
  557. </section3>
  558. <section3 topic="Hiding Alice's Identity" anchor='init-acceptalice-hide'>
  559. <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 Bob's Identity</link> for a more detailed description). Alice's calculations are summarised below. Note: When calculating &macA; pay attention to the order of &NsubB; and &NsubA; and to the inclusion of &formA2;.</p>
  560. <p>Note: &formA; is the full <link url='#sign-normal'>Normalized</link>&#160;<em>content</em> of the <link url='#init-online-request'>ESession Request</link> data form that Alice sent to Bob at the start of the negotiation, while &formA2; is the full <link url='#sign-normal'>Normalized</link>&#160;<em>content</em> of Alice's session negotiation completion form <em>excluding</em> the 'identity' and 'mac' fields (see <link url='#init-acceptalice-send'>Sending Alice's Identity</link> below).</p>
  561. <code>&macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;, &formA;, &formA2;})</code>
  562. <code>if (init_pubkey != 'none') &signA; = SIGN(&signKeyA;, &macA;)</code>
  563. <code>if (init_pubkey == 'hash') &pubKeyA; = HASH(&pubKeyA;)</code>
  564. <code>&IDA; = CIPHER(&KCsubA;, &CsubA;, {&pubKeyA;, &signA;}) <em>OR</em>&#160; &IDA; = CIPHER(&KCsubA;, &CsubA;, &macA;)</code>
  565. <code>&MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)</code>
  566. </section3>
  567. <section3 topic="Sending Alice's Identity" anchor='init-acceptalice-send'>
  568. <p>Alice MUST send the Base64 encoded values of &NsubB; (wrapped in a 'nonce' field), &IDA; (wrapped in an 'identity' field) and &MsubA; (wrapped in a 'mac' field) to Bob in her session negotiation completion message.</p>
  569. <p>In the case of a 3-message negotiation Alice MAY also send encrypted content (see <cite>Stanza Encryption</cite>) in the same stanza as the proof of her identity:</p>
  570. <example caption='Alice Sends Bob Her Identity (3-Message Negotiation)'><![CDATA[
  571. <message from='alice@example.org/pda' to='bob@example.com/laptop'>
  572. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  573. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  574. <x type='result' xmlns='jabber:x:data'>
  575. <field var='FORM_TYPE'><value>urn:xmpp:ssn</value></field>
  576. <field var='accept'><value>1</value></field>
  577. <field var='nonce'><value> ** Bob's Base64 encoded ESession ID ** </value></field>
  578. <field var='identity'><value> ** Encrypted identity ** </value></field>
  579. <field var='mac'><value> ** Integrity of identity ** </value></field>
  580. </x>
  581. </feature>
  582. <c xmlns='http://www.xmpp.org/extensions/xep-0200.html#ns'>
  583. <data> ** Base64 encoded m_final ** </data>
  584. <mac> ** Base64 encoded a_mac ** </mac>
  585. </c>
  586. </message>
  587. ]]></example>
  588. <p>Note: 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>
  589. <p>In the case of a 4-message negotiation Alice MUST also include in the data form her Base64 encoded values of e (wrapped in a 'dhkeys' field) and the Base64 encoded HMAC (using HASH and the key &NsubA; <note>The HMACs of the retained secrets are generated using Alice's unique session nonce to prevent her being identified by her retained secrets (only one secret changes each session, and some might not change very often).</note>) of each secret that Alice has retained from her previous session with each of Bob's clients (wrapped in a 'rshashes' field) - see <link url='#init-acceptbob-send'>Sending Bob's Identity</link>. Note: Alice MUST also append a few random numbers to the 'rshashes' field to make it difficult for an active attacker to discover if she has communicated with Bob before or how many clients Bob has used to communicate with her.</p>
  590. <example caption='Alice Sends Bob Her Identity (4-Message Negotiation)'><![CDATA[
  591. <message from='alice@example.org/pda' to='bob@example.com/laptop'>
  592. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  593. <feature xmlns='http://jabber.org/protocol/feature-neg'>
  594. <x type='result' xmlns='jabber:x:data'>
  595. <field var='FORM_TYPE'><value>urn:xmpp:ssn</value></field>
  596. <field var='accept'><value>1</value></field>
  597. <field var='nonce'><value> ** Bob's Base64 encoded ESession ID ** </value></field>
  598. <field type='hidden' var='dhkeys'>
  599. <value> ** Base64 encoded value of e5 ** </value>
  600. </field>
  601. <field type='hidden' var='rshashes'>
  602. <value> ** Base64 encoded hash of retained secret ** </value>
  603. <value> ** Base64 encoded hash of retained secret ** </value>
  604. <value> ** Base64 encoded random value ** </value>
  605. <value> ** Base64 encoded random value ** </value>
  606. </field>
  607. <field var='identity'><value> ** Encrypted identity ** </value></field>
  608. <field var='mac'><value> ** Integrity of identity ** </value></field>
  609. </x>
  610. </feature>
  611. </message>
  612. ]]></example>
  613. </section3>
  614. </section2>
  615. <section2 topic="ESession Accept (Bob)" anchor='init-acceptbob'>
  616. <section3 topic="Verifying Alice's Identity" anchor='init-acceptbob-verify'>
  617. <p>In the case of a 4-message negotiation Bob MUST perform the following four steps:</p>
  618. <ol>
  619. <li><p>Return a &feature; error unless SHA256(e) equals 'He', the value he received from Alice in her original session request.</p></li>
  620. <li><p>Return a &feature; error unless: 1 &lt; e &lt; p - 1</p></li>
  621. <li><p>Use the value of e he received from Alice, his secret value of y and their agreed value of p to calculate the value of the Diffie-Hellman shared secret: K = HASH(&esupy; mod p)</p></li>
  622. <li><p>Generate Alice's provisory session keys (&KCsubA;, &KMsubA;, &KSsubA;) in exactly the same way as specified for 3-message negotiations in the <link url='#init-keys'>Generating Session Keys</link> section.</p></li>
  623. </ol>
  624. <p>After receiving Alice's identity Bob MUST verify it by performing steps equivalent to those performed by Alice above (see <link url='#init-online-bobid'>Verifying Bob's Identity</link> for a more detailed description). Some of Bob's calculations are summarised below. Note: When calculating &macA; pay attention to the order of &NsubB; and &NsubA; and to the inclusion of &formA2;.</p>
  625. <p>Note: &formA; is the full <link url='#sign-normal'>Normalized</link>&#160;<em>content</em> of the <link url='#init-online-request'>ESession Request</link> data form that Alice sent to Bob at the start of the negotiation, while &formA2; is the full <link url='#sign-normal'>Normalized</link>&#160;<em>content</em> of Alice's session negotiation completion form <em>excluding</em> the 'identity' and 'mac' fields (see <link url='#init-acceptalice-send'>Sending Alice's Identity</link>).</p>
  626. <p>Note: If Bob sends an error to Alice then he SHOULD ignore any encrypted content he received in the stanza.</p>
  627. <code>&MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)</code>
  628. <code>&macA; = DECIPHER(&KCsubA;, &CsubA;, &IDA;) <em>OR</em> {&pubKeyA;, &signA;} = DECIPHER(&KCsubA;, &CsubA;, &IDA;)</code>
  629. <code>&macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;, &formA;, &formA2;})</code>
  630. <code>VERIFY(&signA;, &pubKeyA;, &macA;)</code>
  631. <p><em>In the case of a 3-message negotiation, the ESession negotiation is now complete.</em></p>
  632. </section3>
  633. <section3 topic="Short Authentication String" anchor='init-acceptbob-sas'>
  634. <p><em>Note: The steps in this and all the following Online ESession Negotiation sections are only necessary for 4-message negotiations.</em></p>
  635. <p>Bob and Alice MAY confirm out-of-band that the Short Authentication Strings (SAS) their clients generate for them (using the SAS generation algorithm that they agreed on) are the same. This out-of-band step MAY be performed at any time. However, if either Bob or Alice has not provided a public key, or if either of their public keys has never been authenticated by the other party, then they SHOULD confirm out-of-band that their SAS match as soon as they realise that the two clients have no retained secret in common (see <link url='#init-finalbob'>Generating Bob's Final Session Keys</link> below, or <link url='#init-finalalice'>Generating Alice's Final Session Keys</link>). However, if it is inconvenient for Bob and Alice to confirm the match immediately, both clients MAY remember (in a secure way) that a SAS match has not yet been confirmed and remind Bob and Alice at the start of each ESession that they should confirm the SAS match (even if they have a retained secret in common). Their clients should continue to remind them until they either confirm a SAS match, or indicate that security is not important enough for them to bother.</p>
  636. </section3>
  637. <section3 topic="Generating Bob's Final Session Keys" anchor='init-finalbob'>
  638. <p>Bob MUST identify the shared retained secret (SRS) by selecting from his client's list of the secrets it retained from previous sessions with Alice's clients (i.e., secrets from sessions where the bareJID was the same as the one Alice is currently using). Note: The list contains the most recent shared secret for each of Alice's clients that she has previously used to negotiate ESessions with the client Bob is currently using.</p>
  639. <p>Bob does this by calculating the HMAC (using HASH and the key &NsubA;) of each secret in the list in turn and comparing it with each of the values in the 'rshashes' field he received from Alice (see <link url='#init-acceptalice-send'>Sending Alice's Identity</link>). Once he finds a match, and has confirmed that the secret has not expired (because it is older than an implementation-defined period of time), then he has found the SRS.</p>
  640. <p>If Bob cannot find a match, then he SHOULD search through all the retained secrets that have not expired for all the other JIDs his client has communicated with to try to find a match with one of the values in the 'rshashes' field he received from Alice (since she may simply be using a different JID, perhaps in order to protect her identity from third parties). Once he finds a match then he has found the SRS. Note: Resource-constrained implementations MAY make the performance of this second extended search an optional feature.</p>
  641. <p>Bob MUST calculate the final session key by appending to K (the Diffie-Hellman shared secret) the SRS (only if one was found) and then the Other Shared Secret (only if one exists) and then setting K to be the HASH result of the concatenated string of bytes:</p>
  642. <code>K = HASH(K | SRS | OSS)</code>
  643. <p>Bob MUST now use the new value of K to generate the new session keys (&KCsubA;, &KMsubA;, &KCsubB;, &KMsubB; and &KSsubB;) in exactly the same way as he does for 3-message negotiations (see <link url='#init-keys'>Generating Session Keys</link>). These keys will be used to exchange encrypted stanzas. Note: Bob will still need the value of K in the next section.</p>
  644. </section3>
  645. <section3 topic="Sending Bob's Identity" anchor='init-acceptbob-send'>
  646. <p>Bob MUST now prove his identity to Alice while protecting it from third parties. He does this in the same way as he does for 3-message negotiations (see <link url='#init-hide'>Hiding Bob's Identity</link> for a more detailed description) except that, when calculating &macB;, he MUST include &formB2;:</p>
  647. <code>&macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &formB;, &formB2;})</code>
  648. <p>Note: &formB2; is the full <link url='#sign-normal'>Normalized</link>&#160;<em>content</em> of Bob's session negotiation completion form <em>excluding</em> the 'identity' and 'mac' fields (see below).</p>
  649. <p>Bob MUST send Alice the Base64 encoded value of the HMAC (using HASH and the key SRS) of the string "Shared Retained Secret" (wrapped in an 'srshash' field). If no SRS was found then he MUST use a random number instead. <note>Bob always sends a value in the 'srshash' field to prevent an attacker learning that the session is not protected by a retained secret.</note></p>
  650. <code><em>HMAC</em>(HASH, SRS, "Shared Retained Secret")</code>
  651. <p>Bob MUST also include in the data form the Base64 encoded values of &NsubA;, and &IDB; and &MsubB; (that he just calculated). Note: He MAY also send encrypted content (see <cite>Stanza Encryption</cite>) in the same stanza.</p>
  652. <example caption='Bob Sends Alice His Identity'><![CDATA[
  653. <message from='bob@example.com/laptop' to='alice@example.org/pda'>
  654. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  655. <init xmlns='http://www.xmpp.org/extensions/xep-0116.html#ns-init'>
  656. <x type='result' xmlns='jabber:x:data'>
  657. <field var='FORM_TYPE'><value>urn:xmpp:ssn</value></field>
  658. <field var='nonce'><value> ** Alice's Base64 encoded ESession ID ** </value></field>
  659. <field var='srshash'><value> ** HMAC with shared retained secret ** </value></field>
  660. <field var='identity'><value> ** Encrypted identity ** </value></field>
  661. <field var='mac'><value> ** Integrity of identity ** </value></field>
  662. </x>
  663. </init>
  664. </message>
  665. ]]></example>
  666. <p>Finally, Bob MUST destroy all his copies of the old retained secret (SRS) he was keeping for Alice's client, and calculate a new retained secret for this session:</p>
  667. <code><em>HMAC</em>(HASH, K, "New Retained Secret")</code>
  668. <p>Bob MUST <em>securely</em> store the new value along with the retained secrets his client shares with Alice's other clients.</p>
  669. <p>Bob's value of K MUST now be securely destroyed.</p>
  670. </section3>
  671. </section2>
  672. <section2 topic="Final Steps (Alice)" anchor='init-complete'>
  673. <section3 topic="Generating Alice's Final Session Keys" anchor='init-finalalice'>
  674. <p>Alice MUST identify the shared retained secret (SRS) by selecting from her client's list of the secrets it retained from sessions with Bob's clients (the most recent secret for each of the clients he has used to negotiate ESessions with Alice's client).</p>
  675. <p>Alice does this by using each secret in the list in turn as the key to calculate the HMAC (with HASH) of the string "Shared Retained Secret", and comparing the calculated value with the value in the 'srshash' field she received from Bob (see <link url='#init-acceptbob-send'>Sending Bob's Identity</link>). Once she finds a match, and has confirmed that the secret has not expired (because it is older than an implementation-defined period of time), then she has found the SRS.</p>
  676. <p>Alice MUST calculate the final session key by appending to K (the Diffie-Hellman shared secret) the SRS (only if one was found) and then the Other Shared Secret (only if one exists) and then setting K to be the HASH result of the concatenated string of bytes:</p>
  677. <code>K = HASH(K | SRS | OSS)</code>
  678. <p>Alice MUST destroy all her copies of SRS (the retained secret she was keeping for Bob's client), calculate a new retained secret for this session (see below) and <em>securely</em> store the new value along with the other retained secrets her client shares with Bob's clients:</p>
  679. <code><em>HMAC</em>(HASH, K, "New Retained Secret")</code>
  680. <p>Alice MUST now use the new value of K to generate the new session keys (&KCsubA;, &KMsubA;, &KCsubB;, &KMsubB; and &KSsubB;) in exactly the same way as Bob did (see <link url='#init-keys'>Generating Session Keys</link>). These keys will be used to exchange encrypted stanzas.</p>
  681. </section3>
  682. <section3 topic="Verifying Bob's Identity" anchor='init-complete-verify'>
  683. <p>Finally, Alice MUST verify the identity she received from Bob. She does this in the same way as she does for 3-message negotiations <link url='#init-online-bobid'>Verifying Bob's Identity</link> above. Note: If Alice discovers an error then she SHOULD ignore any encrypted content she received in the stanza.</p>
  684. <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) within the session.</p>
  685. </section3>
  686. </section2>
  687. </section1>
  688. <section1 topic='ESession Termination' anchor='terminate'>
  689. <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 (see <cite>Stanza Encryption</cite>) to Bob including within the encrypted XML of the &lt;data/&gt; element a stanza session negotiation form with a "terminate" field (as specified in the Termination section of <cite>Stanza 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 <cite>Stanza Encryption</cite>). She MUST then securely destroy all keys associated with the ESession.</p>
  690. <example caption='Alice Terminates an ESession'><![CDATA[
  691. <message from='alice@example.org/pda' to='bob@example.com/laptop'>
  692. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  693. <c xmlns='http://www.xmpp.org/extensions/xep-0200.html#ns'>
  694. <data> ** Base64 encoded encrypted terminate form ** </data>
  695. <old> ** Base64 encoded old MAC key ** </old>
  696. <mac> ** Base64 encoded a_mac ** </mac>
  697. </c>
  698. </message>
  699. ]]></example>
  700. <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>Stanza 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>
  701. <example caption='Bob Acknowledges ESession Termination'><![CDATA[
  702. <message from='bob@example.com/laptop' to='alice@example.org/pda'>
  703. <thread>ffd7076498744578d10edabfe7f4a866</thread>
  704. <c xmlns='http://www.xmpp.org/extensions/xep-0200.html#ns'>
  705. <data> ** Base64 encoded encrypted acknowledgement form ** </data>
  706. <old> ** Base64 encoded old MAC key ** </old>
  707. <mac> ** Base64 encoded b_mac ** </mac>
  708. </c>
  709. </message>
  710. ]]></example>
  711. <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>
  712. </section1>
  713. <section1 topic='Implementation Notes' anchor='implement'>
  714. <section2 topic='Multiple-Precision Integers' anchor='sign-bigint'>
  715. <p>Before Base-64 encoding, hashing or HMACing an arbitrary-length integer, the integer MUST first be converted to a "big endian" bitstring. The bitstring MUST then be padded with leading zero bits so that there are an integral number of octets. Finally, if the integer is not of fixed bit-length (i.e. not a hash or HMAC result) and the bitstring contains leading octets that are zero, these MUST be removed (so the high-order octet is non-zero).</p>
  716. </section2>
  717. <section2 topic='XML Normalization' anchor='sign-normal'>
  718. <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>
  719. <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>
  720. <ul>
  721. <li>Set attribute value delimiters to single quotation marks (i.e. simply replace all single quotes in the serialized XML with double quotes)</li>
  722. <li>Impose lexicographic order on the attributes of "field" elements (i.e. ensure "type" is before "var")</li>
  723. </ul>
  724. <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>
  725. <ul>
  726. <li>Ensure there are no character references</li>
  727. <li>Convert empty elements to start-end tag pairs</li>
  728. <li>Ensure there is no whitespace except for single spaces before attributes</li>
  729. <li>Ensure there are no "xmlns" attributes or namespace prefixes.</li>
  730. </ul>
  731. </section2>
  732. </section1>
  733. <section1 topic='Security Considerations' anchor='sec'>
  734. <section2 topic='Random Numbers' anchor='sec-prng'>
  735. <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>
  736. </section2>
  737. <section2 topic='Replay Attacks' anchor='sec-replay'>
  738. <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>
  739. </section2>
  740. <section2 topic='Verifying Keys' anchor='sec-keys'>
  741. <p>The trust system outlined in this document is based on Alice trusting that the public key presented by Bob (wrapped in a &lt;KeyValue/&gt; element) 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>
  742. <p>When trust cannot be achieved automatically, methods that are not transparent to the users may be employed. The out-of-band Short Authentication String mechanism described in this document is an easy way for people to do that. Alternatively, Bob could communicate the <em>full</em> 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: Since very few people bother to (consistently) verify SAS or fingerprints, entities SHOULD protect against 'man-in-the-middle' attacks using retained secrets and/or other secrets. In the case of retained secrets entities SHOULD remember whether or not the whole chain of retained secrets (and the associated sessions) has ever been validated by the user verifying a SAS.</p>
  743. <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>
  744. </section2>
  745. <section2 topic='Key Associations' anchor='sec-associations'>
  746. <p>An entity SHOULD remember the fingerprints of all public keys it receives, and remember whether or not they have been validated by the user (see <link url='#sec-keys'>Verifying Keys</link>).</p>
  747. <p>Entities MUST associate one or more JIDs with each public key fingerprint that they store, and alert their users immediately if another JID presents the same public key. This is necessary since if Bob already has fingerprints from Alice and Mallory, and Bob's client presents only the JID (or a name associated with the JID) to Bob, then Mallory could use his own public key (that is trusted by Bob) and pretend to be Alice simply by exchanging stanzas with Bob using Alice's JID.</p>
  748. <p>If a JID for which a key has previously been stored attempts to establish an ESession using a public key with a different fingerprint (or no key at all) then the entity MUST alert its user.</p>
  749. <p>Since Alice MAY use many different JIDs to talk to Bob, but always identify herself to him with the same public key, Entities SHOULD associate a "petname" with each public key fingerprint they store. Entities MUST present any public key petnames clearly to their users, and more prominently than any petname or nickname associated with the JID or the JID itself.</p>
  750. </section2>
  751. <section2 topic='Unencrypted ESessions' anchor='sec-unencrypted'>
  752. <p>Organisations with full disclosure policies may require entities to disable encryption (see <link url='#sec-backdoor'>Back Doors</link>) to enable the logging of all messages on their server. Unencrypted ESessions meet all the Security Requirements (see <cite>Cryptographic Design of Encrypted Sessions</cite>) 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 'security' option (as specified in <cite>Stanza Session Negotiation</cite>) has not been tampered with.</p>
  753. </section2>
  754. <section2 topic="Back Doors" anchor="sec-backdoor">
  755. <p>The authors and the XSF would like to discourage the deliberate inclusion of "back doors" in implementations of this protocol. However, we recognize that some organizations must monitor stanza sessions or record stanza sessions in decryptable form for legal compliance reasons, or may choose to monitor stanza sessions for quality assurance purposes. In these cases it is important to inform the other entity of the (potential for) disclosure before starting the ESession (if only to maintain public confidence in this protocol).</p>
  756. <p>Both implementations MUST immediately and clearly inform their users if the negotiated value of the 'disclose' field is not 'never'.</p>
  757. <p>Before disclosing any stanza session, an entity SHOULD either negotiate the value of the 'disclose' field to be 'enabled' or terminate the negotiation unsuccessfully. It MUST NOT negotiate the value of the 'disclose' field to be 'disabled' unless it would be illegal for it to divulge the disclosure to the other entity.</p>
  758. <p>In any case an implementation MUST NOT negotiate the value of the 'disclose' field to be 'never' unless it implements no feature or mechanism (not even a disabled feature or mechanism) that could be used directly or indirectly to divulge to <em>any</em> third-party either the identites of the participants, or the keys, or the content of <em>any</em> ESession (or information that could be used to recover any of those items). If an implementation deliberately fails to observe this last point (or fails to correct an accidental back door) then it is not compliant with this protocol and MUST NOT either claim or imply any compliance with this protocol or any of the other protocols developed by the authors or the XSF. In this case the authors and the XSF reserve all rights regarding the names of the protocols.</p>
  759. <p>The expectation is that this legal requirement will persuade many implementors either to tell the users of their products that a back door exists, or not to implement a back door at all (if, once informed, the market demands that).</p>
  760. </section2>
  761. <section2 topic='Extra Responsabilities of Implementors' anchor='sec-general'>
  762. <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>
  763. </section2>
  764. </section1>
  765. <section1 topic='Mandatory to Implement Technologies' anchor='sec-mandatory'>
  766. <p>An implementation of ESession MUST support the Diffie-Hellman Key Agreement and HMAC (see Section 2 of &rfc2104;) algorithms. Note: Some of 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 some of the other names.</p>
  767. <section2 topic='Block Cipher Algorithms' anchor='sec-mandatory-encryption'>
  768. <p>An implementation of ESession MUST support the following block cipher algorithm:</p>
  769. <ul>
  770. <li>aes128-ctr (see &nistfips197;)</li>
  771. </ul>
  772. <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>
  773. <ul>
  774. <li>aes256-ctr</li>
  775. <li>aes192-ctr</li>
  776. <li>twofish256-ctr (see &twofish;)</li>
  777. <li>twofish192-ctr</li>
  778. <li>twofish128-ctr</li>
  779. <li>serpent256-ctr (see &serpent;)</li>
  780. <li>serpent192-ctr</li>
  781. <li>serpent128-ctr</li>
  782. <li>none (no encryption, only signing)</li>
  783. </ul>
  784. </section2>
  785. <section2 topic='Key Signing Algorithms' anchor='sec-mandatory-sign'>
  786. <p>An implementation of ESession MUST support the following signing algorithm:</p>
  787. <ul>
  788. <li><p>http://www.w3.org/2000/09/xmldsig#rsa-sha256</p>
  789. <p>(the same as http://www.w3.org/2000/09/xmldsig#rsa-sha1 except that it uses SHA256 instead of SHA1, see <cite>XML Signature</cite>)</p></li>
  790. </ul>
  791. <p>An implementation of ESession SHOULD also support at least the following signing algorithm:</p>
  792. <ul>
  793. <li><p>http://www.w3.org/2000/09/xmldsig#dsa-sha256</p>
  794. <p>(the same as http://www.w3.org/2000/09/xmldsig#dsa-sha1 except that it uses SHA256 instead of SHA1, see <cite>XML Signature</cite>)</p></li>
  795. </ul>
  796. </section2>
  797. <section2 topic='Public Signature-Verification-Key Formats' anchor='sec-mandatory-public'>
  798. <p>&lt;KeyValue/&gt; elements (as specified in <cite>XML Signature</cite>) may contain different public key formats. An implementation of ESession MUST support the following format:</p>
  799. <ul>
  800. <li>&lt;RSAKeyValue/&gt;</li>
  801. </ul>
  802. <p>An implementation of ESession SHOULD also support the following public key format:</p>
  803. <ul>
  804. <li>&lt;DSAKeyValue/&gt;</li>
  805. </ul>
  806. </section2>
  807. <section2 topic='Hash Algorithms' anchor='sec-mandatory-hash'>
  808. <p>An implementation of ESession MUST support the following hash algorithm:</p>
  809. <ul>
  810. <li>sha256 (see <cite>Secure Hash Standard</cite>)</li>
  811. </ul>
  812. <p>An implementation of ESession SHOULD also support at least the following hash algorithm (sha1 and md5 are broken and therefore NOT RECOMMENDED):</p>
  813. <ul>
  814. <li>whirlpool (see &whirlpool;)</li>
  815. </ul>
  816. </section2>
  817. <section2 topic='Short Authentication String Generation Algorithms' anchor='sec-mandatory-sas'>
  818. <p>An implementation of ESession MUST support the following SAS generation algorithm:</p>
  819. <ul>
  820. <li>sas28x5 (see <link url='#sas'>The sas28x5 SAS Algorithm</link>)</li>
  821. </ul>
  822. </section2>
  823. <section2 topic='Compression Algorithms' anchor='sec-mandatory-compress'>
  824. <p>An implementation of ESession MUST support the following compression algorithm:</p>
  825. <ul>
  826. <li>none (no compression, the output MUST be the same as the input)</li>
  827. </ul>
  828. <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>
  829. <ul>
  830. <li>lzw (see &ecma151;)</li>
  831. <li>zlib (see &rfc1950;)</li>
  832. </ul>
  833. </section2>
  834. </section1>
  835. <section1 topic="The sas28x5 SAS Algorithm" anchor='sas'>
  836. <p>Given the multi-precision integer &MsubA; (a big-endian byte array), the UTF-8 byte string &formB; (see <link url='#init-hide'>Hiding Bob's Identity</link>) and the hash function "HASH", the following steps can be used to calculate a 5-character SAS with over 16 million possible values that is easy to read and communicate verbally:</p>
  837. <ol>
  838. <li><p>Concatenate &MsubA;, &formB; and the UTF-8 byte string "Short Authentication String" into a string of bytes</p></li>
  839. <li><p>Calculate the least significant 24-bits of the HASH of the string</p></li>
  840. <li><p>Convert the 24-bit integer into a base-28 <note>Base-28 was used instead of Base-36 because some characters are often confused when communicated verbally (n, s, b, t, z, j), and because zero is often read as the letter 'o', and the letter 'l' is often read as the number '1'.</note> 5-character string using the following "digits": acdefghikmopqruvwxy123456789 (the digits have values 0-27)</p></li>
  841. </ol>
  842. </section1>
  843. <section1 topic='IANA Considerations' anchor='iana'>
  844. <p>This document requires no interaction with &IANA;. </p>
  845. </section1>
  846. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  847. <section2 topic='Protocol Namespaces' anchor='ns'>
  848. <p>Until this specification advances to a status of Draft, its associated namespaces shall be "http://www.xmpp.org/extensions/xep-0116.html#ns" and "http://www.xmpp.org/extensions/xep-0116.html#ns-init"; upon advancement of this specification, the &REGISTRAR; shall issue permanent namespaces in accordance with the process defined in Section 4 of &xep0053;.</p>
  849. </section2>
  850. <section2 topic='Field Standardization' anchor='registrar-formtype'>
  851. <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 Session Negotiation and Stanza Session Negotiation:</p>
  852. <code caption='Registry Submission'><![CDATA[
  853. <form_type>
  854. <name>http://www.xmpp.org/extensions/xep-0116.html#ns</name>
  855. <doc>XEP-0116</doc>
  856. <desc>ESession negotiation forms</desc>
  857. <field
  858. var='compress'
  859. type='list-single'
  860. label='Compression algorithm options'/>
  861. <field
  862. var='counter'
  863. type='hidden'
  864. label='Initial block counter'/>
  865. <field
  866. var='crypt_algs'
  867. type='list-single'
  868. label='Symmetric block cipher options'/>
  869. <field
  870. var='dhhashes'
  871. type='hidden'
  872. label='Hashes of Diffie-Hellman public keys'/>
  873. <field
  874. var='dhkeys'
  875. type='hidden'
  876. label='Diffie-Hellman public keys'/>
  877. <field
  878. var='expires'
  879. type='hidden'
  880. label='Expiry time of offline ESession options'/>
  881. <field
  882. var='hash_algs'
  883. type='list-single'
  884. label='Hash algorithm options'/>
  885. <field
  886. var='match_resource'
  887. type='text-single'
  888. label='Target resource for offline ESessions'/>
  889. <field
  890. var='modp'
  891. type='list-single'
  892. label='MODP group number'/>
  893. <field
  894. var='my_nonce'
  895. type='hidden'
  896. label='ESession ID of Sender'/>
  897. <field
  898. var='nonce'
  899. type='hidden'
  900. label='ESession ID of Receiver'/>
  901. <field
  902. var='init_pubkey'
  903. type='list-single'
  904. label='Initiator public key required'>
  905. <option label='No Key'>
  906. <value>none</value>
  907. </option>
  908. <option label='Full Key'>
  909. <value>key</value>
  910. </option>
  911. <option label='Key Fingerprint'>
  912. <value>hash</value>
  913. </option>
  914. </field>
  915. <field
  916. var='resp_pubkey'
  917. type='list-single'
  918. label='Responder public key required'>
  919. <option label='No Key'>
  920. <value>none</value>
  921. </option>
  922. <option label='Full Key'>
  923. <value>key</value>
  924. </option>
  925. <option label='Key Fingerprint'>
  926. <value>hash</value>
  927. </option>
  928. </field>
  929. <field
  930. var='rekey_freq'
  931. type='text-single'
  932. label='Minimum number of stanzas between key exchanges'/>
  933. <field
  934. var='rshashes'
  935. type='hidden'
  936. label='Hashes of retained secrets'/>
  937. <field
  938. var='sas_algs'
  939. type='list-single'
  940. label='SAS generation algorithm options'/>
  941. <field
  942. var='sign_algs'
  943. type='list-single'
  944. label='Signature algorithm options'/>
  945. <field
  946. var='signs'
  947. type='list-single'
  948. label='Data form signatures'/>
  949. <field
  950. var='srshash'
  951. type='hidden'
  952. label='Hash of shared retained secret'/>
  953. <field
  954. var='stanzas'
  955. type='list-multi'
  956. label='Stanzas types to encrypt'/>
  957. <option>
  958. <value>message</value>
  959. </option>
  960. <option>
  961. <value>presence</value>
  962. </option>
  963. <option>
  964. <value>iq</value>
  965. </option>
  966. </field>
  967. <field
  968. var='ver'
  969. type='list-single'
  970. label='Supported versions of ESessions'>
  971. <option>
  972. <value>1.0</value>
  973. </option>
  974. </field>
  975. </form_type>
  976. <form_type>
  977. <name>urn:xmpp:ssn</name>
  978. <doc>XEP-0155</doc>
  979. ...
  980. </form_type>
  981. ]]></code>
  982. </section2>
  983. </section1>
  984. <section1 topic='Open Issues' anchor='open'>
  985. <section2 topic='To Think About' anchor='open-tothink'>
  986. <ol>
  987. <li>What challenges exist to make the OTR Gaim Plugin use this protocol natively when talking to XMPP entities? Can these be mitigated by 'non-critical' protocol changes?</li>
  988. <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>
  989. <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>
  990. </ol>
  991. </section2>
  992. <section2 topic='To Do' anchor='open-todo'>
  993. <ol>
  994. <li>Ask the authors of AMP to explain how to achieve the match_resource functionality specified in XEP-0187.</li>
  995. <li>Add non-repudiable signing option</li>
  996. <li>Perhaps the document needs to specify more carefully how block counters are handled between messages, especially in the event of partial blocks?</li>
  997. <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>
  998. <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>
  999. </ol>
  1000. </section2>
  1001. </section1>
  1002. </xep>