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-0390.xml 62KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. <!ENTITY caps "<em>Entity Capabilities 2.0</em>">
  6. <!ENTITY hash "<em>Capability Hash</em>">
  7. <!ENTITY hashes "<em>Capability Hashes</em>">
  8. <!ENTITY hashcache "<em>Capability Hash Cache</em>">
  9. <!ENTITY hashcaches "<em>Capability Hash Caches</em>">
  10. <!ENTITY hashnode "<em>Capability Hash Node</em>">
  11. <!ENTITY hashnodes "<em>Capability Hash Nodes</em>">
  12. <!ENTITY hashset "<em>Capability Hash Set</em>">
  13. <!ENTITY hashsets "<em>Capability Hash Sets</em>">
  14. <!ENTITY sepl4 "0x1f (ASCII Unit Separator)">
  15. <!ENTITY sepl3 "0x1e (ASCII Record Separator)">
  16. <!ENTITY sepl2 "0x1d (ASCII Group Separator)">
  17. <!ENTITY sepl1 "0x1c (ASCII File Separator)">
  18. <!ENTITY fullstop 'FULL STOP character (U+002E, ".")'>
  19. <!ENTITY procent "<em>Processing Entity</em>">
  20. <!ENTITY procents "<em>Processing Entities</em>">
  21. <!ENTITY genent "<em>Generating Entity</em>">
  22. <!ENTITY genents "<em>Generating Entities</em>">
  23. <!ENTITY queryintercept "<em>Query Interception</em>">
  24. <!ENTITY gratcaps "<em>Gratuitous Capabilities</em>">
  25. <!ENTITY mlwaqas1 "<note>org.jabber.security Mailing List Archive: '[Security] Trivial preimage attack against the entity capabilities protocol)' from 2009-07-22, &lt;<link url='https://mail.jabber.org/pipermail/security/2009-July/000812.html'>https://mail.jabber.org/pipermail/security/2009-July/000812.html</link>&gt;.</note>">
  26. <!ENTITY capsdb "<span class='ref'><link url='https://github.com/xnyhps/capsdb/'>capsdb</link></span> <note><link url='https://github.com/xnyhps/capsdb/'>https://github.com/xnyhps/capsdb/</link></note>">
  27. ]>
  28. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  29. <xep>
  30. <header>
  31. <title>Entity Capabilities 2.0</title>
  32. <abstract>This document overhauls the XMPP protocol extension Entity Capabilities (XEP-0115). It defines an XMPP protocol extension for broadcasting and dynamically discovering client, device, or generic entity capabilities. In order to minimize network impact, the transport mechanism is standard XMPP presence broadcast (thus forestalling the need for polling related to service discovery data), the capabilities information can be cached either within a session or across sessions, and the format has been kept as small as possible.</abstract>
  33. &LEGALNOTICE;
  34. <number>0390</number>
  35. <status>Experimental</status>
  36. <type>Standards Track</type>
  37. <sig>Standards</sig>
  38. <approver>Council</approver>
  39. <dependencies>
  40. <spec>XMPP Core</spec>
  41. <spec>XMPP IM</spec>
  42. <spec>XEP-0030</spec>
  43. <spec>XEP-0300</spec>
  44. </dependencies>
  45. <supersedes>
  46. <spec>XEP-0115</spec>
  47. </supersedes>
  48. <supersededby/>
  49. <shortname>ecaps2</shortname>
  50. &jonaswielicki;
  51. <revision>
  52. <version>0.2</version>
  53. <date>2017-06-14</date>
  54. <initials>jwi</initials>
  55. <remark>
  56. <ul>
  57. <li>Clearly specify handling of xml:lang attributes.</li>
  58. <li>Add Query Interception.</li>
  59. <li>Add Gratuitous Caps.</li>
  60. </ul>
  61. </remark>
  62. </revision>
  63. <revision>
  64. <version>0.1</version>
  65. <date>2017-03-23</date>
  66. <initials>jwi</initials>
  67. <remark><ul><li>Add security consideration for caps spamming.</li><li>Properly reference UTF-8 and Base64 RFCs.</li><li>Remove namespace prefixes from examples.</li><li>Properly reference &fullstop;.</li><li>Clarify the first error condition in the Hash Function Input algorithm.</li></ul></remark>
  68. </revision>
  69. <revision>
  70. <version>0.0.1</version>
  71. <date>2017-02-28</date>
  72. <initials>jwi</initials>
  73. <remark><p>First draft.</p></remark>
  74. </revision>
  75. </header>
  76. <section1 topic='Introduction' anchor='intro'>
  77. <p>XMPP applications often face choices based on the disco#info (see &xep0030;) exposed by other entities. For example, for a client, knowledge about whether a roster entry is a &xep0369; entity or a normal client is important for user experience. It may also be desirable to provide indicators on the type of client a contact is using (mobile or not).</p>
  78. <p>The canonical way to do so has been issueing <cite>XEP-0030</cite> requests to the entities emitting presence. This, with the evergrowing featureset of XMPP, induces a lot of traffic for all involed parties, especially during startup. This is a waste of resources, as <cite>XEP-0030</cite> information rarely changes and even more, common client configurations and versions share exactly the same information.</p>
  79. <p>&xep0115; has provided the XMPP ecosystem with a way to share this information with less bandwith. Entities using that protocol send a hash of their disco#info result along with presence or stream features. As those hashes can be cached, entities receiving these hashes only need to query the information for each hash once, greatly reducing the Service Discovery traffic.</p>
  80. <p>However, <cite>XEP-0115</cite> has two main flaws:</p>
  81. <ul>
  82. <li>The hash agility mechanism is underspecified. While it is possible to change the hash function, there is no clearly defined way to send multiple hashes at once to allow for a transition period. Even though it is technically not forbidden to send multiple <cite>XEP-0115</cite> &lt;c/&gt; elements with different hashes at once, it is unclear how implementations behave when this happens. Possible issues lie in the use of caps optimization, as well as clients expecting only one &lt;c/&gt; element.</li>
  83. <li>The algorithm to generate the input for the hash function has flaws as pointed out by Waqas Hussain &mlwaqas1;. Even though these flaws have partially been fixed and worked around, the fundamental problem that the structural information of the individual strings from the disco response is lost persists.</li>
  84. </ul>
  85. </section1>
  86. <section1 topic='Requirements' anchor='reqs'>
  87. <p>The &caps; protocol aims to satisfy the following requirements:</p>
  88. <ol>
  89. <li>Entities must be able to participate even if they support only &xmppcore;, &xmppim; and &xep0030;<note>While elements of XEP-0300 are re-used here, full support of XEP-0300 is not formally required to implement this specification.</note>.</li>
  90. <li>Entities must be able to participate without connectivity to services except their own XMPP server and without connectivity to specialized XMPP services, including cached information from those services.</li>
  91. <li>Entities should be able to learn Service Discovery information without actively querying for it.</li>
  92. <li>The bandwidth consumption should be as minimal as possible, while reusing existing specifications.</li>
  93. <li>It must be possible to write &xep0045; and &xep0369; implementations which can forward this protocol with negligible extra work.</li>
  94. <li>Entities must be able to update their published information arbitrarily often in a single presence session.</li>
  95. <li>Server infrastructure beyond <cite>XMPP Core</cite> and <cite>XMPP IM</cite> must not be required for this to work (but may be beneficial).</li>
  96. <li>Entities must be able to be confident that the information obtained from the broadcast is equivalent to the information which would be obtained from querying the generating entity directly at the time the broadcast was generated.</li>
  97. <li>The protocol must be able to coexist (but not necessarily exchange information) with &xep0115;.</li>
  98. <li>No special XML features beyond what is needed to implement <cite>XMPP Core</cite> itself should be required.</li>
  99. <li>Obsoletion of hash functions should not need a new version of the specification.</li>
  100. <li>Support for pushing Entity Capabilities to the clients server without sending presence.</li>
  101. </ol>
  102. </section1>
  103. <section1 topic='Glossary' anchor='glossary'>
  104. <dl>
  105. <di><dt>Capability Hash</dt><dd>A tuple of hash function and hash value generated as described in the <link url='#algorithm'>Hash Function Input</link> section.</dd></di>
  106. <di><dt>Capability Hash Cache</dt><dd>A mapping which maps &hashes; to disco#info &lt;query/&gt; responses with an empty 'node' attribute.</dd></di>
  107. <di><dt>Cabability Hash Node</dt><dd>The name of a <cite>XEP-0030</cite> 'node' for a given &hash;. See <link url='#algorithm-hashnodes'>Construction of Capability Hash Nodes</link>.</dd></di>
  108. <di><dt>Capability Hash Set</dt><dd>A set of &hashes; which cover the same <cite>XEP-0030</cite> response, possibly in the form of a &lt;c/&gt; element with &xep0300; &lt;hash/&gt; children.</dd></di>
  109. <di><dt>Generating Entity</dt><dd>An entity which emits a &hashset; to other entities.</dd></di>
  110. <di><dt>Processing Entity</dt><dd>An entity which receives and processes a &hashset; from a &genent;.</dd></di>
  111. <di><dt>Query Interception</dt><dd>Server-side processing of disco#info queries directed to a resource based on the &hashsets; published by that resource.</dd></di>
  112. <di><dt>Gratuitous Capabilities</dt><dd>The sending of a &hashset; to a server before initial presence has been sent and without being asked by the server.</dd></di>
  113. </dl>
  114. </section1>
  115. <section1 topic='Algorithms' anchor='algorithm'>
  116. <p>The following algorithms provide data which is sent using this protocol.</p>
  117. <section2 topic='Hash Function Input' anchor='algorithm-input'>
  118. <p>The input to this algorithm is a &xep0030; disco#info &lt;query/&gt; response. The output is an octet string which can be used as input to a hash function or an error.</p>
  119. <div class="box"><p>General remarks:</p>
  120. <ul>
  121. <li><p>The algorithm strongly distinguishes between character data (sequences of Unicode code points) and octet strings (sequences of 8-bit bytes). Whenever character data is encoded to octet strings in the following algorithm, the UTF-8 as specified in &rfc3629; encoding is used. Whenever octet strings are sorted in the following algorithm, the i;octet collation as specified in &rfc4790; is used.</p></li>
  122. <li><p>The algorithm uses the <tt>xml:lang</tt> attribute. Implementations must take implicit values for the <tt>xml:lang</tt> attribute into account, for example those inherited from the disco#info or the IQ element.</p></li>
  123. </ul></div>
  124. <ol>
  125. <li>If the &lt;query/&gt; element contains any elements except &lt;identity/&gt;, &lt;feature/&gt; (both from the &xep0030; disco#info namespace) or &xep0128; data forms, abort with an error.</li>
  126. <li>If any &xep0128; &lt;x/&gt; element contains a data form which contains a &lt;reported/&gt; or &lt;item/&gt; element, abort with an error.</li>
  127. <li>If any &xep0128; &lt;x/&gt; element does not adhere to the "FORM_TYPE" protocol specified by &xep0068;, abort with an error.</li>
  128. <li><p>Processing of &lt;feature/&gt; elements:</p>
  129. <ol>
  130. <li>For each &lt;feature/&gt; element: Encode the character data of the 'var' attribute and append an octet of value &sepl4;</li>
  131. <li>Join the resulting octet strings together, ordered from lesser to greater.</li>
  132. <li>Append an octet of value &sepl1;.</li>
  133. </ol>
  134. <p>The result of this step is referenced as <em>Features String</em> later.</p>
  135. </li>
  136. <li><p>Processing of &lt;identity/&gt; nodes:</p>
  137. <ol>
  138. <li><p>For each &lt;identity/&gt; node:</p>
  139. <ol>
  140. <li>Encode the character data of the 'category', 'type', 'xml:lang' and 'name' attributes.</li>
  141. <li>Append an octet of value &sepl4; to each resulting octet string.</li>
  142. <li>Join the resulting octet strings together, in the order of 'category', 'type', 'xml:lang' and 'name', resulting in a single octet string for the &lt;identity/&gt; node.</li>
  143. <li>Append an octet of value &sepl3;.</li>
  144. </ol>
  145. </li>
  146. <li>Join the resulting octet strings together, ordered from lesser to greater.</li>
  147. <li>Append an octet of value &sepl1;.</li>
  148. </ol>
  149. <p>The result of this step is referenced as <em>Identities String</em> later.</p>
  150. </li>
  151. <li><p>Processing of &xep0128; &lt;x/&gt; elements:</p>
  152. <ol>
  153. <li><p>For each &lt;x/&gt; element:</p>
  154. <ol>
  155. <li><p>For each &lt;field/&gt; element:</p>
  156. <ol>
  157. <li>Encode the character data of each &lt;value/&gt; element and append an octet of value &sepl4;</li>
  158. <li>Join the resulting octet strings together, ordered from lesser to greater.</li>
  159. <li>Encode the character data of the 'var' attribute and append an octet of value &sepl4; and the result from the previous step.</li>
  160. <li>Append an octet of value &sepl3;.</li>
  161. </ol>
  162. </li>
  163. <li>Join the resulting octet strings together, ordered from lesser to greater.</li>
  164. <li>Append an octet of value &sepl2;.</li>
  165. </ol>
  166. </li>
  167. <li>Join the resulting octet strings together, ordered from lesser to greater.</li>
  168. <li>Append an octet of value &sepl1;.</li>
  169. </ol>
  170. <p>The result of this step is referenced as <em>Extensions String</em> later.</p>
  171. </li>
  172. <li>Join the <em>Features String</em>, <em>Identities String</em> and <em>Extensions String</em> together, in this order. Return the resulting string as result of the algorithm.</li>
  173. </ol>
  174. </section2>
  175. <section2 topic='Construction of Capability Hash Sets' anchor='algorithm-hashsets'>
  176. <p>The entity picks a set of hash functions it wishes to use. The set of hash functions MUST include at least one hash function which MUST be implemented according to &xep0300; and SHOULD NOT include any hash functions which MUST NOT be supported according to <cite>XEP-0300</cite>.</p>
  177. <p>Using the algorithm from the previous subsection, the entity calculates the input for the hash functions. It then runs the input through each hash function individually. The resulting tuples of hash algorithm and hash values constitute the &hashset;.</p>
  178. </section2>
  179. <section2 topic='Construction of Capability Hash Nodes' anchor='algorithm-hashnodes'>
  180. <p>The &hashnode; is obtained from a &hash; with the following simple algorithm:</p>
  181. <ol>
  182. <li>To the namespace prefix "urn:xmpp:caps#", append the name of the hash function as per &xep0300;.</li>
  183. <li>Append a &fullstop;.</li>
  184. <li>Append the Base64 encoded (as specified in &rfc3548;) hash value.</li>
  185. </ol>
  186. <p>The &hashnode; can be decomposed into its original components with the following algorithm:</p>
  187. <ol>
  188. <li>Remove the namespace prefix "urn:xmpp:caps#" from the input.</li>
  189. <li>From the <em>end</em> of the string, start searching for the &fullstop; separator.</li>
  190. <li>Split the string into the hash function and the Base64-encoded hash value at the position found in the previous step.</li>
  191. </ol>
  192. </section2>
  193. <section2 topic='Verification of a Capability Hash Set' anchor='algorithm-verify'>
  194. <p>The algorithm takes a &hashset; as input and returns successfully if the hash matches and an error otherwise.</p>
  195. <ol>
  196. <li>Pick a &hash; from the &hashset;.</li>
  197. <li>Query the &genent; for disco#info on the &hashnode; for the chosen hash like described above. If the entity returns an error, abort with an error.</li>
  198. <li>Locally calculate the &hash; using the same hash function as in the input as described in the algorithm. If the algorithm exits with an error, abort with an error.</li>
  199. <li>If the hashes do not match, abort with an error.</li>
  200. <li>Exit successfully, the hash is verified.</li>
  201. </ol>
  202. </section2>
  203. <section2 topic='Examples' anchor='algorithm-example'>
  204. <p>The two examples walk through the process of constructing a &hashset; for SHA-256 and SHA3-256. The full algorithm for generating the hash function input is explained.</p>
  205. <section3 topic='Simple Example' anchor='algorithm-example-simple'>
  206. <example caption='disco#info payload for the simple example; no XEP-0128 forms'><![CDATA[
  207. <query xmlns="http://jabber.org/protocol/disco#info">
  208. <identity category="client" name="BombusMod" type="mobile"/>
  209. <feature var="http://jabber.org/protocol/si"/>
  210. <feature var="http://jabber.org/protocol/bytestreams"/>
  211. <feature var="http://jabber.org/protocol/chatstates"/>
  212. <feature var="http://jabber.org/protocol/disco#info"/>
  213. <feature var="http://jabber.org/protocol/disco#items"/>
  214. <feature var="urn:xmpp:ping"/>
  215. <feature var="jabber:iq:time"/>
  216. <feature var="jabber:iq:privacy"/>
  217. <feature var="jabber:iq:version"/>
  218. <feature var="http://jabber.org/protocol/rosterx"/>
  219. <feature var="urn:xmpp:time"/>
  220. <feature var="jabber:x:oob"/>
  221. <feature var="http://jabber.org/protocol/ibb"/>
  222. <feature var="http://jabber.org/protocol/si/profile/file-transfer"/>
  223. <feature var="urn:xmpp:receipts"/>
  224. <feature var="jabber:iq:roster"/>
  225. <feature var="jabber:iq:last"/>
  226. </query>
  227. ]]></example>
  228. <p>The data from the example was the first entry in the &capsdb; hashes subdirectory which had no data forms at the time of writing. The features have been shuffled to show the sorting step in the algorithm.</p>
  229. <p>The algorithm starts by constructing the <em>Features String</em>. For this, the values of the 'var' attributes of the feature nodes are encoded as UTF-8 and suffixed with &sepl4;. The first three of those features are shown as a hexdump below:</p>
  230. <code>
  231. 00000000 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 |http://jabber.or|
  232. 00000010 67 2f 70 72 6f 74 6f 63 6f 6c 2f 73 69 1f |g/protocol/si.|
  233. 0000001e
  234. 00000000 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 |http://jabber.or|
  235. 00000010 67 2f 70 72 6f 74 6f 63 6f 6c 2f 62 79 74 65 73 |g/protocol/bytes|
  236. 00000020 74 72 65 61 6d 73 1f |treams.|
  237. 00000027
  238. 00000000 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 |http://jabber.or|
  239. 00000010 67 2f 70 72 6f 74 6f 63 6f 6c 2f 63 68 61 74 73 |g/protocol/chats|
  240. 00000020 74 61 74 65 73 1f |tates.|
  241. 00000026</code>
  242. <p>Note the appended 0x1f octet for each of the three strings. Now the strings are ordered using the i;octet collation and concatenated. The result is suffixed with &sepl1;, which gives the following hexdump of the final <em>Features String</em>:</p>
  243. <code>
  244. 00000000 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 |http://jabber.or|
  245. 00000010 67 2f 70 72 6f 74 6f 63 6f 6c 2f 62 79 74 65 73 |g/protocol/bytes|
  246. 00000020 74 72 65 61 6d 73 1f 68 74 74 70 3a 2f 2f 6a 61 |treams.http://ja|
  247. 00000030 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 6f 63 6f |bber.org/protoco|
  248. 00000040 6c 2f 63 68 61 74 73 74 61 74 65 73 1f 68 74 74 |l/chatstates.htt|
  249. 00000050 70 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 |p://jabber.org/p|
  250. 00000060 72 6f 74 6f 63 6f 6c 2f 64 69 73 63 6f 23 69 6e |rotocol/disco#in|
  251. 00000070 66 6f 1f 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 |fo.http://jabber|
  252. 00000080 2e 6f 72 67 2f 70 72 6f 74 6f 63 6f 6c 2f 64 69 |.org/protocol/di|
  253. 00000090 73 63 6f 23 69 74 65 6d 73 1f 68 74 74 70 3a 2f |sco#items.http:/|
  254. 000000a0 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 |/jabber.org/prot|
  255. 000000b0 6f 63 6f 6c 2f 69 62 62 1f 68 74 74 70 3a 2f 2f |ocol/ibb.http://|
  256. 000000c0 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 6f |jabber.org/proto|
  257. 000000d0 63 6f 6c 2f 72 6f 73 74 65 72 78 1f 68 74 74 70 |col/rosterx.http|
  258. 000000e0 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 |://jabber.org/pr|
  259. 000000f0 6f 74 6f 63 6f 6c 2f 73 69 1f 68 74 74 70 3a 2f |otocol/si.http:/|
  260. 00000100 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 |/jabber.org/prot|
  261. 00000110 6f 63 6f 6c 2f 73 69 2f 70 72 6f 66 69 6c 65 2f |ocol/si/profile/|
  262. 00000120 66 69 6c 65 2d 74 72 61 6e 73 66 65 72 1f 6a 61 |file-transfer.ja|
  263. 00000130 62 62 65 72 3a 69 71 3a 6c 61 73 74 1f 6a 61 62 |bber:iq:last.jab|
  264. 00000140 62 65 72 3a 69 71 3a 70 72 69 76 61 63 79 1f 6a |ber:iq:privacy.j|
  265. 00000150 61 62 62 65 72 3a 69 71 3a 72 6f 73 74 65 72 1f |abber:iq:roster.|
  266. 00000160 6a 61 62 62 65 72 3a 69 71 3a 74 69 6d 65 1f 6a |jabber:iq:time.j|
  267. 00000170 61 62 62 65 72 3a 69 71 3a 76 65 72 73 69 6f 6e |abber:iq:version|
  268. 00000180 1f 6a 61 62 62 65 72 3a 78 3a 6f 6f 62 1f 75 72 |.jabber:x:oob.ur|
  269. 00000190 6e 3a 78 6d 70 70 3a 70 69 6e 67 1f 75 72 6e 3a |n:xmpp:ping.urn:|
  270. 000001a0 78 6d 70 70 3a 72 65 63 65 69 70 74 73 1f 75 72 |xmpp:receipts.ur|
  271. 000001b0 6e 3a 78 6d 70 70 3a 74 69 6d 65 1f 1c |n:xmpp:time..|
  272. 000001bd</code>
  273. <p>For the <em>Identities String</em>, first the character data of the 'category', 'type', 'xml:lang' and 'name' attributes is encoded as UTF-8 and suffixed with &sepl4;. The resulting individual strings have the following hexdumps:</p>
  274. <code>
  275. 00000000 63 6c 69 65 6e 74 1f |client.|
  276. 00000007
  277. 00000000 6d 6f 62 69 6c 65 1f |mobile.|
  278. 00000007
  279. 00000000 1f |.|
  280. 00000001
  281. 00000000 42 6f 6d 62 75 73 4d 6f 64 1f |BombusMod.|
  282. 0000000a</code>
  283. <p>The strings are now joined together and the result is suffixed with &sepl3;:</p>
  284. <code>
  285. 00000000 63 6c 69 65 6e 74 1f 6d 6f 62 69 6c 65 1f 1f 42 |client.mobile..B|
  286. 00000010 6f 6d 62 75 73 4d 6f 64 1f 1e |ombusMod..|
  287. 0000001a</code>
  288. <p>Normally, a sorting step would occur here. As the example only has a single string, the sorting and joining is a no-op. The string is now suffixed with &sepl1; to get the <em>Identities String</em>:</p>
  289. <code>
  290. 00000000 63 6c 69 65 6e 74 1f 6d 6f 62 69 6c 65 1f 1f 42 |client.mobile..B|
  291. 00000010 6f 6d 62 75 73 4d 6f 64 1f 1e 1c |ombusMod...|
  292. 0000001b</code>
  293. <p>The <em>Extensions String</em> is simply the &sepl1; used to terminate it as no extensions are contained in the example. Thus, the final input for the hash function is, as hexdump:</p>
  294. <code>
  295. 00000000 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 |http://jabber.or|
  296. 00000010 67 2f 70 72 6f 74 6f 63 6f 6c 2f 62 79 74 65 73 |g/protocol/bytes|
  297. 00000020 74 72 65 61 6d 73 1f 68 74 74 70 3a 2f 2f 6a 61 |treams.http://ja|
  298. 00000030 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 6f 63 6f |bber.org/protoco|
  299. 00000040 6c 2f 63 68 61 74 73 74 61 74 65 73 1f 68 74 74 |l/chatstates.htt|
  300. 00000050 70 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 |p://jabber.org/p|
  301. 00000060 72 6f 74 6f 63 6f 6c 2f 64 69 73 63 6f 23 69 6e |rotocol/disco#in|
  302. 00000070 66 6f 1f 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 |fo.http://jabber|
  303. 00000080 2e 6f 72 67 2f 70 72 6f 74 6f 63 6f 6c 2f 64 69 |.org/protocol/di|
  304. 00000090 73 63 6f 23 69 74 65 6d 73 1f 68 74 74 70 3a 2f |sco#items.http:/|
  305. 000000a0 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 |/jabber.org/prot|
  306. 000000b0 6f 63 6f 6c 2f 69 62 62 1f 68 74 74 70 3a 2f 2f |ocol/ibb.http://|
  307. 000000c0 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 6f |jabber.org/proto|
  308. 000000d0 63 6f 6c 2f 72 6f 73 74 65 72 78 1f 68 74 74 70 |col/rosterx.http|
  309. 000000e0 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 |://jabber.org/pr|
  310. 000000f0 6f 74 6f 63 6f 6c 2f 73 69 1f 68 74 74 70 3a 2f |otocol/si.http:/|
  311. 00000100 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 |/jabber.org/prot|
  312. 00000110 6f 63 6f 6c 2f 73 69 2f 70 72 6f 66 69 6c 65 2f |ocol/si/profile/|
  313. 00000120 66 69 6c 65 2d 74 72 61 6e 73 66 65 72 1f 6a 61 |file-transfer.ja|
  314. 00000130 62 62 65 72 3a 69 71 3a 6c 61 73 74 1f 6a 61 62 |bber:iq:last.jab|
  315. 00000140 62 65 72 3a 69 71 3a 70 72 69 76 61 63 79 1f 6a |ber:iq:privacy.j|
  316. 00000150 61 62 62 65 72 3a 69 71 3a 72 6f 73 74 65 72 1f |abber:iq:roster.|
  317. 00000160 6a 61 62 62 65 72 3a 69 71 3a 74 69 6d 65 1f 6a |jabber:iq:time.j|
  318. 00000170 61 62 62 65 72 3a 69 71 3a 76 65 72 73 69 6f 6e |abber:iq:version|
  319. 00000180 1f 6a 61 62 62 65 72 3a 78 3a 6f 6f 62 1f 75 72 |.jabber:x:oob.ur|
  320. 00000190 6e 3a 78 6d 70 70 3a 70 69 6e 67 1f 75 72 6e 3a |n:xmpp:ping.urn:|
  321. 000001a0 78 6d 70 70 3a 72 65 63 65 69 70 74 73 1f 75 72 |xmpp:receipts.ur|
  322. 000001b0 6e 3a 78 6d 70 70 3a 74 69 6d 65 1f 1c 63 6c 69 |n:xmpp:time..cli|
  323. 000001c0 65 6e 74 1f 6d 6f 62 69 6c 65 1f 1f 42 6f 6d 62 |ent.mobile..Bomb|
  324. 000001d0 75 73 4d 6f 64 1f 1e 1c 1c |usMod....|
  325. 000001d9</code>
  326. <p>Running this octet string through the hash functions leads as to the following &hashset;:</p>
  327. <code><![CDATA[
  328. <c xmlns="urn:xmpp:caps">
  329. <hash xmlns="urn:xmpp:hashes:2" algo="sha-256">kzBZbkqJ3ADrj7v08reD1qcWUwNGHaidNUgD7nHpiw8=</hash>
  330. <hash xmlns="urn:xmpp:hashes:2" algo="sha3-256">79mdYAfU9rEdTOcWDO7UEAt6E56SUzk/g6TnqUeuD9Q=</hash>
  331. </c>]]></code>
  332. </section3>
  333. <section3 topic='Complex Example' anchor='algorithm-examples-complex'>
  334. <example caption='disco#info payload for the complex example with XEP-0128 forms'><![CDATA[
  335. <query xmlns="http://jabber.org/protocol/disco#info">
  336. <identity category="client" name="Tkabber" type="pc" xml:lang="en"/>
  337. <identity category="client" name="Ткаббер" type="pc" xml:lang="ru"/>
  338. <feature var="games:board"/>
  339. <feature var="http://jabber.org/protocol/activity"/>
  340. <feature var="http://jabber.org/protocol/activity+notify"/>
  341. <feature var="http://jabber.org/protocol/bytestreams"/>
  342. <feature var="http://jabber.org/protocol/chatstates"/>
  343. <feature var="http://jabber.org/protocol/commands"/>
  344. <feature var="http://jabber.org/protocol/disco#info"/>
  345. <feature var="http://jabber.org/protocol/disco#items"/>
  346. <feature var="http://jabber.org/protocol/evil"/>
  347. <feature var="http://jabber.org/protocol/feature-neg"/>
  348. <feature var="http://jabber.org/protocol/geoloc"/>
  349. <feature var="http://jabber.org/protocol/geoloc+notify"/>
  350. <feature var="http://jabber.org/protocol/ibb"/>
  351. <feature var="http://jabber.org/protocol/iqibb"/>
  352. <feature var="http://jabber.org/protocol/mood"/>
  353. <feature var="http://jabber.org/protocol/mood+notify"/>
  354. <feature var="http://jabber.org/protocol/rosterx"/>
  355. <feature var="http://jabber.org/protocol/si"/>
  356. <feature var="http://jabber.org/protocol/si/profile/file-transfer"/>
  357. <feature var="http://jabber.org/protocol/tune"/>
  358. <feature var="http://www.facebook.com/xmpp/messages"/>
  359. <feature var="http://www.xmpp.org/extensions/xep-0084.html#ns-metadata+notify"/>
  360. <feature var="jabber:iq:avatar"/>
  361. <feature var="jabber:iq:browse"/>
  362. <feature var="jabber:iq:dtcp"/>
  363. <feature var="jabber:iq:filexfer"/>
  364. <feature var="jabber:iq:ibb"/>
  365. <feature var="jabber:iq:inband"/>
  366. <feature var="jabber:iq:jidlink"/>
  367. <feature var="jabber:iq:last"/>
  368. <feature var="jabber:iq:oob"/>
  369. <feature var="jabber:iq:privacy"/>
  370. <feature var="jabber:iq:roster"/>
  371. <feature var="jabber:iq:time"/>
  372. <feature var="jabber:iq:version"/>
  373. <feature var="jabber:x:data"/>
  374. <feature var="jabber:x:event"/>
  375. <feature var="jabber:x:oob"/>
  376. <feature var="urn:xmpp:avatar:metadata+notify"/>
  377. <feature var="urn:xmpp:ping"/>
  378. <feature var="urn:xmpp:receipts"/>
  379. <feature var="urn:xmpp:time"/>
  380. <x xmlns="jabber:x:data" type="result">
  381. <field type="hidden" var="FORM_TYPE">
  382. <value>urn:xmpp:dataforms:softwareinfo</value>
  383. </field>
  384. <field var="software">
  385. <value>Tkabber</value>
  386. </field>
  387. <field var="software_version">
  388. <value>0.11.1-svn-20111216-mod (Tcl/Tk 8.6b2)</value>
  389. </field>
  390. <field var="os">
  391. <value>Windows</value>
  392. </field>
  393. <field var="os_version">
  394. <value>XP</value>
  395. </field>
  396. </x>
  397. </query>
  398. ]]></example>
  399. <p>The data from the example is the shortest entry from the &capsdb; hashes subdirectory which had data forms and multiple identities at the time of writing. The features have been shuffled to show the sorting step in the algorithm.</p>
  400. <p>We skip over the process for the <em>Features String</em> and only present the final result encoded as base64 for reference:</p>
  401. <code>
  402. Z2FtZXM6Ym9hcmQfaHR0cDovL2phYmJlci5vcmcvcHJvdG9jb2wvYWN0aXZpdHkfaHR0cDovL2ph
  403. YmJlci5vcmcvcHJvdG9jb2wvYWN0aXZpdHkrbm90aWZ5H2h0dHA6Ly9qYWJiZXIub3JnL3Byb3Rv
  404. Y29sL2J5dGVzdHJlYW1zH2h0dHA6Ly9qYWJiZXIub3JnL3Byb3RvY29sL2NoYXRzdGF0ZXMfaHR0
  405. cDovL2phYmJlci5vcmcvcHJvdG9jb2wvY29tbWFuZHMfaHR0cDovL2phYmJlci5vcmcvcHJvdG9j
  406. b2wvZGlzY28jaW5mbx9odHRwOi8vamFiYmVyLm9yZy9wcm90b2NvbC9kaXNjbyNpdGVtcx9odHRw
  407. Oi8vamFiYmVyLm9yZy9wcm90b2NvbC9ldmlsH2h0dHA6Ly9qYWJiZXIub3JnL3Byb3RvY29sL2Zl
  408. YXR1cmUtbmVnH2h0dHA6Ly9qYWJiZXIub3JnL3Byb3RvY29sL2dlb2xvYx9odHRwOi8vamFiYmVy
  409. Lm9yZy9wcm90b2NvbC9nZW9sb2Mrbm90aWZ5H2h0dHA6Ly9qYWJiZXIub3JnL3Byb3RvY29sL2li
  410. Yh9odHRwOi8vamFiYmVyLm9yZy9wcm90b2NvbC9pcWliYh9odHRwOi8vamFiYmVyLm9yZy9wcm90
  411. b2NvbC9tb29kH2h0dHA6Ly9qYWJiZXIub3JnL3Byb3RvY29sL21vb2Qrbm90aWZ5H2h0dHA6Ly9q
  412. YWJiZXIub3JnL3Byb3RvY29sL3Jvc3RlcngfaHR0cDovL2phYmJlci5vcmcvcHJvdG9jb2wvc2kf
  413. aHR0cDovL2phYmJlci5vcmcvcHJvdG9jb2wvc2kvcHJvZmlsZS9maWxlLXRyYW5zZmVyH2h0dHA6
  414. Ly9qYWJiZXIub3JnL3Byb3RvY29sL3R1bmUfaHR0cDovL3d3dy5mYWNlYm9vay5jb20veG1wcC9t
  415. ZXNzYWdlcx9odHRwOi8vd3d3LnhtcHAub3JnL2V4dGVuc2lvbnMveGVwLTAwODQuaHRtbCNucy1t
  416. ZXRhZGF0YStub3RpZnkfamFiYmVyOmlxOmF2YXRhch9qYWJiZXI6aXE6YnJvd3NlH2phYmJlcjpp
  417. cTpkdGNwH2phYmJlcjppcTpmaWxleGZlch9qYWJiZXI6aXE6aWJiH2phYmJlcjppcTppbmJhbmQf
  418. amFiYmVyOmlxOmppZGxpbmsfamFiYmVyOmlxOmxhc3QfamFiYmVyOmlxOm9vYh9qYWJiZXI6aXE6
  419. cHJpdmFjeR9qYWJiZXI6aXE6cm9zdGVyH2phYmJlcjppcTp0aW1lH2phYmJlcjppcTp2ZXJzaW9u
  420. H2phYmJlcjp4OmRhdGEfamFiYmVyOng6ZXZlbnQfamFiYmVyOng6b29iH3Vybjp4bXBwOmF2YXRh
  421. cjptZXRhZGF0YStub3RpZnkfdXJuOnhtcHA6cGluZx91cm46eG1wcDpyZWNlaXB0cx91cm46eG1w
  422. cDp0aW1lHxw=</code>
  423. <p>In the previous example, it was already shown how the individual parts of each &lt;identity/&gt; element are combined. We get the following octet strings as hexdumps:</p>
  424. <code>
  425. 00000000 63 6c 69 65 6e 74 1f 70 63 1f 72 75 1f d0 a2 d0 |client.pc.ru....|
  426. 00000010 ba d0 b0 d0 b1 d0 b1 d0 b5 d1 80 1f 1e |.............|
  427. 0000001d
  428. 00000000 63 6c 69 65 6e 74 1f 70 63 1f 65 6e 1f 54 6b 61 |client.pc.en.Tka|
  429. 00000010 62 62 65 72 1f 1e |bber..|
  430. 00000016</code>
  431. <p>The second string is ordered before the first string in the i;octet collation and afterwards the strings are joined and the result is suffixed with &sepl1; to close the identities part of the input. The final <em>Identities String</em> is thus, as hexdump:</p>
  432. <code>
  433. 00000000 63 6c 69 65 6e 74 1f 70 63 1f 65 6e 1f 54 6b 61 |client.pc.en.Tka|
  434. 00000010 62 62 65 72 1f 1e 63 6c 69 65 6e 74 1f 70 63 1f |bber..client.pc.|
  435. 00000020 72 75 1f d0 a2 d0 ba d0 b0 d0 b1 d0 b1 d0 b5 d1 |ru..............|
  436. 00000030 80 1f 1e 1c |....|
  437. 00000034</code>
  438. <p>The example has a &xep0128; form. For each field, a string consisting of the 'var' attributes character data and the values is created as per the algorithm:</p>
  439. <code>
  440. 00000000 46 4f 52 4d 5f 54 59 50 45 1f 75 72 6e 3a 78 6d |FORM_TYPE.urn:xm|
  441. 00000010 70 70 3a 64 61 74 61 66 6f 72 6d 73 3a 73 6f 66 |pp:dataforms:sof|
  442. 00000020 74 77 61 72 65 69 6e 66 6f 1f 1e |twareinfo..|
  443. 0000002b
  444. 00000000 73 6f 66 74 77 61 72 65 1f 54 6b 61 62 62 65 72 |software.Tkabber|
  445. 00000010 1f 1e |..|
  446. 00000012
  447. 00000000 73 6f 66 74 77 61 72 65 5f 76 65 72 73 69 6f 6e |software_version|
  448. 00000010 1f 30 2e 31 31 2e 31 2d 73 76 6e 2d 32 30 31 31 |.0.11.1-svn-2011|
  449. 00000020 31 32 31 36 2d 6d 6f 64 20 28 54 63 6c 2f 54 6b |1216-mod (Tcl/Tk|
  450. 00000030 20 38 2e 36 62 32 29 1f 1e | 8.6b2)..|
  451. 00000039
  452. 00000000 6f 73 1f 57 69 6e 64 6f 77 73 1f 1e |os.Windows..|
  453. 0000000c
  454. </code>
  455. <p>The strings need to be sorted using i;octet and joined together. The result is suffixed with &sepl2;, which closes the form. As this is the only form, the resulting <em>Extensions String</em> is obtained by adding a &sepl1; to close the extensions section of the hash input:</p>
  456. <code>
  457. 00000000 46 4f 52 4d 5f 54 59 50 45 1f 75 72 6e 3a 78 6d |FORM_TYPE.urn:xm|
  458. 00000010 70 70 3a 64 61 74 61 66 6f 72 6d 73 3a 73 6f 66 |pp:dataforms:sof|
  459. 00000020 74 77 61 72 65 69 6e 66 6f 1f 1e 6f 73 1f 57 69 |twareinfo..os.Wi|
  460. 00000030 6e 64 6f 77 73 1f 1e 6f 73 5f 76 65 72 73 69 6f |ndows..os_versio|
  461. 00000040 6e 1f 58 50 1f 1e 73 6f 66 74 77 61 72 65 1f 54 |n.XP..software.T|
  462. 00000050 6b 61 62 62 65 72 1f 1e 73 6f 66 74 77 61 72 65 |kabber..software|
  463. 00000060 5f 76 65 72 73 69 6f 6e 1f 30 2e 31 31 2e 31 2d |_version.0.11.1-|
  464. 00000070 73 76 6e 2d 32 30 31 31 31 32 31 36 2d 6d 6f 64 |svn-20111216-mod|
  465. 00000080 20 28 54 63 6c 2f 54 6b 20 38 2e 36 62 32 29 1f | (Tcl/Tk 8.6b2).|
  466. 00000090 1e 1d 1c |...|
  467. 00000093</code>
  468. <p>Note the "os" field is now before the other fields but after "FORM_TYPE", due to the sorting.</p>
  469. <p>The final hash function input is obtained by concatenating the <em>Features String</em>, <em>Identities String</em> and <em>Extensions String</em>:</p>
  470. <code>
  471. 00000000 67 61 6d 65 73 3a 62 6f 61 72 64 1f 68 74 74 70 |games:board.http|
  472. 00000010 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 |://jabber.org/pr|
  473. 00000020 6f 74 6f 63 6f 6c 2f 61 63 74 69 76 69 74 79 1f |otocol/activity.|
  474. 00000030 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 |http://jabber.or|
  475. 00000040 67 2f 70 72 6f 74 6f 63 6f 6c 2f 61 63 74 69 76 |g/protocol/activ|
  476. 00000050 69 74 79 2b 6e 6f 74 69 66 79 1f 68 74 74 70 3a |ity+notify.http:|
  477. 00000060 2f 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f |//jabber.org/pro|
  478. 00000070 74 6f 63 6f 6c 2f 62 79 74 65 73 74 72 65 61 6d |tocol/bytestream|
  479. 00000080 73 1f 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 2e |s.http://jabber.|
  480. 00000090 6f 72 67 2f 70 72 6f 74 6f 63 6f 6c 2f 63 68 61 |org/protocol/cha|
  481. 000000a0 74 73 74 61 74 65 73 1f 68 74 74 70 3a 2f 2f 6a |tstates.http://j|
  482. 000000b0 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 6f 63 |abber.org/protoc|
  483. 000000c0 6f 6c 2f 63 6f 6d 6d 61 6e 64 73 1f 68 74 74 70 |ol/commands.http|
  484. 000000d0 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 |://jabber.org/pr|
  485. 000000e0 6f 74 6f 63 6f 6c 2f 64 69 73 63 6f 23 69 6e 66 |otocol/disco#inf|
  486. 000000f0 6f 1f 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 2e |o.http://jabber.|
  487. 00000100 6f 72 67 2f 70 72 6f 74 6f 63 6f 6c 2f 64 69 73 |org/protocol/dis|
  488. 00000110 63 6f 23 69 74 65 6d 73 1f 68 74 74 70 3a 2f 2f |co#items.http://|
  489. 00000120 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 6f |jabber.org/proto|
  490. 00000130 63 6f 6c 2f 65 76 69 6c 1f 68 74 74 70 3a 2f 2f |col/evil.http://|
  491. 00000140 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 6f |jabber.org/proto|
  492. 00000150 63 6f 6c 2f 66 65 61 74 75 72 65 2d 6e 65 67 1f |col/feature-neg.|
  493. 00000160 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 2e 6f 72 |http://jabber.or|
  494. 00000170 67 2f 70 72 6f 74 6f 63 6f 6c 2f 67 65 6f 6c 6f |g/protocol/geolo|
  495. 00000180 63 1f 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 2e |c.http://jabber.|
  496. 00000190 6f 72 67 2f 70 72 6f 74 6f 63 6f 6c 2f 67 65 6f |org/protocol/geo|
  497. 000001a0 6c 6f 63 2b 6e 6f 74 69 66 79 1f 68 74 74 70 3a |loc+notify.http:|
  498. 000001b0 2f 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f |//jabber.org/pro|
  499. 000001c0 74 6f 63 6f 6c 2f 69 62 62 1f 68 74 74 70 3a 2f |tocol/ibb.http:/|
  500. 000001d0 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 |/jabber.org/prot|
  501. 000001e0 6f 63 6f 6c 2f 69 71 69 62 62 1f 68 74 74 70 3a |ocol/iqibb.http:|
  502. 000001f0 2f 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f |//jabber.org/pro|
  503. 00000200 74 6f 63 6f 6c 2f 6d 6f 6f 64 1f 68 74 74 70 3a |tocol/mood.http:|
  504. 00000210 2f 2f 6a 61 62 62 65 72 2e 6f 72 67 2f 70 72 6f |//jabber.org/pro|
  505. 00000220 74 6f 63 6f 6c 2f 6d 6f 6f 64 2b 6e 6f 74 69 66 |tocol/mood+notif|
  506. 00000230 79 1f 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 2e |y.http://jabber.|
  507. 00000240 6f 72 67 2f 70 72 6f 74 6f 63 6f 6c 2f 72 6f 73 |org/protocol/ros|
  508. 00000250 74 65 72 78 1f 68 74 74 70 3a 2f 2f 6a 61 62 62 |terx.http://jabb|
  509. 00000260 65 72 2e 6f 72 67 2f 70 72 6f 74 6f 63 6f 6c 2f |er.org/protocol/|
  510. 00000270 73 69 1f 68 74 74 70 3a 2f 2f 6a 61 62 62 65 72 |si.http://jabber|
  511. 00000280 2e 6f 72 67 2f 70 72 6f 74 6f 63 6f 6c 2f 73 69 |.org/protocol/si|
  512. 00000290 2f 70 72 6f 66 69 6c 65 2f 66 69 6c 65 2d 74 72 |/profile/file-tr|
  513. 000002a0 61 6e 73 66 65 72 1f 68 74 74 70 3a 2f 2f 6a 61 |ansfer.http://ja|
  514. 000002b0 62 62 65 72 2e 6f 72 67 2f 70 72 6f 74 6f 63 6f |bber.org/protoco|
  515. 000002c0 6c 2f 74 75 6e 65 1f 68 74 74 70 3a 2f 2f 77 77 |l/tune.http://ww|
  516. 000002d0 77 2e 66 61 63 65 62 6f 6f 6b 2e 63 6f 6d 2f 78 |w.facebook.com/x|
  517. 000002e0 6d 70 70 2f 6d 65 73 73 61 67 65 73 1f 68 74 74 |mpp/messages.htt|
  518. 000002f0 70 3a 2f 2f 77 77 77 2e 78 6d 70 70 2e 6f 72 67 |p://www.xmpp.org|
  519. 00000300 2f 65 78 74 65 6e 73 69 6f 6e 73 2f 78 65 70 2d |/extensions/xep-|
  520. 00000310 30 30 38 34 2e 68 74 6d 6c 23 6e 73 2d 6d 65 74 |0084.html#ns-met|
  521. 00000320 61 64 61 74 61 2b 6e 6f 74 69 66 79 1f 6a 61 62 |adata+notify.jab|
  522. 00000330 62 65 72 3a 69 71 3a 61 76 61 74 61 72 1f 6a 61 |ber:iq:avatar.ja|
  523. 00000340 62 62 65 72 3a 69 71 3a 62 72 6f 77 73 65 1f 6a |bber:iq:browse.j|
  524. 00000350 61 62 62 65 72 3a 69 71 3a 64 74 63 70 1f 6a 61 |abber:iq:dtcp.ja|
  525. 00000360 62 62 65 72 3a 69 71 3a 66 69 6c 65 78 66 65 72 |bber:iq:filexfer|
  526. 00000370 1f 6a 61 62 62 65 72 3a 69 71 3a 69 62 62 1f 6a |.jabber:iq:ibb.j|
  527. 00000380 61 62 62 65 72 3a 69 71 3a 69 6e 62 61 6e 64 1f |abber:iq:inband.|
  528. 00000390 6a 61 62 62 65 72 3a 69 71 3a 6a 69 64 6c 69 6e |jabber:iq:jidlin|
  529. 000003a0 6b 1f 6a 61 62 62 65 72 3a 69 71 3a 6c 61 73 74 |k.jabber:iq:last|
  530. 000003b0 1f 6a 61 62 62 65 72 3a 69 71 3a 6f 6f 62 1f 6a |.jabber:iq:oob.j|
  531. 000003c0 61 62 62 65 72 3a 69 71 3a 70 72 69 76 61 63 79 |abber:iq:privacy|
  532. 000003d0 1f 6a 61 62 62 65 72 3a 69 71 3a 72 6f 73 74 65 |.jabber:iq:roste|
  533. 000003e0 72 1f 6a 61 62 62 65 72 3a 69 71 3a 74 69 6d 65 |r.jabber:iq:time|
  534. 000003f0 1f 6a 61 62 62 65 72 3a 69 71 3a 76 65 72 73 69 |.jabber:iq:versi|
  535. 00000400 6f 6e 1f 6a 61 62 62 65 72 3a 78 3a 64 61 74 61 |on.jabber:x:data|
  536. 00000410 1f 6a 61 62 62 65 72 3a 78 3a 65 76 65 6e 74 1f |.jabber:x:event.|
  537. 00000420 6a 61 62 62 65 72 3a 78 3a 6f 6f 62 1f 75 72 6e |jabber:x:oob.urn|
  538. 00000430 3a 78 6d 70 70 3a 61 76 61 74 61 72 3a 6d 65 74 |:xmpp:avatar:met|
  539. 00000440 61 64 61 74 61 2b 6e 6f 74 69 66 79 1f 75 72 6e |adata+notify.urn|
  540. 00000450 3a 78 6d 70 70 3a 70 69 6e 67 1f 75 72 6e 3a 78 |:xmpp:ping.urn:x|
  541. 00000460 6d 70 70 3a 72 65 63 65 69 70 74 73 1f 75 72 6e |mpp:receipts.urn|
  542. 00000470 3a 78 6d 70 70 3a 74 69 6d 65 1f 1c 63 6c 69 65 |:xmpp:time..clie|
  543. 00000480 6e 74 1f 70 63 1f 65 6e 1f 54 6b 61 62 62 65 72 |nt.pc.en.Tkabber|
  544. 00000490 1f 1e 63 6c 69 65 6e 74 1f 70 63 1f 72 75 1f d0 |..client.pc.ru..|
  545. 000004a0 a2 d0 ba d0 b0 d0 b1 d0 b1 d0 b5 d1 80 1f 1e 1c |................|
  546. 000004b0 46 4f 52 4d 5f 54 59 50 45 1f 75 72 6e 3a 78 6d |FORM_TYPE.urn:xm|
  547. 000004c0 70 70 3a 64 61 74 61 66 6f 72 6d 73 3a 73 6f 66 |pp:dataforms:sof|
  548. 000004d0 74 77 61 72 65 69 6e 66 6f 1f 1e 6f 73 1f 57 69 |twareinfo..os.Wi|
  549. 000004e0 6e 64 6f 77 73 1f 1e 6f 73 5f 76 65 72 73 69 6f |ndows..os_versio|
  550. 000004f0 6e 1f 58 50 1f 1e 73 6f 66 74 77 61 72 65 1f 54 |n.XP..software.T|
  551. 00000500 6b 61 62 62 65 72 1f 1e 73 6f 66 74 77 61 72 65 |kabber..software|
  552. 00000510 5f 76 65 72 73 69 6f 6e 1f 30 2e 31 31 2e 31 2d |_version.0.11.1-|
  553. 00000520 73 76 6e 2d 32 30 31 31 31 32 31 36 2d 6d 6f 64 |svn-20111216-mod|
  554. 00000530 20 28 54 63 6c 2f 54 6b 20 38 2e 36 62 32 29 1f | (Tcl/Tk 8.6b2).|
  555. 00000540 1e 1d 1c |...|
  556. 00000543</code>
  557. <p>Feeding the concatenated octet string as input to the hash functions yields the following &hashset;:</p>
  558. <code><![CDATA[
  559. <c xmlns="urn:xmpp:caps">
  560. <hash xmlns="urn:xmpp:hashes:2" algo="sha-256">u79ZroNJbdSWhdSp311mddz44oHHPsEBntQ5b1jqBSY=</hash>
  561. <hash xmlns="urn:xmpp:hashes:2" algo="sha3-256">XpUJzLAc93258sMECZ3FJpebkzuyNXDzRNwQog8eycg=</hash>
  562. </c>]]></code>
  563. </section3>
  564. </section2>
  565. </section1>
  566. <section1 topic='Use Cases' anchor='usecases'>
  567. <section2 topic='Advertising Support' anchor='usecases-support'>
  568. <p>If an entity supports &caps;, it MUST advertise the fact by returning a feature of "urn:xmpp:caps".</p>
  569. <example caption='Response to a disco#info request'><![CDATA[
  570. <iq from='romeo@montague.lit/orchard'
  571. id='disco1'
  572. to='juliet@capulet.lit/chamber'
  573. type='result'>
  574. <query xmlns='http://jabber.org/protocol/disco#info'>
  575. ...
  576. <feature var='urn:xmpp:caps'/>
  577. ...
  578. </query>
  579. </iq>
  580. ]]></example>
  581. </section2>
  582. <section2 topic='Advertisement of Support and Capabilities by Servers' anchor='usecases-stream-feature'>
  583. <p>A server MAY advertise its support for this protocol as well as the current hashes in the stream features.</p>
  584. <example caption='Stream Features of a server'><![CDATA[
  585. <stream:features>
  586. ...
  587. <c xmlns="urn:xmpp:caps">
  588. <hash xmlns="urn:xmpp:hashes:2" algo="sha-256">K1Njy3HZBThlo4moOD5gBGhn0U0oK7/CbfLlIUDi6o4=</hash>
  589. <hash xmlns="urn:xmpp:hashes:2" algo="sha3-256">+sDTQqBmX6iG/X3zjt06fjZMBBqL/723knFIyRf0sg8=</hash>
  590. </c>
  591. ...
  592. </stream:features>
  593. ]]></example>
  594. <p>When a connected client or peer server sends a service discovery information request to determine the entity capabilities of a server that advertises capabilities via the stream feature, the requesting entity MUST send the disco#info request to the server's JID as provided in the 'from' attribute of the response stream header. To enable this functionality, a server that advertises support for entity capabilities MUST provide a 'from' address in its response stream headers, in accordance with &rfc6120;.</p>
  595. </section2>
  596. <section2 topic='Advertising Support of Caps Optimizations' anchor='usecases-support'>
  597. <p>If a server supports Caps Optimizations, it MUST advertise the fact by returning a feature of "urn:xmpp:caps:optimize".</p>
  598. <example caption='Response to a disco#info request'><![CDATA[
  599. <iq from='montague.lit'
  600. id='disco2'
  601. to='romeo@montague.lit/chamber'
  602. type='result'>
  603. <query xmlns='http://jabber.org/protocol/disco#info'>
  604. ...
  605. <feature var='urn:xmpp:caps'/>
  606. <feature var='urn:xmpp:caps:optimize'/>
  607. ...
  608. </query>
  609. </iq>
  610. ]]></example>
  611. </section2>
  612. <section2 topic='Broadcasting Entity Capabilities' anchor='usecases-broadcast'>
  613. <p>An entity publishes the current &hashset; in presence stanzas it sends:</p>
  614. <example caption='Presence broadcast with hashes'><![CDATA[
  615. <presence from='juliet@capulet.lit'>
  616. <c xmlns="urn:xmpp:caps">
  617. <hash xmlns="urn:xmpp:hashes:2" algo="sha-256">u79ZroNJbdSWhdSp311mddz44oHHPsEBntQ5b1jqBSY=</hash>
  618. <hash xmlns="urn:xmpp:hashes:2" algo="sha3-256">XpUJzLAc93258sMECZ3FJpebkzuyNXDzRNwQog8eycg=</hash>
  619. </c>
  620. </presence>
  621. ]]></example>
  622. <p>The &lt;hash/&gt; element is specified by &xep0300; and is used to transport the &hashes;.</p>
  623. </section2>
  624. <section2 topic='Service Discovery Query for a Specific Hash Value' anchor='usecases-hash-query'>
  625. <p>To query the &xep0030; information for a specific &hash; value, an entity MUST query a Service Discovery node equal to the &hashnode;<note>As outlined in the Business Rules, this statement does not oblige an entity to actually perform this query.</note>.</p>
  626. <p>An entity is free to choose for which &hash; of a &hashset; the request is sent.</p>
  627. <example caption='Service Discovery request in response to a broadcast Capability Hash Set'><![CDATA[
  628. <presence from='juliet@capulet.lit/chamber' to='romeo@montague.lit/orchard'>
  629. <c xmlns="urn:xmpp:caps">
  630. <hash xmlns="urn:xmpp:hashes:2" algo="sha-256">u79ZroNJbdSWhdSp311mddz44oHHPsEBntQ5b1jqBSY=</hash>
  631. <hash xmlns="urn:xmpp:hashes:2" algo="sha3-256">XpUJzLAc93258sMECZ3FJpebkzuyNXDzRNwQog8eycg=</hash>
  632. </c>
  633. </presence>
  634. <iq from='romeo@montague.lit/orchard'
  635. id='disco3'
  636. to='juliet@capulet.lit/chamber'
  637. type='get'>
  638. <query xmlns='http://jabber.org/protocol/disco#info'
  639. node='urn:xmpp:caps#sha-256.u79ZroNJbdSWhdSp311mddz44oHHPsEBntQ5b1jqBSY='/>
  640. </iq>
  641. <iq from='juliet@capulet.lit/chamber'
  642. id='disco3'
  643. to='romeo@montague.lit/orchard'
  644. type='result'>
  645. <query xmlns='http://jabber.org/protocol/disco#info'
  646. node='urn:xmpp:caps#sha-256.u79ZroNJbdSWhdSp311mddz44oHHPsEBntQ5b1jqBSY='>
  647. <identity category="client" name="Tkabber" type="pc" xml:lang="en"/>
  648. <identity category="client" name="Ткаббер" type="pc" xml:lang="ru"/>
  649. <feature var="games:board"/>
  650. <feature var="http://jabber.org/protocol/activity"/>
  651. <feature var="http://jabber.org/protocol/activity+notify"/>
  652. <feature var="http://jabber.org/protocol/bytestreams"/>
  653. <feature var="http://jabber.org/protocol/chatstates"/>
  654. <feature var="http://jabber.org/protocol/commands"/>
  655. <feature var="http://jabber.org/protocol/disco#info"/>
  656. <feature var="http://jabber.org/protocol/disco#items"/>
  657. <feature var="http://jabber.org/protocol/evil"/>
  658. <feature var="http://jabber.org/protocol/feature-neg"/>
  659. <feature var="http://jabber.org/protocol/geoloc"/>
  660. <feature var="http://jabber.org/protocol/geoloc+notify"/>
  661. <feature var="http://jabber.org/protocol/ibb"/>
  662. <feature var="http://jabber.org/protocol/iqibb"/>
  663. <feature var="http://jabber.org/protocol/mood"/>
  664. <feature var="http://jabber.org/protocol/mood+notify"/>
  665. <feature var="http://jabber.org/protocol/rosterx"/>
  666. <feature var="http://jabber.org/protocol/si"/>
  667. <feature var="http://jabber.org/protocol/si/profile/file-transfer"/>
  668. <feature var="http://jabber.org/protocol/tune"/>
  669. <feature var="http://www.facebook.com/xmpp/messages"/>
  670. <feature var="http://www.xmpp.org/extensions/xep-0084.html#ns-metadata+notify"/>
  671. <feature var="jabber:iq:avatar"/>
  672. <feature var="jabber:iq:browse"/>
  673. <feature var="jabber:iq:dtcp"/>
  674. <feature var="jabber:iq:filexfer"/>
  675. <feature var="jabber:iq:ibb"/>
  676. <feature var="jabber:iq:inband"/>
  677. <feature var="jabber:iq:jidlink"/>
  678. <feature var="jabber:iq:last"/>
  679. <feature var="jabber:iq:oob"/>
  680. <feature var="jabber:iq:privacy"/>
  681. <feature var="jabber:iq:roster"/>
  682. <feature var="jabber:iq:time"/>
  683. <feature var="jabber:iq:version"/>
  684. <feature var="jabber:x:data"/>
  685. <feature var="jabber:x:event"/>
  686. <feature var="jabber:x:oob"/>
  687. <feature var="urn:xmpp:avatar:metadata+notify"/>
  688. <feature var="urn:xmpp:ping"/>
  689. <feature var="urn:xmpp:receipts"/>
  690. <feature var="urn:xmpp:time"/>
  691. <x xmlns="jabber:x:data" type="result">
  692. <field type="hidden" var="FORM_TYPE">
  693. <value>urn:xmpp:dataforms:softwareinfo</value>
  694. </field>
  695. <field var="software">
  696. <value>Tkabber</value>
  697. </field>
  698. <field var="software_version">
  699. <value>0.11.1-svn-20111216-mod (Tcl/Tk 8.6b2)</value>
  700. </field>
  701. <field var="os">
  702. <value>Windows</value>
  703. </field>
  704. <field var="os_version">
  705. <value>XP</value>
  706. </field>
  707. </x>
  708. </query>
  709. </iq>
  710. ]]></example>
  711. </section2>
  712. <section2 topic='Gratuitous Capabilities' anchor='usecases-gratuitous'>
  713. <p>A server MAY support pushing of &hashes; from clients before sending initial presence. This allows servers to discover capabilities of clients before those have sent initial presence, which may be useful or important for some protocols (such as &xep0369;). This feature is called &gratcaps;.</p>
  714. <p>To advertise support, the server publishes the <tt>urn:xmpp:caps:gratuitous</tt> feature:</p>
  715. <example caption='Response to a disco#info request if the server supports Gratuitous Capabilities'><![CDATA[
  716. <iq from='montague.lit'
  717. id='disco3'
  718. to='romeo@montague.lit/chamber'
  719. type='result'>
  720. <query xmlns='http://jabber.org/protocol/disco#info'>
  721. ...
  722. <feature var='urn:xmpp:caps'/>
  723. <feature var='urn:xmpp:caps:gratuitous'/>
  724. ...
  725. </query>
  726. </iq>
  727. ]]></example>
  728. <p>After determining server support, a client can send &hashes; via &gratcaps; before sending initial presence:</p>
  729. <example caption='Sending Gratuitous Capabilities'><![CDATA[
  730. <iq from='romeo@montague.lit/chamber'
  731. to='montague.lit'
  732. id='grat1'
  733. type='set'>
  734. <c xmlns="urn:xmpp:caps">
  735. <hash xmlns="urn:xmpp:hashes:2" algo="sha-256">u79ZroNJbdSWhdSp311mddz44oHHPsEBntQ5b1jqBSY=</hash>
  736. <hash xmlns="urn:xmpp:hashes:2" algo="sha3-256">XpUJzLAc93258sMECZ3FJpebkzuyNXDzRNwQog8eycg=</hash>
  737. </c>
  738. </iq>
  739. <iq from='montague.lit'
  740. to='romeo@montague.lit/chamber'
  741. id='grat1'
  742. type='result'>
  743. </iq>
  744. ]]></example>
  745. <p>The server replies with an empty result on success.</p>
  746. <p>The server MUST NOT broadcast the &hashes; submitted via &gratcaps; using presence.</p>
  747. <p>Clients SHOULD NOT send &gratcaps; after they have sent initial presence; instead, they SHOULD re-send presence to update the &hashes;. Otherwise, entities subscribed to the presence will not receive the updated &hashes;.</p>
  748. </section2>
  749. </section1>
  750. <section1 topic='Business Rules' anchor='rules'>
  751. <section2 topic='Rules for Generating Entities' anchor='rules-generating'>
  752. <ul>
  753. <li>Entities MUST respond to disco#info queries for all &hashnodes; of at least the most recent 3 &hashsets; emitted.</li>
  754. <li>Entities MUST broadcast the &hashset; of the current disco#info it publishes in every non-directed "available" &lt;presence/&gt; they send and SHOULD do so for directed "available" &lt;presence/&gt;.</li>
  755. <li>After initial presence has been sent, entities MUST re-broadcast the &hashset; after their disco#info response changes, but MAY limit the rate at which presences are emitted solely for the purpose of sending new &hashsets;.</li>
  756. <li>Before initial presence has been sent and if the server supports &gratcaps;, entities SHOULD send &gratcaps; after their disco#info response changes, but MAY limit the rate at which &gratcaps; are sent. (For example, a client may load and enable additional functionality (thus changing its features) based on server support and only send &gratcaps; once all functionality has been set up, not after each individual feature.)</li>
  757. <li>Entities MAY assume that another entity supports &caps; after receiving a &hashset; from that entity.</li>
  758. <li>Entities MAY also send &xep0115; capabilities to support legacy entities.</li>
  759. </ul>
  760. </section2>
  761. <section2 topic='Rules for Processing Entities' anchor='rules-processing'>
  762. <ul>
  763. <li>Entities MAY limit the rate at which they process incoming &hashsets;.</li>
  764. <li>Entities MUST be able to process &hashnodes; which use a hash function whose name includes the &fullstop;.</li>
  765. <li>Entities MAY verify incoming &hashsets;.</li>
  766. <li>Entities MUST NOT expect to receive &hashsets; on every presence sent by an entity supporting &caps;.</li>
  767. </ul>
  768. <section3 topic='Caching' anchor='rules-processing-caching'>
  769. <p>A &hash; MAY be stored alongside with its disco#info in a &hashcache;. A received &hash; which has not been verified MUST NOT be stored.</p>
  770. <p>Instead of issuing a &xep0030; disco#info &lt;query/&gt; with absent 'node' attribute to a target entity, an entity MAY use a &hashcache; to obtain the response. To look up the disco#info response in the &hashcache;, an entity MUST use a hash from the &hashset; which was most recently received from the entity to which the &lt;query/&gt; would have been sent otherwise. If none of the most recently received &hashes; are found in the &hashcache;, the entity MUST fall back to sending the request.</p>
  771. <p>An entity MUST NOT use &hashes; which were not included in the most recent &hashset; received from the target entity.</p>
  772. <p>An entity MAY use external data sources to fill the &hashcache;.</p>
  773. <p>An entity MUST ensure that implicit values for <tt>xml:lang</tt> attributes is preserved when disco#info data is cached. This can for example happen by making the implicit values explicit in the storage.</p>
  774. </section3>
  775. </section2>
  776. <section2 topic='Additional Rules for Clients and Servers implementing Caps Optimizations' anchor='rules-optimize'>
  777. <ul>
  778. <li>Servers MAY strip off the &lt;c/&gt; element if it has not changed since the previous presence broadcast.</li>
  779. <li>Servers MUST ensure that the first presence notification sent to each subscriber contains the most recent &lt;c/&gt; element, if any were sent in the current presence session.</li>
  780. <li>Servers MUST ensure that every change in the &lt;c/&gt; element is sent to all subscribers.</li>
  781. <li>Clients MAY omit the &lt;c/&gt; element if it has not changed since the last presence <em>iff</em> they determined that their server supports Caps Optimization.</li>
  782. <li>Servers MAY answer disco#info requests for &hashnodes; on behalf of their and others clients if the disco#info response belonging to that &hash; is known to them.</li>
  783. </ul>
  784. </section2>
  785. <section2 topic='Query Interception' anchor='rules-servers'>
  786. <p>Servers MAY implement &queryintercept; to further optimise bandwidth consumption. The idea is that servers intercept &xep0030; disco#info queries sent to clients if they already know the answer from &hashes; published by the client. The rules for &queryintercept; are the following (to be applied in this order):</p>
  787. <ul>
  788. <li>Servers MUST NOT intercept disco#info queries except those with empty <tt>node</tt> or a <tt>node</tt> which refers to a &hashnode; known to the server.</li>
  789. <li>Servers MUST NOT intercept disco#info queries on behalf of the resource unless the query would be forwarded to the resource otherwise.</li>
  790. <li>Servers MUST NOT intercept disco#info queries to resources which do not support &caps; (clients not implementing &caps; may legitimately use disco#info nodes matching the format of &hashnodes; for different purposes).</li>
  791. <li>Servers SHOULD intercept disco#info queries with empty <tt>node</tt> and answer them with the disco#info of the most recent &hashset; published by the client.</li>
  792. <li>Servers SHOULD intercept disco#info queries a valid &hashnode; <tt>node</tt>, if the server knows the disco#info for the &hashnode;. Otherwise, the query MUST be forwarded to the addressed resource. Note that it is valid for a sevrer to reply for &hashnodes; which have not been published by the resource.</li>
  793. </ul>
  794. </section2>
  795. </section1>
  796. <section1 topic='Implementation Notes' anchor='impl'>
  797. <section2 topic='Caching' anchor='impl-caching'>
  798. <p>It is RECOMMENDED that entities use the caching mechanisms outlined in <link url='#rules-processing-caches'>the Caching Business Rules</link>. Entities MAY share caches among connections and accounts.</p>
  799. </section2>
  800. <section2 topic='Upgrading from XEP-0115' anchor='impl-upgrade'>
  801. <p>&genents; are encouraged to also emit &xep0115; &lt;c/&gt; elements in their presence updates (as specified in <cite>XEP-0115</cite>) for a reasonable transition period.</p>
  802. <p>When receiving a &hashset; along with <cite>XEP-0115</cite> capabilities, a &procent; MAY obtain the disco#info &lt;query/&gt; for verification from a <cite>XEP-0115</cite> based cache instead of querying the &genent; directly. A &procent; MUST NOT use disco#info data from a <cite>XEP-0115</cite> cache without verification if a &caps; &lt;c/&gt; element is available.</p>
  803. </section2>
  804. </section1>
  805. <section1 topic='Security Considerations' anchor='security'>
  806. <section2 topic='Hash Function Input Data Separators' anchor='security-separators'>
  807. <p>The codepoints used for separating the different parts in the <link url='#algorithm-input'>Hash Function Input Algortihm</link> (&sepl1; through &sepl4;) are not allowed in well-formed XML character data. As entities are, per &xmppcore;, required to close a stream if non-well-formed XML data is received, these codepoints cannot occur in the input to the algorithm and their use as separators is safe.</p>
  808. </section2>
  809. <section2 topic='Caching' anchor='security-caching'>
  810. <p>If the algorithm for constructing the input to the hash function or the used hash function itself allow for cheap collisions, caching the hashes will become dangerous as it allows for cache poisoning. This in turn allows entities to effectively fake disco#info responses of other entities.</p>
  811. <p>This was an issue with &xep0115; and has been addressed with a new algorithm for generating the hash function input which keeps the structural information of the disco#info input.</p>
  812. <p>An entity MUST NOT ever use disco#info which has not been verified to belong to a &hash; obtained from a cache using that &hash;. Using cache contents from a trusted source (at the discretion of the entity) counts as verifying.</p>
  813. <p>A malicious entity could send a large amount of &hashsets; in short intervals, while making sure that it provides matching disco#info responses. If a &procent; uses caching, this can overflow or thrash the caches. &procents; should be aware of this risk and apply proper rate-limiting for processing &hashsets;. To reduce the attack surface, an entity MAY choose to not cache &hashes; obtained from entities not in its roster.</p>
  814. <p>As mentioned earlier, when storing disco#info data in a cache for later retrieval, implementations MUST ensure that implicit values for <tt>xml:lang</tt> attributes are reconstructed correctly when the disco#info is restored.</p>
  815. </section2>
  816. <section2 topic='Directed Presence' anchor='security-directed-presence'>
  817. <p>Entities MAY choose to not send &hashsets; with directed presence (for example to increase privacy). In that case, entities SHOULD also refuse direct &xep0030; queries.</p>
  818. </section2>
  819. <section2 topic='Query Interception' anchor='security-query-interception'>
  820. <p>The server replies to certain disco#info queries on behalf of the client. This means that the client has no choice on to whom they reply. Otherwise, a client could choose to reply with <tt>&lt;service-unavailable/&gt;</tt> to mask its existence. We consider two effects of this:</p>
  821. <ul>
  822. <li>
  823. <p>A remote entity could attempt to detect that an entity exists behind a resource. For this, they send a disco#info query to the resource since nearly everyone implements disco#info. As the client responds with <tt>&lt;service-unavailable/&gt;</tt>, it looks as if no client was present at this resource.</p>
  824. <p>With &queryintercept;, the server would reply on behalf of the client. However, the consensus in the community is that by measuring the difference between the reply from the server of the resource and the reply from the actual resource, it would generally be possible to detect the existence of a resource.</p>
  825. </li>
  826. <li>
  827. <p>A remote entity can obtain the disco#info information of any resource which supports &caps; and of which the entity knows the resource.</p>
  828. <p>This cannot be mitigated with &queryintercept;. The risk is deemed acceptable considering that resources should generally be chosen randomly.</p>
  829. </li>
  830. </ul>
  831. </section2>
  832. </section1>
  833. <section1 topic='Design Considerations' anchor='design'>
  834. <p>The following alternatives to the custom algorithm were considered and eventually rejected:</p>
  835. <section2 topic='Canonical XML' anchor='design-c14n'>
  836. <p>A common way to canonicalize XML which could be used is &w3canon;. It was decided not to use <cite>Canonical XML</cite> for the following reasons:</p>
  837. <ul>
  838. <li>Implementing it is quite some effort and not all XML libraries come with an implementation.</li>
  839. <li>It is sensitive to the relative ordering of the elements. The relative ordering of children in disco#info &lt;query/&gt; elements, however, does not matter.</li>
  840. <li>Several children of &xep0128; data forms are deliberately ignored, like instructions and other descriptive text. The descriptive text is not relevant for the information is being conveyed.</li>
  841. </ul>
  842. <p>Thus, using <cite>Canonical XML</cite> would require additional, non-trivial software support and still require non-trivial additional canonicalization rules.</p>
  843. </section2>
  844. </section1>
  845. <section1 topic='IANA Considerations' anchor='iana'>
  846. <p>This document requires no interaction with &IANA;. </p>
  847. </section1>
  848. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  849. <section2 topic='Protocol Namespaces' anchor='ns'>
  850. <p>The &REGISTRAR; includes "urn:xmpp:caps" in its registry of protocol namespaces (see &NAMESPACES;).</p>
  851. <code><![CDATA[
  852. <ns>
  853. <name>urn:xmpp:caps</name>
  854. <doc>&xep0390;</doc>
  855. </ns>
  856. ]]></code>
  857. </section2>
  858. <section2 topic='Service Discovery Features' anchor='registrar-features'>
  859. <p>The XMPP Registrar includes "urn:xmpp:caps" and "urn:xmpp:caps:optimize" in its registry of service discovery features (see &DISCOFEATURES;).</p>
  860. <code><![CDATA[
  861. <var>
  862. <name>urn:xmpp:caps</name>
  863. <desc>Indicate support for Entity Capabilities 2.0</desc>
  864. <doc>&xep0390;</doc>
  865. </var>
  866. <var>
  867. <name>urn:xmpp:caps:optimize</name>
  868. <desc>Indicate support for optimisation of Entity Capabilities 2.0 broadcast.</desc>
  869. <doc>&xep0390;</doc>
  870. </var>]]></code>
  871. </section2>
  872. <section2 topic='Stream Features' anchor='registrar-stream-features'>
  873. <p>The XMPP Registrar includes "urn:xmpp:caps" in its registry of stream features (see &STREAMFEATURES;).</p>
  874. <code><![CDATA[
  875. <feature>
  876. <ns>urn:xmpp:caps</ns>
  877. <name>ecaps2</name>
  878. <element>c</element>
  879. <desc>Indicate support for Entity Capabilities 2.0 and publish capabilities to peer.</desc>
  880. <doc>&xep0390;</doc>
  881. </feature>
  882. ]]></code>
  883. </section2>
  884. </section1>
  885. <section1 topic='XML Schema' anchor='schema'>
  886. <code><![CDATA[
  887. <?xml version='1.0' encoding='UTF-8'?>
  888. <xs:schema
  889. xmlns:xs='http://www.w3.org/2001/XMLSchema'
  890. targetNamespace='urn:xmpp:caps'
  891. xmlns='urn:xmpp:caps'
  892. elementFormDefault='qualified'
  893. xmlns:hashes='urn:xmpp:hashes:2'>
  894. <!-- FIXME: import of XEP-0300 schema, which isn't at https://xmpp.org/schemas/ at the time of writing -->
  895. <xs:annotation>
  896. <xs:documentation>
  897. The protocol documented by this schema is defined in XEP-0390:
  898. http://www.xmpp.org/extensions/xep-0390.html
  899. </xs:documentation>
  900. </xs:annotation>
  901. <xs:element name='c'>
  902. <xs:complexType>
  903. <xs:sequence minOccurs='1'>
  904. <xs:element ref='hashes:hash' minOccurs='1' maxOccurs='unbounded'/>
  905. </xs:sequence>
  906. </xs:complexType>
  907. </xs:element>
  908. </xs:schema>
  909. ]]></code>
  910. </section1>
  911. <section1 topic='Acknowledgements' anchor='acknowledgements'>
  912. <p>Thanks to the authors of &xep0115; for coming up with the original idea of using presence broadcast to convey service discovery information, as well as the optimization strategies.</p>
  913. <p>The note below the example in <link url='#usecases-stream-feature'>Advertisement of Support and Capabilities by Servers</link> has been copied verbatimly from <cite>XEP-0115</cite>.</p>
  914. <p>Thanks to Waqas Hussain for originally (to my knowledge) pointing out the security flaws in <cite>XEP-0115</cite> (see &mlwaqas1;).</p>
  915. <p>Thanks to Dave Cridland, Georg Lukas, Link Mauve, Sebastian Riese, Florian Schmaus and Sam Whited for their input, editorial and otherwise.</p>
  916. </section1>
  917. </xep>