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-0188.xml 49KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  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>Cryptographic Design of Encrypted Sessions</title>
  10. <abstract>This document describes the cryptographic design that underpins the XMPP protocol extensions Encrypted Session Negotiation, Offline Encrypted Sessions and Stanza Encryption.</abstract>
  11. &LEGALNOTICE;
  12. <number>0188</number>
  13. <status>Deferred</status>
  14. <type>Informational</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. <spec>XMPP IM</spec>
  19. <spec>RFC 2104</spec>
  20. </dependencies>
  21. <supersedes/>
  22. <supersededby/>
  23. <shortname>N/A</shortname>
  24. &ianpaterson;
  25. <revision>
  26. <version>0.6</version>
  27. <date>2007-05-30</date>
  28. <initials>ip</initials>
  29. <remark><p>SIGMA-R negotiates both isPKA and isPKB fields</p></remark>
  30. </revision>
  31. <revision>
  32. <version>0.5</version>
  33. <date>2007-04-20</date>
  34. <initials>ip</initials>
  35. <remark><p>Moved requirements, approach and scope to new XEP-0210</p></remark>
  36. </revision>
  37. <revision>
  38. <version>0.4</version>
  39. <date>2007-03-15</date>
  40. <initials>ip</initials>
  41. <remark><p>Incorporated whole forms into SAS calculation</p></remark>
  42. </revision>
  43. <revision>
  44. <version>0.3</version>
  45. <date>2006-11-27</date>
  46. <initials>ip</initials>
  47. <remark><p>Added PKI Independence and Robustness requirements; added optional public key independence, hash commitment, SAS authentication, retained secrets and other secrets to SIGMA-R key exchange</p></remark>
  48. </revision>
  49. <revision>
  50. <version>0.2</version>
  51. <date>2006-07-19</date>
  52. <initials>ip</initials>
  53. <remark><p>Removed public key IDs from Offline options</p></remark>
  54. </revision>
  55. <revision>
  56. <version>0.1</version>
  57. <date>2006-07-18</date>
  58. <initials>ip</initials>
  59. <remark><p>Initial version (extracted from XEP-0116 version 0.9).</p></remark>
  60. </revision>
  61. </header>
  62. <section1 topic='Introduction' anchor='intro'>
  63. <p><em>Note: The protocols developed according to the cryptographic design described in this document are described in &xep0116;, &xep0217;, &xep0187; and &xep0200;. The information in those documents should be sufficient for implementors. This purely informative document is primarily for people interested in the design and analysis of those protocols.</em></p>
  64. <p>As specified in &rfc3920;, XMPP is an XML streaming protocol that enables the near-real-time exchange of XML fragments between any two (or more) network endpoints. To date, the main application built on top of the core XML streaming layer is instant messaging (IM) and presence, the base extensions for which are specified in &rfc3921;. There are three first-level elements of XML streams (&MESSAGE;, &PRESENCE;, and &IQ;); each of these "XML stanza" types has different semantics, which can complicate the task of defining a generalized approach to end-to-end encryption for XMPP. In addition, XML stanzas can be extended (via properly-namespaced child elements) for a wide variety of functionality.</p>
  65. <p>XMPP is a session-oriented communication technology: normally, a client authenticates with a server and maintains a long-lived connection that defines the client's XMPP session. Such stream-level sessions may be secured via channel encryption using Transport Level Security (&rfc2246;), as specified in Section 5 of <cite>RFC 3920</cite>. However, there is no guarantee that all hops will implement or enforce channel encryption (or that intermediate servers are trustworthy), which makes end-to-end encryption desirable.</p>
  66. <p>This document specifies a method for encrypted sessions ("ESessions") that takes advantage of the inherent possibilities and strengths of session encryption as opposed to object encryption. The detailed requirements for encrypted sessions are defined in &xep0210;.</p>
  67. <p>The conceptual model for the approach specified in this document was inspired by "off-the-record" (OTR) communication, as implemented in the Gaim encryption plugin and described in &otr;. 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 all one-to-one XML stanzas exchanged between the endpoints will be encrypted and then transmitted within a "wrapper" protocol element.</p>
  68. <p>Note: In order to gain a thorough understanding of this document, it is recommended that the <cite>Off-the-Record Communication</cite> paper and &rfc6189; are read first.</p>
  69. </section1>
  70. <section1 topic="Dramatis Personae" anchor='personae'>
  71. <p>This document introduces two characters to help the reader follow the necessary exchanges:</p>
  72. <ol start='1'>
  73. <li>"Alice" is the name of the initiator of the ESession.</li>
  74. <li>"Bob" is the name of the other participant in the ESession started by Alice.</li>
  75. </ol>
  76. <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>
  77. </section1>
  78. <section1 topic='Cryptographic Origins' anchor='foundations'>
  79. <section2 topic='Introduction' anchor='foundations-intro'>
  80. <p>Authenticated key-exchange is the most challenging part of the design of any secure communication protocol. The ESessions key exchange essentially translates the &sigma;<note>Like <cite>RFC 2409</cite>, this protocol uses <em>variant (ii)</em>, as described in Secion 5.4 of the <cite>SIGMA</cite> paper.</note> key-exchange protocol into the syntax of XMPP. The SIGMA approach to Diffie-Hellman Key Agreement (see &rfc2631;) underpins several standard key-exchange protocols including the Internet Key Exchange (IKE) protocol versions 1 and 2 (see &rfc2409; and &rfc4306;).</p>
  81. <p>Note: Although this section provides an overview of SIGMA, it is strongly recommended that the <cite>SIGMA</cite> paper is read first in order to gain a thorough understanding of this document.</p>
  82. <p>The 3-message SIGMA-I-based key exchange 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>
  83. <p>The two 4-message SIGMA-R-based key exchanges with hash commitment defend the <em>responder's</em> identity against active attacks and facilitate detection of a Man in the Middle attack. They SHOULD be used to establish client to client sessions.</p>
  84. <p>Note: The block cipher function, <em>cipher</em>, uses CTR mode.</p>
  85. </section2>
  86. <section2 topic='SIGMA Parameter Descriptions' anchor='foundations-parameters'>
  87. <table caption='SIGMA and SAS Overview Parameters'>
  88. <tr>
  89. <th>Parameter</th>
  90. <th>Description</th>
  91. </tr>
  92. <tr>
  93. <td>g</td>
  94. <td>Diffie-Hellman generator</td>
  95. </tr>
  96. <tr>
  97. <td>x, y</td>
  98. <td>Alice and Bob's private Diffie-Hellman keys</td>
  99. </tr>
  100. <tr>
  101. <td>&gsupx;, &gsupy;</td>
  102. <td>Alice and Bob's public Diffie-Hellman keys</td>
  103. </tr>
  104. <tr>
  105. <td>H&gsupx;</td>
  106. <td>Hash of Alice's public Diffie-Hellman key</td>
  107. </tr>
  108. <tr>
  109. <td>&KSsubA;, &KSsubB;</td>
  110. <td>The MAC keys (derived from K) that Alice and Bob use to calculate &macA; and &macB;</td>
  111. </tr>
  112. <tr>
  113. <td>&pubKeyA;, &pubKeyB;</td>
  114. <td>The public keys that represent the identity of Alice and Bob, and are used to verify their signatures</td>
  115. </tr>
  116. <tr>
  117. <td>&macA;, &macB;</td>
  118. <td>The MAC values that associate the shared secret with the identity of Alice or Bob</td>
  119. </tr>
  120. <tr>
  121. <td>&signKeyA;, &signKeyB;</td>
  122. <td>The private keys that Alice and Bob use to sign</td>
  123. </tr>
  124. <tr>
  125. <td>&signA;, &signB;</td>
  126. <td>Alice's and Bob's signatures of the shared secret</td>
  127. </tr>
  128. <tr>
  129. <td>&KCsubA;, &KCsubB;</td>
  130. <td>The cipher keys (derived from K) that Alice and Bob use to encrypt</td>
  131. </tr>
  132. <tr>
  133. <td>&IDA;, &IDB;</td>
  134. <td>The encrypted parameters that identify Alice and Bob to each other</td>
  135. </tr>
  136. <tr>
  137. <td>SAS</td>
  138. <td>Short Authentication String</td>
  139. </tr>
  140. </table>
  141. <table caption='Key Exchange Parameters'>
  142. <tr>
  143. <th>Parameter</th>
  144. <th>Description</th>
  145. </tr>
  146. <tr>
  147. <td>p</td>
  148. <td>Diffie-Hellman prime</td>
  149. </tr>
  150. <tr>
  151. <td>e, d</td>
  152. <td>Alice and Bob's public Diffie-Hellman keys (the same as &gsupx;, &gsupy;)</td>
  153. </tr>
  154. <tr>
  155. <td>He</td>
  156. <td>Hash of Alice's public Diffie-Hellman key</td>
  157. </tr>
  158. <tr>
  159. <td>K</td>
  160. <td>Shared secret (derived by Alice from &gsupy; and x, or by Bob from &gsupx; and y)</td>
  161. </tr>
  162. <tr>
  163. <td>HASH</td>
  164. <td>Selected hash algorithm</td>
  165. </tr>
  166. <tr>
  167. <td>&NsubA;, &NsubB;</td>
  168. <td>Alice and Bob's session freshness nonces (ESession IDs)</td>
  169. </tr>
  170. <tr>
  171. <td>&CsubA;, &CsubB;</td>
  172. <td>Block cipher initial counter value for blocks sent by Alice and Bob</td>
  173. </tr>
  174. <tr>
  175. <td>n</td>
  176. <td>Block size of selected cipher algorithm in bits</td>
  177. </tr>
  178. <tr>
  179. <td>&KMsubA;, &KMsubB;</td>
  180. <td>The MAC keys (derived from K) that Alice and Bob use to protect the integrity of encrypted data</td>
  181. </tr>
  182. <tr>
  183. <td>&MsubA;, &MsubB;</td>
  184. <td>The MAC values that Alice and Bob use to confirm the integrity of encrypted data</td>
  185. </tr>
  186. <tr>
  187. <td>SRS</td>
  188. <td>Shared retained secret (derived from K in previous session between the clients)</td>
  189. </tr>
  190. <tr>
  191. <td>&RS1ARSZA;</td>
  192. <td>Retained secrets Alice shares with Bob (one for each client he uses)</td>
  193. </tr>
  194. <tr>
  195. <td>&RS1BRSZB;</td>
  196. <td>Retained secrets Bob shares with Alice (one for each client she uses)</td>
  197. </tr>
  198. <tr>
  199. <td>&RSH1ARSHZA;</td>
  200. <td>HMACs of retained secrets Alice shares with Bob</td>
  201. </tr>
  202. <tr>
  203. <td>SRSH</td>
  204. <td>Bob's HMAC of SRS</td>
  205. </tr>
  206. <tr>
  207. <td>OSS</td>
  208. <td>Other shared secret of Alice and Bob (e.g. a shared password) defaults to "secret"</td>
  209. </tr>
  210. <tr>
  211. <td>&isPKsubA;, &isPKsubB;</td>
  212. <td>Whether or not Alice and Bob prefer to <em>receive</em> a public key (booleans)</td>
  213. </tr>
  214. </table>
  215. </section2>
  216. <section2 topic='SIGMA-I Overview' anchor='foundations-skeleton-i'>
  217. <p>The diagram below demonstrates the barest cryptographic skeleton of the SIGMA-I key exchange protocol. Here Bob allows Alice to protect her identity from active attacks, by allowing her to authenticate him before she communicates her identity. Note: The cipher keys (&KCsubA; and &KCsubB;) are different in each direction, making this exchange slightly more conservative than <cite>SIGMA</cite>.</p>
  218. <code>
  219. <strong>ALICE</strong>&#160; <strong>BOB</strong>&#160;
  220. &gsupx;
  221. ------------&gt;
  222. &macB; = <em>HMAC</em>(&KSsubB;, {&gsupx;, &gsupy;, &pubKeyB;})
  223. &signB; = <em>sign</em>(&signKeyB;, &macB;)
  224. &IDB; = <em>cipher</em>(&KCsubB;, {&pubKeyB;, &signB;})
  225. &gsupy;, &IDB;&#160;
  226. &lt;------------
  227. <em>authenticate</em>(&IDB;)&#160;
  228. &macA; = <em>HMAC</em>(&KSsubA;, {&gsupy;, &gsupx;, &pubKeyA;})
  229. &signA; = <em>sign</em>(&signKeyA;, &macA;)
  230. &IDA; = <em>cipher</em>(&KCsubA;, {&pubKeyA;, &signA;})
  231. &IDA;
  232. ------------&gt;
  233. <em>authenticate</em>(&IDA;)
  234. </code>
  235. </section2>
  236. <section2 topic='SAS-Only Overview' anchor='foundations-skeleton-sas'>
  237. <p>The diagram below demonstrates the skeleton of the Diffie-Hellman key exchange that employs out-of-band Short Authentication String (SAS) verification. If Alice and Bob's public keys are not yet trusted, or if their private keys have been compromised, then the hash commitment sent in the first step enables Alice and Bob to verify their copies of each other's Diffie-Hellman (and public) keys and detect a Man in the Middle more easily.</p>
  238. <p>If a Man in the Middle changes the public Diffie-Hellman keys that Alice and Bob receive, then he could potentially use his knowledge of the SAS that Bob will eventually calculate when choosing the key he will send to Alice in the second step. However, the fact that the value he received in the first step is only a hash means the Man in the Middle must choose the key he sends to Alice before he can predict the SAS that she will calculate with it. Therefore, even if the SAS is very short, he is unable to use his resources to choose a key that will (have a better than random chance to) result in a SAS that matches Bob's. So only a truncated version of the HASH of Alice and Bob's keys needs to be verified out-of-band in the final step.</p>
  239. <code>
  240. <strong>ALICE</strong>&#160; <strong>BOB</strong>&#160;
  241. H&gsupx;
  242. ------------&gt;
  243. &gsupy;
  244. &lt;------------
  245. SAS = <em>truncate</em>(HASH(&gsupx; | &gsupy;))
  246. &gsupx;
  247. ------------&gt;
  248. <em>assert</em> H&gsupx; = HASH(&gsupx;)
  249. SAS = <em>truncate</em>(HASH(&gsupx; | &gsupy;))
  250. SAS
  251. &lt;===========&gt;
  252. </code>
  253. </section2>
  254. <section2 topic='SIGMA-R with SAS Overview' anchor='foundations-skeleton-r'>
  255. <p>The logic of the four-step SIGMA-R protocol is similar to the three-step SIGMA-I protocol. The difference being that Bob protects his identity from active attacks by by delaying communicating his identity to Alice until he has authenticated her. The diagram below demonstrates the skeleton of the key exchange. Note that it also takes advantage of the extra step required for SIGMA-R to incorporate a hash commitment, thus enabling <em>optional</em> out-of-band SAS authentication.</p>
  256. <code>
  257. <strong>ALICE</strong>&#160; <strong>BOB</strong>&#160;
  258. H&gsupx;
  259. ------------&gt;
  260. &gsupy;
  261. &lt;------------
  262. &macA; = <em>HMAC</em>(&KSsubA;, {&gsupy;, &gsupx;, &pubKeyA;})
  263. &signA; = <em>sign</em>(&signKeyA;, &macA;)
  264. &IDA; = <em>cipher</em>(&KCsubA;, {&pubKeyA;, &signA;})
  265. SAS = <em>truncate</em>(HASH(&gsupx; | &gsupy;))
  266. &gsupx;, &IDA;
  267. ------------&gt;
  268. <em>assert</em> H&gsupx; = HASH(&gsupx;)
  269. SAS = <em>truncate</em>(HASH(&gsupx; | &gsupy;))
  270. SAS
  271. &lt;===========&gt;
  272. <em>authenticate</em>(&IDA;)
  273. &macB; = <em>HMAC</em>(&KSsubB;, {&gsupx;, &gsupy;, &pubKeyB;})
  274. &signB; = <em>sign</em>(&signKeyB;, &macB;)
  275. &IDB; = <em>cipher</em>(&KCsubB;, {&pubKeyB;, &signB;})
  276. &IDB;
  277. &lt;------------
  278. <em>authenticate</em>(&IDB;)
  279. </code>
  280. </section2>
  281. <section2 topic='SIGMA-I Key Exchange' anchor='foundations-core-i'>
  282. <p>The diagram below describes exactly the same SIGMA-I key exchange protocol as the <link url='#foundations-skeleton-i'>SIGMA-I Overview</link> above. It provides much more detail, without specifying any ESession-specific details. The differences between it and the <link url='#foundations-core-r'>SIGMA-R with SAS Key Exchange</link> are highlighted.</p>
  283. <code>
  284. <strong>ALICE</strong>&#160; <strong>BOB</strong>&#160;
  285. &NsubA; = <em>random</em>()
  286. x = <em>random</em>()
  287. e = &gsupx; mod p
  288. e,&#160;&NsubA;
  289. ------------&gt;
  290. &NsubB; = <em>random</em>()
  291. &CsubA; = <em>random</em>()
  292. &CBeCAx2n1;&#160;
  293. y = <em>random</em>()
  294. d = &gsupy; mod p
  295. <em>assert</em> 1 &lt; e &lt; p-1
  296. K = HASH(&esupy; mod p)
  297. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  298. &KCsubB; = <em>HMAC</em>(HASH, K, "Responder Cipher Key")
  299. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  300. &KMsubB; = <em>HMAC</em>(HASH, K, "Responder MAC Key")
  301. &KSsubA; = <em>HMAC</em>(HASH, K, "Initiator SIGMA Key")
  302. &KSsubB; = <em>HMAC</em>(HASH, K, "Responder SIGMA Key")
  303. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &CsubA;})
  304. &signB; = <em>sign</em>(&signKeyB;, &macB;)
  305. &IDB; = <em>cipher</em>(&KCsubB;, &CsubB;, {&pubKeyB;, &signB;})
  306. &MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)&#160;
  307. d, &CsubA;, &NsubB;
  308. &lt;------------
  309. &IDB;, &MsubB;&#160;
  310. &CBeCAx2n1;&#160;
  311. <em>assert</em> 1 &lt; d &lt; p-1
  312. K = HASH(&dsupx; mod p)
  313. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  314. &KCsubB; = <em>HMAC</em>(HASH, K, "Responder Cipher Key")&#160;
  315. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  316. &KMsubB; = <em>HMAC</em>(HASH, K, "Responder MAC Key")&#160;
  317. &KSsubA; = <em>HMAC</em>(HASH, K, "Initiator SIGMA Key")
  318. &KSsubB; = <em>HMAC</em>(HASH, K, "Responder SIGMA Key")
  319. <em>assert</em>&#160;&MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)
  320. {&pubKeyB;, &signB;} = <em>decipher</em>(&KCsubB;, &CsubB;, &IDB;)
  321. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &CsubA;})
  322. <em>verify</em>(&signB;, &pubKeyB;, &macB;)&#160;
  323. &macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;})
  324. &signA; = <em>sign</em>(&signKeyA;, &macA;)
  325. &IDA; = <em>cipher</em>(&KCsubA;, &CsubA;, {&pubKeyA;, &signA;})
  326. &MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)
  327. &IDA;
  328. ------------&gt;
  329. &MsubA;&#160;
  330. <em>assert</em>&#160;&MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)
  331. {&pubKeyA;, &signA;} = <em>decipher</em>(&KCsubA;, &CsubA;, &IDA;)
  332. &macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;})
  333. <em>verify</em>(&signA;, &pubKeyA;, &macA;)
  334. </code>
  335. </section2>
  336. <section2 topic='SIGMA-R with SAS Key Exchange' anchor='foundations-core-r'>
  337. <p>The Short Authentication String technique enables protection against a Man in the Middle without the need to generate, distribute or authenticate any public keys. As long as a hash commitment is used at the start of the key exchange then only a short human-friendly string needs to be verified out-of-band (e.g. by recognizable voice communication).</p>
  338. <p>Furthermore, if retained secrets associated with a client/user combination 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, and the out-of-band verification would only need to be performed once to verify the absence of a Man in the Middle for all sessions between the parties (past, present and future). <note>This combination of techniques underpins the <cite>ZRTP</cite> key agreement protocol.</note></p>
  339. <p>Public keys are optional in the diagram below. It describes the same SIGMA-R with SAS key exchange protocol as the <link url='#foundations-skeleton-r'>SIGMA-R Overview</link>. It provides much more detail including the use of retained secrets and other secrets. The use of public keys is negotiated in the first two messages. Note: These <em>optional</em> security enhancements are especially important when the protocol is being used without public keys.</p>
  340. <p>The diagram does not specify any ESession-specific details. The differences between it and the <link url='#foundations-core-i'>SIGMA-I Key Exchange</link> are highlighted.</p>
  341. <code>
  342. <strong>ALICE</strong>&#160; <strong>BOB</strong>&#160;
  343. &NsubA; = <em>random</em>()
  344. x = <em>random</em>()
  345. e = &gsupx; mod p
  346. He = SHA256(e)
  347. He, &isPKsubA;
  348. ------------&gt;
  349. &isPKsubB;,&#160;&NsubA;&#160;
  350. &NsubB; = <em>random</em>()
  351. &CsubA; = <em>random</em>()
  352. &CBeCAx2n1;&#160;
  353. y = <em>random</em>()
  354. d = &gsupy; mod p
  355. d, &CsubA;, &NsubB;
  356. &lt;------------
  357. &isPKsubA;, &isPKsubB;&#160;
  358. &CBeCAx2n1;&#160;
  359. <em>assert</em> 1 &lt; d &lt; p-1
  360. K = HASH(&dsupx; mod p)
  361. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  362. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  363. &KSsubA; = <em>HMAC</em>(HASH, K, "Initiator SIGMA Key")
  364. &RSH1ARSHZA; = <em>HMAC</em>(HASH, &NsubA;, &RS1ARSZA;)
  365. <em>if</em>&#160;&isPKsubB;&#160;<em>equals false then:</em>&#160;
  366. &macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &RSH1ARSHZA;})
  367. &IDA; = <em>cipher</em>(&KCsubA;, &CsubA;, &macA;)
  368. <em>else:</em>&#160;
  369. &macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;, &RSH1ARSHZA;})
  370. &signA; = <em>sign</em>(&signKeyA;, &macA;)
  371. &IDA; = <em>cipher</em>(&KCsubA;, &CsubA;, {&pubKeyA;, &signA;})
  372. &MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)
  373. SAS = <em>truncate</em>(HASH(&MsubA; | d | "Short Authentication String"))&#160;
  374. &IDA;, &MsubA;
  375. ------------&gt;
  376. e, &RSH1ARSHZA;&#160;
  377. <em>assert</em>&#160;He = SHA256(e)
  378. SAS = <em>truncate</em>(HASH(&MsubA; | d | "Short Authentication String"))
  379. SAS
  380. &lt;===========&gt;
  381. <em>assert</em> 1 &lt; e &lt; p-1
  382. K = HASH(&esupy; mod p)
  383. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  384. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  385. &KSsubA; = <em>HMAC</em>(HASH, K, "Initiator SIGMA Key")&#160;
  386. <em>assert</em>&#160;&MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)
  387. <em>if</em>&#160;&isPKsubB;&#160;<em>equals false then:</em>&#160;
  388. &macA; = <em>decipher</em>(&KCsubA;, &CsubA;, &IDA;)
  389. <em>assert</em>&#160;&macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &RSH1ARSHZA;})
  390. <em>else:</em>&#160;
  391. {&pubKeyA;, &signA;} = <em>decipher</em>(&KCsubA;, &CsubA;, &IDA;)
  392. &macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;, &RSH1ARSHZA;})
  393. <em>verify</em>(&signA;, &pubKeyA;, &macA;)
  394. SRS = <em>choose</em>(&RS1BRSZB;, &RSH1ARSHZA;, &NsubA;)
  395. K = HASH(K | SRS | OSS)
  396. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  397. &KCsubB; = <em>HMAC</em>(HASH, K, "Responder Cipher Key")
  398. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  399. &KMsubB; = <em>HMAC</em>(HASH, K, "Responder MAC Key")
  400. &KSsubB; = <em>HMAC</em>(HASH, K, "Responder SIGMA Key")
  401. SRSH = <em>HMAC</em>(HASH, SRS, "Shared Retained Secret")
  402. <em>retain</em>(<em>HMAC</em>(HASH, K, "New Retained Secret"))
  403. <em>if</em>&#160;&isPKsubA;&#160;<em>equals false then:</em>&#160;
  404. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &CsubA;})
  405. &IDB; = <em>cipher</em>(&KCsubB;, &CsubB;, &macB;)&#160;
  406. <em>else:</em>&#160;
  407. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &CsubA;})
  408. &signB; = <em>sign</em>(&signKeyB;, &macB;)
  409. &IDB; = <em>cipher</em>(&KCsubB;, &CsubB;, {&pubKeyB;, &signB;})
  410. &MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)
  411. &IDB;
  412. &lt;------------
  413. &MsubB;, SRSH&#160;
  414. SRS = <em>choose</em>(&RS1ARSZA;, SRSH)
  415. K = HASH(K | SRS | OSS)
  416. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  417. &KCsubB; = <em>HMAC</em>(HASH, K, "Responder Cipher Key")
  418. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  419. &KMsubB; = <em>HMAC</em>(HASH, K, "Responder MAC Key")
  420. &KSsubB; = <em>HMAC</em>(HASH, K, "Responder SIGMA Key")
  421. <em>retain</em>(<em>HMAC</em>(HASH, K, "New Retained Secret"))
  422. <em>assert</em>&#160;&MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)
  423. <em>if</em>&#160;&isPKsubA;&#160;<em>equals false then:</em>&#160;
  424. &macB; = <em>decipher</em>(&KCsubB;, &CsubB;, &IDB;)
  425. <em>assert</em>&#160;&macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &CsubA;})
  426. <em>else:</em>&#160;
  427. {&pubKeyB;, &signB;} = <em>decipher</em>(&KCsubB;, &CsubB;, &IDB;)
  428. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &CsubA;})
  429. <em>verify</em>(&signB;, &pubKeyB;, &macB;)
  430. </code>
  431. </section2>
  432. </section1>
  433. <section1 topic='Cryptographic Design' anchor='design'>
  434. <p>This section provides an overview of the full ESession key-exchange protocol from a cryptographic point of view. This protocol is based on the <em>full fledge</em> protocol, as described in Appendix B of the <cite>SIGMA</cite> paper. It also uses <em>variant (ii)</em>, as described in Secion 5.4 of the same paper.</p>
  435. <section2 topic='ESession Parameter Descriptions' anchor='design-parameters'>
  436. <p>The table below describes the parameters that are not found in the <link url='#foundations-parameters'>Parameter Descriptions</link> tables above.</p>
  437. <table caption='ESession Negotiation Parameters'>
  438. <tr>
  439. <th>Parameter</th>
  440. <th>Description</th>
  441. </tr>
  442. <tr>
  443. <td>options</td>
  444. <td>Includes a set of possible values for each and every ESession parameter (see the ESession Request sub-section in <cite>Encrypted Session Negotiation</cite>), including sets of possible values for p, g, HASH, CIPHER, SIGN</td>
  445. </tr>
  446. <tr>
  447. <td>chosen</td>
  448. <td>Includes a chosen value for each ESession parameter</td>
  449. </tr>
  450. <tr>
  451. <td>CIPHER</td>
  452. <td>Selected CTR-mode block cipher algorithm</td>
  453. </tr>
  454. <tr>
  455. <td>DECIPHER</td>
  456. <td>Selected CTR-mode block decipher algorithm (corresponds to CIPHER)</td>
  457. </tr>
  458. <tr>
  459. <td>SIGN</td>
  460. <td>Selected signature algorithm</td>
  461. </tr>
  462. <tr>
  463. <td>VERIFY</td>
  464. <td>The selected signature verification algorithm (corresponds to SIGN)</td>
  465. </tr>
  466. <tr>
  467. <td>SASGEN</td>
  468. <td>The selected SAS generation algorithm</td>
  469. </tr>
  470. <tr>
  471. <td>&x1xZ;</td>
  472. <td>Alice's private Diffie-Hellman keys - each value corresponds to one of Z different DH groups</td>
  473. </tr>
  474. <tr>
  475. <td>&e1eZ;</td>
  476. <td>The choice of public Diffie-Hellman keys that Alice offers Bob - each value corresponds to one of Z different DH groups (and a different value of x)</td>
  477. </tr>
  478. <tr>
  479. <td>&He1HeZ;</td>
  480. <td>The list of hash commitments that Alice sends to Bob (hashes of &e1eZ;)</td>
  481. </tr>
  482. <tr>
  483. <td>*&signKeysA;</td>
  484. <td>All the private keys that Alice is able to use to create signatures</td>
  485. </tr>
  486. <tr>
  487. <td>*&signsB;</td>
  488. <td>The set of signatures of &formB; (one for each of Bob's private keys)</td>
  489. </tr>
  490. <tr>
  491. <td>*&pubKeysA;</td>
  492. <td>All of Alice's public keys that Bob has access to</td>
  493. </tr>
  494. </table>
  495. <p>* Offline negotiation only</p>
  496. </section2>
  497. <section2 topic='Online ESession-I Negotiation' anchor='design-online-i'>
  498. <p>Alice uses this protocol when Bob is Online. In addition to the key exchange described in the <link url='#foundations-core-i'>SIGMA-I Key Exchange</link> protocol above, she offers Bob a choice of Diffie-Hellman groups with her corresponding values of e, various algorithms and other parameters. The differences between this protocol and <link url='#design-online-r'>Online ESession-R Negotiation</link> are highlighted.</p>
  499. <!--The first two forms below negotiate policy, swap Diffie-Hellman public values and the ancillary data necessary for the exchange and authentication. The second message also authenticates the responder. The third message authenticates the initiator and exchanges the final Diffie-Hellman public value.-->
  500. <code>
  501. <strong>ALICE</strong>&#160; <strong>BOB</strong>&#160;
  502. &NsubA; = <em>random</em>()
  503. <em>for</em> g,p &#8712; options
  504. x = <em>random</em>()
  505. e = &gsupx; mod p
  506. &formA; = {&e1eZ;, options, &NsubA;}
  507. &formA;
  508. ---------&gt;
  509. chosen = {p,g,HASH,CIPHER,SIGN...} = <em>choose</em>(options)
  510. e = <em>choose</em>(&e1eZ;, p)
  511. &NsubB; = <em>random</em>()
  512. &CsubA; = <em>random</em>()
  513. &CBeCAx2n1;&#160;
  514. y = <em>random</em>()
  515. d = &gsupy; mod p
  516. &formB; = {&CsubA;, chosen, d, &NsubA;, &NsubB;}
  517. <em>assert</em> 1 &lt; e &lt; p-1
  518. K = HASH(&esupy; mod p)
  519. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  520. &KCsubB; = <em>HMAC</em>(HASH, K, "Responder Cipher Key")
  521. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  522. &KMsubB; = <em>HMAC</em>(HASH, K, "Responder MAC Key")
  523. &KSsubA; = <em>HMAC</em>(HASH, K, "Initiator SIGMA Key")
  524. &KSsubB; = <em>HMAC</em>(HASH, K, "Responder SIGMA Key")
  525. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &formB;})
  526. &signB; = SIGN(&signKeyB;, &macB;)
  527. &IDB; = CIPHER(&KCsubB;, &CsubB;, {&pubKeyB;, &signB;})
  528. &MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)&#160;
  529. &formB;
  530. &lt;---------
  531. &IDB;, &MsubB;&#160;
  532. <em>assert</em> chosen &#8712; options
  533. x = <em>choose</em>(&x1xZ;, p)
  534. e = &gsupx; mod p
  535. &CBeCAx2n1;&#160;
  536. <em>assert</em> 1 &lt; d &lt; p-1
  537. K = HASH(&dsupx; mod p)
  538. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  539. &KCsubB; = <em>HMAC</em>(HASH, K, "Responder Cipher Key")&#160;
  540. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  541. &KMsubB; = <em>HMAC</em>(HASH, K, "Responder MAC Key")&#160;
  542. &KSsubA; = <em>HMAC</em>(HASH, K, "Initiator SIGMA Key")
  543. &KSsubB; = <em>HMAC</em>(HASH, K, "Responder SIGMA Key")
  544. <em>assert</em>&#160;&MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)
  545. {&pubKeyB;, &signB;} = DECIPHER(&KCsubB;, &CsubB;, &IDB;)
  546. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &formB;})
  547. VERIFY(&signB;, &pubKeyB;, &macB;)&#160;
  548. &macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;, &formA;})
  549. &signA; = SIGN(&signKeyA;, &macA;)
  550. &IDA; = CIPHER(&KCsubA;, &CsubA;, {&pubKeyA;, &signA;})
  551. &MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)
  552. &IDA;
  553. ---------&gt;
  554. &MsubA;, &NsubB;&#160;
  555. <em>assert</em>&#160;&MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)
  556. {&pubKeyA;, &signA;} = DECIPHER(&KCsubA;, &CsubA;, &IDA;)
  557. &macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;, &formA;})
  558. VERIFY(&signA;, &pubKeyA;, &macA;)
  559. </code>
  560. </section2>
  561. <section2 topic='Online ESession-R Negotiation' anchor='design-online-r'>
  562. <p>This protocol is similar to the <link url='#design-online-i'>Online ESession-I Negotiation</link> above, except that Bob's identity is protected from active attacks (by by delaying communicating his identity to Alice until he has authenticated her). The optional use of SAS, retained secrets and other secrets means the protocol may be used without any public keys. The differences between this protocol and <link url='#design-online-i'>Online ESession-I Negotiation</link> are highlighted.</p>
  563. <code>
  564. <strong>ALICE</strong>&#160; <strong>BOB</strong>&#160;
  565. &NsubA; = <em>random</em>()
  566. <em>for</em> g,p &#8712; options
  567. x = <em>random</em>()
  568. e = &gsupx; mod p
  569. He = SHA256(e)&#160;
  570. &formA; = {&He1HeZ;, options, &NsubA;}
  571. &formA;
  572. ------------&gt;
  573. chosen = {p,g,HASH,CIPHER,SIGN,SASGEN,&isPKsubA;,&isPKsubB;...} = <em>choose</em>(options)
  574. He = <em>choose</em>(&He1HeZ;, p)
  575. &NsubB; = <em>random</em>()
  576. &CsubA; = <em>random</em>()
  577. &CBeCAx2n1;&#160;
  578. y = <em>random</em>()
  579. d = &gsupy; mod p
  580. &formB; = {&CsubA;, chosen, d, &NsubA;, &NsubB;}
  581. &formB;
  582. &lt;------------
  583. <em>assert</em> chosen &#8712; options
  584. x = <em>choose</em>(&x1xZ;, p)
  585. e = <em>choose</em>(&e1eZ;, p)
  586. &CBeCAx2n1;&#160;
  587. <em>assert</em> 1 &lt; d &lt; p-1
  588. K = HASH(&dsupx; mod p)
  589. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  590. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  591. &KSsubA; = <em>HMAC</em>(HASH, K, "Initiator SIGMA Key")
  592. &RSH1ARSHZA; = <em>HMAC</em>(HASH, &NsubA;, &RS1ARSZA;)
  593. &formA2; = {&RSH1ARSHZA;, e, &NsubB;}
  594. <em>if</em>&#160;&isPKsubB;&#160;<em>equals false then:</em>&#160;
  595. &macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &formA;, &formA2;})
  596. &IDA; = CIPHER(&KCsubA;, &CsubA;, &macA;)
  597. <em>else:</em>&#160;&#160;
  598. &macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;, &formA;, &formA2;})
  599. &signA; = SIGN(&signKeyA;, &macA;)
  600. &IDA; = CIPHER(&KCsubA;, &CsubA;, {&pubKeyA;, &signA;})
  601. &MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)
  602. SAS = SASGEN(&MsubA;, &formB;)&#160;
  603. &IDA;, &MsubA;
  604. ------------&gt;
  605. &formA2;&#160;
  606. <em>assert</em>&#160;He = SHA256(e)
  607. SAS = SASGEN(&MsubA;, &formB;)
  608. SAS
  609. &lt;===========&gt;
  610. <em>assert</em> 1 &lt; e &lt; p-1
  611. K = HASH(&esupy; mod p)
  612. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  613. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  614. &KSsubA; = <em>HMAC</em>(HASH, K, "Initiator SIGMA Key")
  615. <em>assert</em>&#160;&MsubA; = <em>HMAC</em>(HASH, &KMsubA;, &CsubA;, &IDA;)
  616. <em>if</em>&#160;&isPKsubB;&#160;<em>equals false then:</em>&#160;
  617. &macA; = DECIPHER(&KCsubA;, &CsubA;, &IDA;)
  618. <em>assert</em>&#160;&macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &formA;, &formA2;})
  619. <em>else:</em>&#160;
  620. {&pubKeyA;, &signA;} = DECIPHER(&KCsubA;, &CsubA;, &IDA;)
  621. &macA; = <em>HMAC</em>(HASH, &KSsubA;, {&NsubB;, &NsubA;, e, &pubKeyA;, &formA;, &formA2;})
  622. VERIFY(&signA;, &pubKeyA;, &macA;)
  623. SRS = <em>choose</em>(&RS1BRSZB;, &RSH1ARSHZA;, &NsubA;)
  624. K = HASH(K | SRS | OSS)
  625. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  626. &KCsubB; = <em>HMAC</em>(HASH, K, "Responder Cipher Key")
  627. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  628. &KMsubB; = <em>HMAC</em>(HASH, K, "Responder MAC Key")
  629. &KSsubB; = <em>HMAC</em>(HASH, K, "Responder SIGMA Key")
  630. <em>if</em> SRS <em>equals false then:</em>&#160;
  631. SRS = <em>random</em>()
  632. SRSH = <em>HMAC</em>(HASH, SRS, "Shared Retained Secret")
  633. <em>retain</em>(<em>HMAC</em>(HASH, K, "New Retained Secret"))
  634. &formB2; = {&NsubA;, SRSH}
  635. <em>if</em>&#160;&isPKsubA;&#160;<em>equals false then:</em>&#160;
  636. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &formB;, &formB2;})
  637. &IDB; = CIPHER(&KCsubB;, &CsubB;, &macB;)&#160;
  638. <em>else:</em>&#160;
  639. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &formB;, &formB2;})
  640. &signB; = SIGN(&signKeyB;, &macB;)
  641. &IDB; = CIPHER(&KCsubB;, &CsubB;, {&pubKeyB;, &signB;})
  642. &MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)
  643. &IDB;, &MsubB;&#160;
  644. &lt;------------
  645. &formB2;&#160;
  646. SRS = <em>choose</em>(&RS1ARSZA;, SRSH)
  647. K = HASH(K | SRS | OSS)
  648. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  649. &KCsubB; = <em>HMAC</em>(HASH, K, "Responder Cipher Key")
  650. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  651. &KMsubB; = <em>HMAC</em>(HASH, K, "Responder MAC Key")
  652. &KSsubB; = <em>HMAC</em>(HASH, K, "Responder SIGMA Key")
  653. <em>retain</em>(<em>HMAC</em>(HASH, K, "New Retained Secret"))
  654. <em>assert</em>&#160;&MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)
  655. <em>if</em>&#160;&isPKsubA;&#160;<em>equals false then:</em>&#160;
  656. &macB; = DECIPHER(&KCsubB;, &CsubB;, &IDB;)
  657. <em>assert</em>&#160;&macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &formB;, &formB2;})
  658. <em>else:</em>&#160;
  659. {&pubKeyB;, &signB;} = DECIPHER(&KCsubB;, &CsubB;, &IDB;)
  660. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &formB;, &formB2;})
  661. VERIFY(&signB;, &pubKeyB;, &macB;)
  662. </code>
  663. </section2>
  664. <section2 topic='Offline ESession Negotiation' anchor='design-offline'>
  665. <p>Bob uses this protocol to send stanzas to Alice when she is Offline. Note: Since the full <cite>SIGMA</cite> protocol cannot be used if Alice is offline, her identity is not protected at all.</p>
  666. <p>The diagram is split into three phases. First Alice publishes her ESession options before going offline. Later Bob completes the key exchange (and sends her encrypted stanzas that are not shown below) these are all stored by Alice's server. Finally when Alice comes online again she verifies and calculates the decryption key.</p>
  667. <p>The differences between this offline protocol and the <link url='#design-online-i'>Online ESession-I Negotiation</link> protocol above are highlighted in the diagram below.</p>
  668. <code>
  669. <strong>ALICE</strong>&#160; <strong>ALICE'S SERVER</strong>&#160; <strong>BOB</strong>&#160;
  670. &NsubA; = <em>random</em>()
  671. <em>for</em> g,p &#8712; options
  672. x = <em>random</em>()
  673. e = &gsupx; mod p
  674. &formA; = {&e1eZ;, options, &NsubA;}
  675. &signsA; = <em>multi_sign</em>(&signKeysA;, &formA;)
  676. <em>retain</em>(&NsubA;, &x1xZ;, expireTime)&#160;
  677. &formA;
  678. --------&gt;
  679. &signsA;&#160;
  680. <em>retain</em>(&formA;, &signsA;)
  681. ---------------------------------------------------------------------------------------------------------
  682. <em>retrieve</em>(&formA;, &signsA;)&#160;
  683. &formA;
  684. --------&gt;
  685. &signsA;&#160;
  686. <em>verify_one</em>(&signsA;, &pubKeysA;, &formA;)
  687. chosen = {p,g,HASH,CIPHER,SIGN...} = <em>choose</em>(options)
  688. e = <em>choose</em>(&e1eZ;, p)
  689. &CsubA; = <em>random</em>()
  690. y = <em>random</em>()
  691. d = &gsupy; mod p
  692. &CBeCAx2n1;&#160;
  693. &NsubB; = <em>random</em>()
  694. &formB; = {&CsubA;, chosen, d, &NsubA;, &NsubB;}
  695. <em>assert</em> 1 &lt; e &lt; p-1
  696. K = HASH(&esupy; mod p)
  697. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  698. &KCsubB; = <em>HMAC</em>(HASH, K, "Responder Cipher Key")
  699. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  700. &KMsubB; = <em>HMAC</em>(HASH, K, "Responder MAC Key")
  701. &KSsubA; = <em>HMAC</em>(HASH, K, "Initiator SIGMA Key")
  702. &KSsubB; = <em>HMAC</em>(HASH, K, "Responder SIGMA Key")
  703. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &formB;})
  704. &signB; = SIGN(&signKeyB;, &macB;)
  705. &IDB; = CIPHER(&KCsubB;, &CsubB;, {&pubKeyB;, &signB;})
  706. &MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)
  707. &formB;
  708. &lt;--------
  709. &IDB;, &MsubB;&#160;
  710. <em>retain</em>(&formB;,&IDB;,&MsubB;)
  711. ---------------------------------------------------------------------------------------------------------
  712. <em>retrieve</em>(&formB;,&IDB;,&MsubB;)(&formB;,&IDB;,&MsubB;)
  713. ---------------------------------------------------------------------------------------------------------
  714. <em>retrieve</em>(&formB;,&IDB;,&MsubB;)(&formB;,&IDB;,&MsubB;)
  715. ---------------------------------------------------------------------------------------------------------
  716. <em>retrieve</em>(&formB;,&IDB;,&MsubB;)(&formB;,&IDB;,&MsubB;)
  717. ---------------------------------------------------------------------------------------------------------
  718. <em>retrieve</em>(&formB;,&IDB;,&MsubB;)&#160;
  719. &formB;
  720. &lt;--------
  721. &IDB;, &MsubB;&#160;
  722. <em>retrieve</em>(&NsubA;, &x1xZ;, expireTime)
  723. <em>assert</em> now &lt; expireTime&#160;
  724. <em>assert</em> chosen &#8712; options
  725. x = <em>choose</em>(&x1xZ;, p)
  726. e = &gsupx; mod p
  727. &CBeCAx2n1;&#160;
  728. <em>assert</em> 1 &lt; d &lt; p-1
  729. K = HASH(&dsupx; mod p)
  730. &KCsubA; = <em>HMAC</em>(HASH, K, "Initiator Cipher Key")
  731. &KCsubB; = <em>HMAC</em>(HASH, K, "Responder Cipher Key")
  732. &KMsubA; = <em>HMAC</em>(HASH, K, "Initiator MAC Key")
  733. &KMsubB; = <em>HMAC</em>(HASH, K, "Responder MAC Key")
  734. &KSsubA; = <em>HMAC</em>(HASH, K, "Initiator SIGMA Key")
  735. &KSsubB; = <em>HMAC</em>(HASH, K, "Responder SIGMA Key")
  736. <em>assert</em>&#160;&MsubB; = <em>HMAC</em>(HASH, &KMsubB;, &CsubB;, &IDB;)
  737. {&pubKeyB;, &signB;} = DECIPHER(&KCsubB;, &CsubB;, &IDB;)
  738. &macB; = <em>HMAC</em>(HASH, &KSsubB;, {&NsubA;, &NsubB;, d, &pubKeyB;, &formB;})
  739. VERIFY(&signB;, &pubKeyB;, &macB;)
  740. </code>
  741. <p>Note: &KMsubB; is necessary only to allow Bob to terminate the ESession if he comes online before Alice terminates it. The calculation of &KCsubB; and &KSsubB; is not strictly necessary.</p>
  742. </section2>
  743. </section1>
  744. <section1 topic='Security Considerations' anchor='sec'>
  745. <p>The security considerations are described in <cite>Encrypted Session Negotiation</cite> and <cite>Offline Encrypted Sessions</cite>.</p>
  746. </section1>
  747. <section1 topic='IANA Considerations' anchor='iana'>
  748. <p>This document requires no interaction with &IANA;. </p>
  749. </section1>
  750. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  751. <p>This document requires no interaction with the &REGISTRAR;.</p>
  752. </section1>
  753. <section1 topic='Acknowledgments' anchor='acknowledgments'>
  754. <p>The author would like to thank: Ian Goldberg for the time he spent reviewing an early version of this protocol and for his invaluable suggestions and comments; and Hugo Krawczyk for his general advice and encouragment. The author of this document is entirely responsable for any errors it contains.</p>
  755. </section1>
  756. </xep>