<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd'[
<!ENTITY RFC2119 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC4279 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4279.xml">
<!ENTITY RFC4492 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4492.xml">
<!ENTITY RFC5116 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5116.xml">
<!ENTITY RFC5246 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5246.xml">
<!ENTITY RFC6066 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6066.xml">
<!ENTITY RFC6090 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6090.xml">
<!ENTITY RFC6347 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6347.xml">
<!ENTITY RFC6655 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6655.xml">
<!ENTITY RFC7251 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7251.xml">
<!ENTITY RFC7252 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7252.xml">
]>

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>

<?rfc toc="yes" ?>
<?rfc tocompact="yes" ?>
<?rfc tocdepth="3" ?>
<?rfc tocindent="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="no" ?>
<?rfc comments="yes" ?>
<?rfc inline="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>

<rfc category="info" docName="draft-cragie-tls-ecjpake-01" ipr="trust200902">

  <front>
    <title abbrev="ECJPAKE">Elliptic Curve J-PAKE Cipher Suites for Transport Layer Security (TLS)</title>

    <author fullname="Robert Cragie" initials="R." surname="Cragie">
      <organization>ARM Ltd.</organization>
      <address>
        <postal>
          <street>110 Fulbourn Road</street>
          <city>Cambridge</city>
          <code>CB1 9NJ</code>
          <country>UK</country>
        </postal>
        <email>robert.cragie@arm.com</email>
      </address>
    </author>
    
    <author fullname="Feng Hao" initials="F." surname="Hao">
      <organization>Newcastle University (UK)</organization>
      <address>
        <postal>
          <street>Claremont Tower, School of Computing Science, Newcastle University</street>
          <city>Newcastle upon Tyne</city>
          <code>NE1 7RU</code>
          <country>UK</country>
        </postal>
        <email>feng.hao@ncl.ac.uk</email>
      </address>
    </author>

    <date />

    <area>Security Area</area>

    <workgroup>tls</workgroup>

    <keyword>tls</keyword>
    <keyword>elliptic curve</keyword>
    <keyword>j-pake</keyword>

    <abstract>
      <t>This document defines new cipher suites based on an Elliptic Curve Cryptography (ECC) variant of Password Authenticated Key Exchange by Juggling (J-PAKE) for the Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS) protocols.</t>
    </abstract>
  </front>

  <middle>
    <section anchor="intro" title="Introduction">
      <t>This document defines new cipher suites based on an Elliptic Curve Cryptography (ECC) variant of Password Authenticated Key Exchange by Juggling (J-PAKE) for version 1.2 of Transport Layer Security (TLS) protocol <xref target="RFC5246" /> as well as version 1.2 of the Datagram Transport Layer Security (DTLS) protocol <xref target="RFC6347" />. The cipher suites are AEAD cipher suites using AES-CCM <xref target="CCM" /> based on the cipher suites defined in <xref target="RFC7251" />, using ECJ-PAKE as an alternative key establishment mechanism.</t>
      <t>The existing set of TLS cipher suites are typically aimed at more traditional client-server interactions, for example, a web browser to web server. However, TLS and DTLS are increasingly being specified for use in Internet-of-Things (IoT) standards for peer-to-peer application layer interaction. For example, DTLS is specified as a binding to provide security for the CoAP protocol <xref target="RFC7252" />, which is widely used in IoT applications.</t>
      <t>J-PAKE is a balanced password-authenticated key exchange (PAKE) protocol resistant to off-line dictionary attack designed by Feng Hao and Peter Ryan in 2008 <xref target="HR08" />. The use of a PAKE for IoT devices is highly appropriate as it allows a simple method of commissioning IoT devices onto a network without requiring certificates to be issued and maintained for each device. An ECC variant of J-PAKE <xref target="J-PAKE" /> is particularly suited to IoT devices, which are often constrained with regard to memory and processing power. The cipher suite TLS_ECJPAKE_WITH_AES_128_CCM_8 as defined in this document is currently being used in the Thread protocol <xref target="THREAD" />.</t>
      
      <section title="Requirements Language">
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in <xref target="RFC2119" />.</t>
      </section>
      
      <section title="Terminology">
        <t>AEAD
          <list>
            <t>Authenticated Encryption with Associated Data.</t>
          </list>
        </t>
        
        <t>ECJ-PAKE
          <list>
            <t>Elliptic Curve Cryptography (ECC) variant of Password Authenticated Key Exchange by Juggling (J-PAKE).</t>
          </list>
        </t>

        <t>ZKP
          <list>
            <t>Zero-knowledge proof.</t>
          </list>
        </t>
       </section>
    </section>

    <section title="ECJ-PAKE Based AES-CCM Cipher Suites">
      <t>The cipher suites defined in this document are based on the AES-CCM Authenticated Encryption with Associated Data (AEAD) algorithms AEAD_AES_128_CCM and AEAD_AES_256_CCM described in <xref target="RFC5116" />. The following cipher suites are defined:</t>
      <figure><artwork><![CDATA[
    TLS_ECJPAKE_WITH_AES_128_CCM = {0xTBD, 0xTBD}
    TLS_ECJPAKE_WITH_AES_256_CCM = {0xTBD, 0xTBD}
    TLS_ECJPAKE_WITH_AES_128_CCM_8 = {0xTBD, 0xTBD}
    TLS_ECJPAKE_WITH_AES_256_CCM_8 = {0xTBD, 0xTBD}
]]></artwork></figure>
      <t>These cipher suites make use of the AEAD capability in TLS 1.2 <xref target="RFC5246" />. Cipher suites ending with "8" use eight-octet authentication tags; the other cipher suites have 16-octet authentication tags. The HMAC truncation option described in Section 7 of <xref target="RFC6066" /> (which negotiates the "truncated_hmac" TLS extension) does not have an effect on the cipher suites defined in this document, because they do not use HMAC to protect TLS records.</t>
      <t>The "nonce" input to the AEAD algorithm is as defined in <xref target="RFC6655" />.</t>
      <t>These cipher suites make use of the default TLS 1.2 Pseudorandom Function (PRF), which uses HMAC with the SHA-256 hash function.</t>
      <t>The following stipulations apply to the use of elliptic curves:</t>
      <t><list style="symbols">
       <t>Curves with a cofactor equal to one SHOULD be used; this simplifies their use.</t>
       <t>The uncompressed point format MUST be supported.  Other point formats MAY be used.</t>
       <t>Fundamental ECC algorithms <xref target="RFC6090" /> MAY be used as an implementation method.</t>
       <t>A particular implementation MUST use only a single curve (see <xref target="fixed_param" />)</t>
      </list></t>
    </section>
    
    <section anchor="fixed_param" title="Specific Fixed Implementation Parameters">
    <t>It is expected that TLS-ECJ-PAKE is used in applications where parameters applying to the particular TLS-ECJ-PAKE implementation are fixed and known to the application a priori. For this reason, certain capability negotiations usually associated with TLS are not present in TLS-ECJ-PAKE. This restricts its use to applications where such parameters can be applied a priori, for example as is the case in Thread <xref target="THREAD" />.</t> 
    <t>Parameters which MUST be fixed prior to implementation are:</t>
    <texttable anchor="tbl1" title="Fixed implementation parameters">
      <ttcol align="left">Parameter</ttcol>
      <c>Choice of single elliptic curve</c>
      <c>Presence or absence of identity</c>
    </texttable>
    </section>

    <section title="Notations">
      <t>This section describes the notations used in this document.</t>
      <section title="Elliptic Curve Points">
        <t>The generator (base point) of an elliptic curve is represented by the letter 'G':</t>
        <t><list style="empty">
         <t>G</t>
        </list></t>
        <t>A modified generator is represented by the letter 'G' concatenated with a single uppercase character:</t>
        <t><list style="empty">
         <t>GB</t>
        </list></t>
        <t>Elliptic curve points are represented using a single uppercase character or a single uppercase character concatenated with a single lowercase character or decimal digit, for example:</t>
        <t><list style="empty">
         <t>X</t>
         <t>Xc</t>
         <t>X2</t>
        </list></t>
        <t>Conversion to and from elliptic curve points to octet strings is as specified in Sections 2.3.3 and 2.3.4 of <xref target="SEC1" />.</t>
        <t>Point multiplication is shown as an elliptic curve point multiplied by a scalar integer using the '*' operator, for example:</t>
        <t><list style="empty">
         <t>G*x</t>
        </list></t>
        <t>Point addition or subtraction is shown as the addition or subtraction of elliptic curve points or scalar multiplied elliptic curve points using the '+' and '-' operators respectively, for example:</t>
        <t><list style="empty">
         <t>X1 + X3 + X4</t>
         <t>X*h + G*r</t>
         <t>Xs - X4*x2*s</t>
        </list></t>
      </section>
      
      <section title="Integers">
        <t>Integers are represented using a single lowercase character or a single lowercase character followed by a single lowercase character or decimal digit, for example:</t>
        <t><list style="empty">
          <t>x</t>
          <t>xc</t>
          <t>x2</t>
        </list></t>
        <t>Where expressed, integers are shown in hexadecimal and/or decimal form. Hexadecimal numbers have an '0x' prefix. For example:</t>
        <t><list style="empty">
         <t>0x12ab34cd</t>
         <t>3132110061</t>
        </list></t>
        <t>Integer multiplication is shown as two integers multiplied together using the '*' operator:</t>
        <t><list style="empty">
         <t>x*s</t>
        </list></t>
        <t>Integer addition or subtraction is shown as the addition or subtraction of integers or multiplied integers using the '+' and '-' operators respectively:</t>
        <t><list style="empty">
         <t>v - x*h</t>
        </list></t>
      </section>
      
      <section title="Octet Strings">
      <t>Octet strings are expressed in a hexadecimal form, with no '0x' prefix and with a space separator, first octet leftmost, for example:</t>
        <t><list style="empty">
         <t>12 ab 34 cd</t>
        </list></t>
      </section>
    
      <section anchor="int_to_oct" title="Integer to Octet String Conversion">
      <t>Integer to octet string conversion SHALL be performed as stated in Section 2.3.7 of <xref target="SEC1" />. It is represented as follows:</t>
        <t><list style="empty">
         <t>M = str(mlen, x)</t>
        </list></t>
        <t>where x, mlen, and M are the parameters as stated in Section 2.3.7 of <xref target="SEC1" />.</t>
      </section>
      
      <section anchor="oct_to_int" title="Octet String to Integer Conversion">
        <t>Octet string to integer conversion SHALL be as stated in section 2.3.8 of <xref target="SEC1" />. It is represented as follows:</t>
        <t><list style="empty">
         <t>x = int(mlen, M)</t>
        </list></t>
        <t>where x, mlen, and M are the parameters as stated in Section 2.3.8 of <xref target="SEC1" />.</t>
      </section>

    </section>

    <section title="Handshake">
      <t>The TLS-ECJ-PAKE handshake is as follows, augmented with parameters in braces to show the ECJ-PAKE material conveyed in each case:</t>
      <figure><artwork><![CDATA[
       Client                                        Server
       ------                                        ------
       ClientHello          -------->
       {(X1,ZKP(X1)),
       (X2,ZKP(X2))}                            ServerHello
                                            {(X3, ZKP(X3)),
                                             (X4, ZKP(X4))}
                                          ServerKeyExchange
                                              {Xs, ZKP(Xs)}
                            <--------       ServerHelloDone
       ClientKeyExchange
       {Xc, ZKP(Xc)}
       [ChangeCipherSpec]
       Finished             -------->
                                         [ChangeCipherSpec]
                            <--------              Finished
       Application Data     <------->      Application Data
]]></artwork><postamble>Figure 1: Message flow in a TLS-ECJ-PAKE handshake</postamble></figure>

    </section>
    
    <section title="Failure processing">
      <t>If there are failures for any reason on client or server side, for example, Schnorr ZKP verification or missing extensions, the handshake SHALL abort immediately and send a TLS Error Alert message to the peer, using code 40 (handshake_failure) (see Section 7.2 of <xref target="RFC5246" />).</t>
    </section>
    
    <section title="ECJ-PAKE TLS Extensions and Modification">
      <t>This section describes existing and newly-defined extensions required for ECJ-PAKE-TLS. The guiding principle for extension use is to adhere as closely as possible to <xref target="RFC4492" />.</t>
      <section title="New Structure Definitions">
        <t>TLS-ECJ-PAKE requires new structure definitions for:</t>
        <t><list style="symbols">
          <t>Public key and Schnorr ZKP pair</t>
          <t>Schnorr ZKP</t>
        </list></t>
          
        <section title="Public Key and Schnorr ZKP Pair">
          <t>The TLS structure is as follows:</t>
          <t><figure><artwork><![CDATA[
    struct {
        ECPoint X;
        ECSchnorrZKP zkp;
    } ECJPAKEKeyKP;
]]></artwork></figure></t>
          <t>X
            <list>
              <t>Public key represented as an elliptic curve point. ECPoint is defined in <xref target="RFC4492" />.</t>
            </list>
          </t>
          <t>zkp
            <list>
              <t>ECSchnorrZKP is defined in <xref target="schnorr_zkp" />.</t>
            </list>
          </t>
        </section>
          
        <section anchor="schnorr_zkp" title="Schnorr ZKP">
          <t>The TLS structure is as follows:</t>
          <t><figure><artwork><![CDATA[
    struct {
        ECPoint V;
        opaque r<1..2^8-1>;
    } ECSchnorrZKP;
]]></artwork></figure></t>
          <t>V
            <list>
              <t>Ephemeral public key represented as an elliptic curve point. ECPoint is defined in <xref target="RFC4492" />.</t>
            </list>
          </t>
          <t>r
            <list>
              <t>Schnorr signature.</t>
            </list>
          </t>
        </section>
        
      </section>

      <section title="ClientHello and ServerHello TLS Extensions">
        <section title="Existing Extensions">
          <t>The following TLS extensions defined in Section 4 of <xref target="RFC4492" /> SHALL be present in ClientHello:</t>
          <t><list style="symbols">
            <t>Supported Elliptic Curves Extension (NamedCurve, EllipticCurveList)</t>
            <t>Supported Point Formats Extension (ECPointFormat, ECPointFormatList) </t>
          </list></t>
          <t>and the following TLS extension defined in Section 4 of <xref target="RFC4492" /> SHALL be present in ServerHello:</t>
          <t><list style="symbols">
            <t>Supported Point Formats Extension (ECPointFormat, ECPointFormatList) </t>
          </list></t>
          <t>EllipticCurveList in ClientHello SHALL contain only one entry corresponding to the fixed elliptic curve chosen for the implementation (see <xref target="fixed_param" />).</t>
        </section>
        <section title="Additional Extensions">
          <t>The following extension SHALL additionally be present in both ClientHello and ServerHello:</t>
          <t><figure><artwork><![CDATA[
    enum { ecjpake_key_kp_pair(TBC) } ExtensionType;

    struct {
        opaque identity<0..2^16-1>;
        ECJPAKEKeyKP ecjpake_key_kp_pair_list[2];
    } ECJPAKEKeyKPPairList;
]]></artwork></figure></t>
          <t>identity
            <list>
              <t>Included if the Client or Server needs to uniquely identify themselves to the other party. An identity is used in the Schnorr ZKP hash calculation (see <xref target="zkp_hash_calc" />). The identity field SHALL be elided where an implementation has chosen absence of identity (see <xref target="fixed_param" />).</t>
            </list>
          </t>
          <t>ecjpake_key_kp_pair_list
            <list>
              <t>The list is precisely two elements long. The list in a ClientHello extension conveys public keys X1 and X2 and the list in a ServerHello extension conveys public keys X3 and X4, with associated Schnorr ZKPs.</t>
            </list>
          </t>
          <t>Note: When used in conjunction with DTLS and denial-of-service countermeasures as described in Section 4.2.1 of <xref target="RFC6347" />, the ECJPAKEKeyKPPairList in the subsequent ClientHello message SHALL be the same as the ECJPAKEKeyKPPairList in initial ClientHello message, i.e. the public keys X1 and X2 and associated Schnorr ZKPs SHALL be the same.</t> 
        </section>
        
      </section>

      <section title="ServerKeyExchange">
        <t>ServerKeyExchange is extended as follows:</t>
        <t><figure><artwork><![CDATA[
    enum { ecjpake } KeyExchangeAlgorithm;
]]></artwork></figure></t>
          <t>ecjpake
            <list>
              <t>Indicates the ServerKeyExchange message contains ServerECJPAKEParams.</t>
            </list>
          </t>
        <t>ServerKeyExchange for ecjpake SHALL be formatted as follows:</t>
        <figure><artwork><![CDATA[
    struct {
        ECParameters curve_params;
        ECJPAKEKeyKP ecjpake_key_kp;
    } ServerECJPAKEParams;

    select (KeyExchangeAlgorithm) {
        case ecjpake:
            ServerECJPAKEParams params;
    } ServerKeyExchange;
]]></artwork></figure>
      </section>
      
      <section title="ClientKeyExchange">
        <t>ClientKeyExchange is extended as follows:</t>
        <t><figure><artwork><![CDATA[
    enum { ecjpake } KeyExchangeAlgorithm;
]]></artwork></figure></t>
          <t>ecjpake
            <list>
              <t>Indicates the ClientKeyExchange message contains ClientECJPAKEParams.</t>
            </list>
          </t>
        <t>ClientKeyExchange for ecjpake SHALL be formatted as follows:</t>
        <figure><artwork><![CDATA[
    struct {
        ECJPAKEKeyKP ecjpake_key_kp;
    } ClientECJPAKEParams;

    select (KeyExchangeAlgorithm) {
        case ecjpake:
            ClientECJPAKEParams params;
    } ClientKeyExchange;
]]></artwork></figure>
      </section>
      
    </section>

    <section title="Calculations">
      <t>This section describes the calculations required to populate the data conveyed between Client and Server and also calculations required to verify knowledge proofs.</t>
      <t>The following notation is used throughout this section:</t>
      <t><list style="empty">
        <t>Order of the base point: n</t>
      </list></t>
      
      <section anchor="user_id_selection" title="User Identity Selection">
        <t>The Schnorr ZKP hash calculation requires non-confidential user identities. These identities need to be unique in the context of a transaction and be different for each party. In a peer-to-peer transaction where there is no ambiguity of identity, the identities can be a simple string representing the Client and Server respectively:</t>
        <texttable anchor="tbl2" title="Simple Client and Server identities">
          <ttcol align="left">Originator</ttcol>
          <ttcol align="left">Name</ttcol>
          <ttcol align="left">Identity</ttcol>
          <ttcol align="left">Length of identity</ttcol>
          <c>Client</c><c>"client"</c><c>63 6c 69 65 6e 74</c><c>6</c>
          <c>Server</c><c>"server"</c><c>73 65 72 76 65 72</c><c>6</c>
        </texttable>
        <t>In a multi-party transaction, each party SHOULD additionally provide an identity in the ClientHello and/or ServerHello to uniquely distinguish their user identity.</t>
      </section>
      
      <section anchor="zkp_hash_calc" title="Schnorr ZKP Hash Calculation">
        <t>The hash calculation is defined as follows:</t>
        <texttable anchor="tbl3" title="Schnorr ZKP Hash Calculation">
          <ttcol align="left">Public Key</ttcol>
          <ttcol align="left">Calculation</ttcol>
          <c>X1, X2, X3 and X4</c><c>h = SHA-256(G, V, X, ID) mod n</c>
          <c>Xs</c><c>h = SHA-256(GB, V, Xs, IDs) mod n</c>
          <c>Xc</c><c>h = SHA-256(GA, V, Xc, IDc) mod n</c>
        </texttable>
        <t>Each item in the hash calculation is prepended with its length in octets represented an octet (length 4), formed by applying integer to octet string conversion as defined in <xref target="int_to_oct" />. For example, the length of an uncompressed octet string representation of a public key is 65 (decimal) therefore the octet string (length 4) representation of 65 in hexadecimal is:</t>
        <t><list style="symbols">
          <t>00 00 00 41</t>
        </list></t>
        <t>Each public key (elliptic curve point) is first converted to an octet string according to Section 2.3.3 of <xref target="SEC1" />.</t>
        <t>The concatentation order of the hash is as follows:</t>
        <t><list style="numbers">
          <t>G (or GA, GB): Generator</t>
          <t>V: ZKP ephemeral public key</t>
          <t>X (or Xs, Xc): Public key to be verified</t>
          <t>ID (or IDc, IDs): User ID (see <xref target="user_id_selection" />)</t>
        </list></t>
        <t>The hash is therefore performed on the concatenation as follows:</t>
        <t><list style="symbols">
          <t>H = SHA-256(lenG || G || lenV || V || lenX || X || lenID || ID)</t>
        </list></t>
        <t>An integer representation of the hash (see <xref target="oct_to_int" />) is produced:</t>
        <t><list style="symbols">
          <t>h = int(H)</t>
        </list></t>
      </section>
          
      <section anchor="shared_secret_conv" title="Shared Secret">
        <t>The shared secret for the ServerKeyExchange and ClientKeyExchange calculations is required to be an integer in the range 1 to n-1. This section shows an example of how this could be practically accomplished using an initial password. The initial password is usually represented visually as a variable length character string using a subset of internationally recognized characters from the UTF-8 character set, which prevents the possibility of the resulting shared secret having the value 0. The initial password is then be converted into an octet string &lt;password&gt; using UTF-8 conversion. The integer shared secret calculation is thus defined as follows, using the function defined in <xref target="oct_to_int" />:</t>
        <t><list style="empty">
          <t>s = int(&lt;password&gt;) mod n</t>
        </list></t>
        <section title="Example">
          <t>Password:</t>
          <t><list style="empty">
            <t>"d45yj8e"</t>
          </list></t>
          <t>Equivalent octet string M using UTF-8 conversion (no null termination):</t>
          <t><list style="empty">
            <t>64 34 35 79 6a 38 65</t>
          </list></t>
          <t>Length mlen:</t>
          <t><list style="empty">
            <t>7</t>
          </list></t>
          <t>Shared secret:</t>
          <t><list style="empty">
            <t>0x643435796a3865</t>
            <t>28204901945981028 (decimal)</t>
          </list></t>
        </section>
      </section>
      
      <section title="ClientHello and ServerHello Calculations">
      
        <t>The structure ECJPAKEKeyKPPairList conveys the public key and associated Schnorr ZKP for ClientHello (X1 and X2) and ServerHello (X3 and X4).</t>
        
        <section title="Public Key Generation">
          <t>For X1, X2, X3 and X4, the value for the public key part X of the ECJPAKEKeyKP structure is generated as follows:</t>
          <t>The inputs are:</t>
          <t><list style="symbols">
            <t>Base point: G</t>
            <t>Order of the base point: n</t>
          </list></t>
          <t>The public key of the key pair is calculated as follows:</t>
          <t><list style="numbers">
            <t>A random integer in the range 1 to n-1 is assigned to private key x.</t>
            <t>A public key associated with x is generated and assigned to X:
            <list style="empty">
              <t>X = G*x</t>
            </list></t>
            <t>X is assigned to the public key part X of the ECJPAKEKeyKP structure.</t>
          </list></t>
        </section>
        
        <section title="Schnorr ZKP Generation">
          <t>For X1, X2, X3 and X4, the values for the ZKP part zkp.V and zkp.r of the ECJPAKEKeyKP structure are generated as follows:</t>
          <t>The inputs are:</t>
          <t><list style="symbols">
            <t>Base point: G</t>
            <t>Order of the base point: n</t>
            <t>Identity of originator: ID (IDc or IDs depending on context)</t>
            <t>Key pair to provide a ZKP of: (X,x) (public key: X, private key: x), where X is X1, X2, X3, or X4 and x is x1, x2, x3, or x4, depending on context</t>
          </list></t>
          <t>The ZKP is generated as follows:</t>
          <t><list style="numbers">
            <t>A random integer in the range 1 to n-1 is assigned to ephemeral private key v.</t>
            <t>An ephemeral public key associated with v is generated and assigned to V:
            <list style="empty">
              <t>V = G*v</t>
            </list></t>
            <t>An integer representation of a hash (see <xref target="zkp_hash_calc" />) is generated and assigned to h:
            <list style="empty">
              <t>h = int(SHA-256(G, V, X, ID)) mod n</t>
            </list></t>
            <t>A signature is generated and assigned to r:
            <list style="empty">
              <t>r = v - x*h mod n</t>
            </list></t>
            <t>V and r are assigned to the ZKP part zkp.V and zkp.r of the ECJPAKEKeyKP structure respectively.</t>
          </list></t>
        </section>
        
        <section title="Schnorr ZKP Verification">
          <t>For X1, X2, X3 and X4, the ECJPAKEKeyKP structure is verified as follows:</t>
          <t>The inputs are:</t>
          <t><list style="symbols">
            <t>Base point: G</t>
            <t>Order of the base point: n</t>
            <t>Identity of originator: ID (IDc or IDs depending on context)</t>
            <t>Public key to be verified: X (X1, X2, X3, or X4 depending on context)</t>
            <t>ZKP ephemeral public key: V</t>
            <t>ZKP signature: r</t>
          </list></t>
          <t>The ZKP is verified as follows:</t>
          <t><list style="numbers">
            <t>An integer representation of a hash (see <xref target="zkp_hash_calc" />) is generated and assigned to h:
            <list style="empty">
              <t>h = int(SHA-256(G, V, X, ID)) mod n</t>
            </list></t>
            <t>A check point is generated and assigned to V':
            <list style="empty">
              <t>V'= X*h + G*r</t>
            </list></t>
            <t>The points V' and V are compared. If equal then the ZKP verifies, otherwise it does not verify.</t>
          </list></t>
        </section>
        
      </section>

      <section title="ServerKeyExchange Calculations">
      
        <t>The structure ECJPAKEKeyKP conveys the public key and associated Schnorr ZKP for Xs.</t>

        <section title="Public Key Generation">
          <t>For Xs, the value for the public key part X of the ECJPAKEKeyKP structure is generated as follows:</t>
          <t>The inputs are:</t>
          <t><list style="symbols">
            <t>Public keys: X1, X2 and X3</t>
            <t>Private key: x4</t>
            <t>Shared secret: s (integer format, see <xref target="shared_secret_conv" />)</t>
            <t>Order of the base point: n</t>
          </list></t>
          <t>The public key of the key pair is calculated as follows:</t>
          <t><list style="numbers">
            <t>A new generator is generated and assigned to GB:
            <list style="empty">
              <t>GB = X1 + X2 + X3</t>
            </list></t>
            <t>A private key is generated and assigned to xs:
            <list style="empty">
              <t>xs = x4*s mod n</t>
            </list></t>
            <t>A public key associated with xs is generated and assigned to Xs:
            <list style="empty">
              <t>Xs = GB*xs</t>
            </list></t>
            <t>Xs is assigned to the public key part X of the ECJPAKEKeyKP structure.</t>
          </list></t>
        </section>

        <section title="Schnorr ZKP Generation">
          <t>For Xs, the values for the ZKP part zkp.V and zkp.r of the ECJPAKEKeyKP structure are generated as follows:</t>
          <t>The inputs are:</t>
          <t><list style="symbols">
            <t>New generator: GB</t>
            <t>Order of the base point: n</t>
            <t>Identity of originator: IDs</t>
            <t>Key pair to provide a ZKP of: (Xs,xs) (public key: Xs, private key: xs)</t>
          </list></t>
          <t>The ZKP is generated as follows:</t>
          <t><list style="numbers">
            <t>A random integer in the range 1 to n-1 is assigned to ephemeral private key v.</t>
            <t>An ephemeral public key associated with v is generated and assigned to V:
            <list style="empty">
              <t>V = GB*v</t>
            </list></t>
            <t>An integer representation of a hash (see <xref target="zkp_hash_calc" />) is generated and assigned to h:
            <list style="empty">
              <t>h = int(SHA-256(GB, V, Xs, IDs)) mod n</t>
            </list></t>
            <t>A signature is generated and assigned to r:
            <list style="empty">
              <t>r = v - xs*h mod n</t>
            </list></t>
            <t>V and r are assigned to the ZKP part zkp.V and zkp.r of the ECJPAKEKeyKP structure respectively.</t>
          </list></t>
        </section>
        
        <section title="Schnorr ZKP Verification">
          <t>For Xs, the ECJPAKEKeyKP structure is verified as follows:</t>
          <t>The inputs are:</t>
          <t><list style="symbols">
            <t>New generator: GB</t>
            <t>Order of the base point: n</t>
            <t>Identity of originator: IDs</t>
            <t>Public key to be verified: Xs</t>
            <t>ZKP ephemeral public key: V</t>
            <t>ZKP signature: r</t>
          </list></t>
          <t>The ZKP is verified as follows:</t>
          <t><list style="numbers">
            <t>An integer representation of a hash (see <xref target="zkp_hash_calc" />) is generated and assigned to h:
            <list style="empty">
              <t>h = int(SHA-256(GB, V, Xs, IDs)) mod n</t>
            </list></t>
            <t>A check point is generated and assigned to V':
            <list style="empty">
              <t>V'= X*h + GB*r</t>
            </list></t>
            <t>The points V' and V are compared. If equal then the ZKP verifies, otherwise it does not verify.</t>
          </list></t>
        </section>
        
      </section>
      
      <section title="ClientKeyExchange Calculations">
      
        <t>The structure ECJPAKEKeyKP conveys the public key and associated Schnorr ZKP for Xc.</t>
      
        <section title="Public Key Generation">
          <t>For Xc, the value for the public key part X of the ECJPAKEKeyKP structure is generated as follows:</t>
          <t>The inputs are:</t>
          <t><list style="symbols">
            <t>Public keys: X1, X3 and X4</t>
            <t>Private key: x2</t>
            <t>Shared secret: s (integer format, see <xref target="shared_secret_conv" />)</t>
            <t>Order of the base point: n</t>
          </list></t>
          <t>The public key of the key pair is calculated as follows:</t>
          <t><list style="numbers">
            <t>A new generator is generated and assigned to GA:
            <list style="empty">
              <t>GA = X1 + X3 + X4</t>
            </list></t>
            <t>A private key is generated and assigned to xc:
            <list style="empty">
              <t>xc = x2*s mod n</t>
            </list></t>
            <t>A public key associated with xs is generated and assigned to Xc:
            <list style="empty">
              <t>Xc = GA*xc</t>
            </list></t>
            <t>Xc is assigned to the public key part X of the ECJPAKEKeyKP structure.</t>
          </list></t>
        </section>

        <section title="Schnorr ZKP Generation">
          <t>For Xc, the values for the ZKP part zkp.V and zkp.r of the ECJPAKEKeyKP structure are generated as follows:</t>
          <t>The inputs are:</t>
          <t><list style="symbols">
            <t>New generator: GA</t>
            <t>Order of the base point: n</t>
            <t>Identity of originator: IDc</t>
            <t>Key pair to provide a ZKP of: (Xc,xc) (public key: Xc, private key: xc)</t>
          </list></t>
          <t>The ZKP is generated as follows:</t>
          <t><list style="numbers">
            <t>A random integer in the range 1 to n-1 is assigned to ephemeral private key v.</t>
            <t>An ephemeral public key associated with v is generated and assigned to V:
            <list style="empty">
              <t>V = GA*v</t>
            </list></t>
            <t>An integer representation of a hash (see <xref target="zkp_hash_calc" />) is generated and assigned to h:
            <list style="empty">
              <t>h = int(SHA-256(GA, V, Xc, IDc)) mod n</t>
            </list></t>
            <t>A signature is generated and assigned to r:
            <list style="empty">
              <t>r = v - xc*h mod n</t>
            </list></t>
            <t>V and r are assigned to the ZKP part zkp.V and zkp.r of the ECJPAKEKeyKP structure respectively.</t>
          </list></t>
        </section>
        
        <section title="Schnorr ZKP Verification">
          <t>For Xc, the ECJPAKEKeyKP structure is verified as follows:</t>
          <t>The inputs are:</t>
          <t><list style="symbols">
            <t>New generator: GA</t>
            <t>Order of the base point: n</t>
            <t>Identity of originator: IDc</t>
            <t>Public key to be verified: Xc</t>
            <t>ZKP ephemeral public key: V</t>
            <t>ZKP signature: r</t>
          </list></t>
          <t>The ZKP is verified as follows:</t>
          <t><list style="numbers">
            <t>An integer representation of a hash (see <xref target="zkp_hash_calc" />) is generated and assigned to h:
            <list style="empty">
              <t>h = int(SHA-256(GA, V, Xc, IDc)) mod n</t>
            </list></t>
            <t>A check point is generated and assigned to V':
            <list style="empty">
              <t>V'= X*h + GA*r</t>
            </list></t>
            <t>The points V' and V are compared. If equal then the ZKP verifies, otherwise it does not verify.</t>
          </list></t>
        </section>
        
      </section>  

      <section title="Premaster Secret Generation">
      <t>The TLS-ECJ-PAKE handshake relies on the generation of identical premaster secrets at the client and server to verify the key establishment. The use of the protected Finished messages is therefore used for key confirmation purposes and to verify the handshake.</t>
        <section title="Server Premaster Secret Generation">
          <t>The inputs are:</t>
          <t><list style="symbols">
            <t>Public key of the client: Xc</t>
            <t>Public key: X2</t>
            <t>Private key: x4</t>
            <t>Shared secret: s (integer format, see <xref target="shared_secret_conv" />)</t>
          </list></t>
          <t>The premaster secret is generated as follows:</t>
          <t><list style="numbers">
            <t>Compute PMSK:
            <list style="empty">
              <t>PMSK = (Xc - X2*x4*s)*x4</t>
            </list></t>
            <t>Compute PMS:
            <list style="empty">
              <t>PMS = SHA-256(str(32, X coordinate of PMSK))</t>
            </list></t>
            <t>The master secret and key expansion is generated according to Section 8.1 and Section 6.3 of <xref target="RFC5246" />.</t>
          </list></t>
        </section>
        
        <section title="Client Premaster Secret Generation">
          <t>The inputs are:</t>
          <t><list style="symbols">
            <t>Public key of the server: Xs</t>
            <t>Public key: X4</t>
            <t>Private key: x2</t>
            <t>Shared secret: s (integer format, see <xref target="shared_secret_conv" />)</t>
          </list></t>
          <t>The premaster secret is generated as follows:</t>
          <t><list style="numbers">
            <t>Compute PMSK:
            <list style="empty">
              <t>PMSK = (Xs - X4*x2*s)*x2</t>
            </list></t>
            <t>Compute PMS:
            <list style="empty">
              <t>PMS = SHA-256(str(32, X coordinate of PMSK))</t>
            </list></t>
            <t>The master secret and key expansion is generated according to Section 8.1 and Section 6.3 of <xref target="RFC5246" />.</t>
          </list></t>
        </section>
      </section>
    </section>
   
    <section title="Acknowledgements">
      <t>The authors would like to thank Sorin Aliciuc, Richard Kelsey, Maurizio Nanni, Manuel Pegourie-Gonnard and Martin Turon for their helpful comments and assistance.</t>
    </section>
    <section title="IANA Considerations">

      <section title="Transport Layer Security (TLS) Parameters">
      
        <section title="TLS Cipher Suite Registry">
          <t>IANA is requested to add the following entries in the TLS Cipher Suite Registry:</t>
          <figure><artwork><![CDATA[
    TLS_ECJPAKE_WITH_AES_128_CCM = {0xTBD, 0xTBD}
    TLS_ECJPAKE_WITH_AES_256_CCM = {0xTBD, 0xTBD}
    TLS_ECJPAKE_WITH_AES_128_CCM_8 = {0xTBD, 0xTBD}
    TLS_ECJPAKE_WITH_AES_256_CCM_8 = {0xTBD, 0xTBD}
]]></artwork></figure>
        </section>
        
      </section>
      
      <section title="Transport Layer Security (TLS) Extensions">
        <section title="ExtensionType Values">
          <t>IANA is requested to add the following entries in the ExtensionType Values:</t>
          <figure><artwork><![CDATA[
    ecjpake_key_kp_pair = TBD
]]></artwork></figure>
        </section>
      </section>
      
    </section>
    
    <section title="Security Considerations">

      <section title="Security Proof">
        <t>An independent study that proves security of J-PAKE in a model with algebraic adversaries and random oracles can be found in <xref target="ABM15" />.</t>
      </section>

      <section title="Counter Reuse">
        <t>The cipher suites described in this document are AES-CCM-based AEAD cipher suites, therefore the security considerations for counter reuse described in <xref target="RFC6655"/> also apply to these cipher suites.</t>
      </section>
      
      <section title="Password">
        <t>The password forming the basis of the shared secret SHOULD be distributed in a secure out-of-band channel. In the specific case of <xref target="THREAD" />, this is achieved by the user enabling the use of the password only through a commissioning session where the user is in control of adding details of devices they wish to add to the Thread network.</t>
      </section>
      
      <section title="Rate Limiting">
        <t>An attacker could attempt to engage repeatedly with a ECJ-PAKE server in an attempt to guess the password. Servers SHOULD take steps to ensure the opportunity for repeated contact is limited.</t>
      </section>
      
      <section title="Usage Restrictions">
        <t>The cipher suites described in this document have primarily been developed to enable authentication and authorization for network access for IoT devices, as described in <xref target="THREAD" />. It is therefore RECOMMENDED that the use of these cipher suite is restricted to similar uses and SHOULD NOT be used in conjunction with web servers and web browsers unless consideration is given to secure entry of passwords in a browser.</t>
      </section>
      
      <section title="Fixed Implementation Parameters">
        <t>The requirement to specify fixed parameters in a specific implementation limits the amount of negotiation that takes place between Client and Server. This effectively makes capability negotiation binary, i.e. if the implementation is incompatible, the handshake will simply fail. This is usually an important consideration in the applications TLS-ECJ-PAKE is recommended for, where complex negotiation is neither desirable nor recommended.</t>
      </section>

    </section>
    
  </middle>

  <back>
    <references title="Normative References">
    
      <reference anchor="CCM" target="http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf">
        <front>
          <title>Recommendation for Block Cipher Modes of Operation: The CCM Mode for Authentication and Confidentiality</title>
          <author><organization>National Institute of Standards and Technology</organization></author>
          <date year='2004' month='May' />
        </front>
        <seriesInfo name="" value="SP 800-38C"/>
      </reference>
      
      <reference anchor="SEC1" target="http://www.secg.org/sec1-v2.pdf">
        <front>
          <title>Standards for Efficient Cryptography: SEC 1: Elliptic Curve Cryptography</title>
          <author><organization>Standards for Efficient Cryptography Group</organization></author>
          <date year='2004' month='May' />
        </front>
        <seriesInfo name="SECG" value="SEC1-v2"/>
      </reference>

      <reference anchor="THREAD" target="http://threadgroup.org/Portals/0/documents/whitepapers/Thread%20Commissioning%20white%20paper_v2_public.pdf">
        <front>
          <title>Thread Commissioning</title>
          <author><organization>Thread Group</organization></author>
          <date year='2015' month='July' />
        </front>
      </reference>
     
      <reference anchor="HR08" target="http://grouper.ieee.org/groups/1363/Research/contributions/hao-ryan-2008.pdf">
        <front>
          <title>Password Authenticated Key Exchange by Juggling</title>
          <author initials="F." surname="Hao" fullname="Feng Hao"></author>
          <author initials="P." surname="Ryan" fullname="Peter Ryan"></author>                
          <date month="May" year="2008" />
        </front>
        <seriesInfo name="" value="16th Workshop on Security Protocols (SPW'08)" />
      </reference>

      <reference anchor="ABM15" target="https://www.normalesup.org/~fbenhamo/files/publications/SP_AbdBenMac15.pdf">
        <front>
          <title>Security of the J-PAKE Password-Authenticated Key Exchange Protocol</title>
          <author initials="M." surname="Abdalla" fullname="Michel Abdalla"><organization>CNRS, ENS, INRIA, and PSL</organization></author>
          <author initials="F." surname="Benhamouda" fullname="Fabrice Benhamouda"><organization>ENS, CNRS, INRIA, and PSL</organization></author>  
          <author initials="P." surname="MacKenzie" fullname="Philip MacKenzie"><organization>Google Inc.</organization></author>               
          <date month="May" year="2015" />
        </front>
        <seriesInfo name="" value="IEEE Symposium on Security and Privacy" />
      </reference>
      
      <reference anchor="J-PAKE" target="http://tools.ietf.org/id/draft-hao-jpake-03.txt">
        <front>
          <title>J-PAKE: Password Authenticated Key Exchange by Juggling</title>
          <author initials="F." surname="Hao" fullname="Feng Hao"></author>
          <date month="February" day="29" year="2016"/>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-hao-jpake-03"/>
      </reference>
      &RFC2119;
      &RFC4492;
      &RFC5116;
      &RFC5246;
      &RFC6066;
      &RFC6655;
      &RFC7251;
    </references>

    <references title="Informative References">
      &RFC6090;
      &RFC6347;
      &RFC7252;
    </references>
  </back>
</rfc>
