<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc SYSTEM "rfc2629-xhtml.ent">
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<rfc
      xmlns:xi="http://www.w3.org/2001/XInclude"
      category="info"
      docName="draft-rransom-secsh-client-ntru-kex-00"
      ipr="trust200902"
      submissionType="independent"
      xml:lang="en"
      version="3">

<front>
<title abbrev="Client-Side NTRU Key Exchange for SSH">Client-Side NTRU Key Exchange for Secure Shell (SSH)</title>
<seriesInfo name="Internet-Draft" value="draft-rransom-secsh-client-ntru-kex-00"/>
<author fullname="Robert Ransom" initials="R." surname="Ransom"/>
<abstract>
<t>This document describes the specification for using NTRU keypairs generated by the client for key exchange in the Secure Shell (SSH) protocol.</t>
</abstract>
</front>

<middle>
<section><name>Introduction</name>
<t>The Secure Shell (SSH) transport layer protocol specified in <xref target="RFC4253"/> provides for extension to support new key exchange methods.
This document specifies key exchange methods which provide post-quantum security based on the NTRU KEM <xref target="NTRU"/>.</t>
<t>For ease of implementation in existing SSH software, this key exchange method uses an ephemeral NTRU keypair generated by the client, retains the same structure and pattern of messages as the existing Diffie-Hellman and ECDH <xref target="RFC5656"/><xref target="RFC8731"/> key exchange methods, and relies on a signature keypair to authenticate the server.</t>
<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><name>Notation</name>
<t>In this document, the concatenation of two strings <tt>a</tt> and <tt>b</tt> will be denoted <tt>a || b</tt>.</t>
</section>

<section><name>Key exchange methods</name>
<t>The key exchange procedure follows the same general pattern as the ECDH key exchange specified in section 4 of <xref target="RFC5656"/>, and uses the same message numbers; however, the contents differ, and the key exchange is not symmetric as in ECDH.</t>
<t>Each key exchange method name specifies both an NTRU parameter set and a hash function.
NTRU operations <tt>Key_Pair</tt>, <tt>Encapsulate</tt>, and <tt>Decapsulate</tt> are performed as in <xref target="NTRU"/> for the given parameter set,
except that its <tt>Hash</tt> is replaced with the hash function specified for the key exchange method.
The <tt>kem_public_key_bytes</tt> and <tt>kem_ciphertext_bytes</tt> constants are also as specified in <xref target="NTRU"/> for the given parameter set.</t>
<t>Let <tt>hash_bytes</tt> denote the length of the hash function's output.</t>
<t>The client generates a private key <tt>priv</tt> and a public key <tt>pub</tt> by applying <tt>Key_Pair</tt> to the output of a random number generator.
This key may be stored by the client and used for more than one connection.
Each <tt>priv</tt> and <tt>pub</tt> <bcp14>MUST</bcp14> only be used with a single hash function.</t>
<t>For each connection, the client generates a new random string <tt>nonce</tt> of length <tt>hash_bytes</tt>.
<tt>nonce</tt> <bcp14>MUST NOT</bcp14> be reused.</t>
<t>The client sends the following:</t>
<table><tbody>
<tr><td>byte</td><td><tt>SSH_MSG_KEX_ECDH_INIT</tt></td></tr>
<tr><td>string</td><td><tt>pub || nonce</tt></td></tr>
</tbody></table>
<t>Both <tt>pub</tt> and <tt>nonce</tt> have fixed length for each key exchange method, so the string <tt>pub || nonce</tt> can be uniquely parsed into <tt>pub</tt> and <tt>nonce</tt> by the server.
The server applies <tt>Encapsulate</tt> to <tt>pub</tt>, to produce a shared secret key <tt>sk</tt> and a ciphertext <tt>ct</tt>.</t>
<t>The server responds with:</t>
<table><tbody>
<tr><td>byte</td><td><tt>SSH_MSG_KEX_ECDH_REPLY</tt></td></tr>
<tr><td>string</td><td><tt>ct</tt></td></tr>
</tbody></table>
<t>The client applies <tt>Decapsulate</tt> to <tt>priv</tt> and <tt>ct</tt>, to recover <tt>sk</tt>.</t>
<t>Let <tt>pad</tt> denote the string containing the single byte <tt>1</tt>.
Both parties compute <tt>K'</tt> as <tt>pad || Hash(sk || nonce)</tt>, and compute <tt>K</tt> by interpreting <tt>K'</tt> as a big-endian integer.
Equivalently, the <tt>mpint</tt> <tt>K</tt> specified by section 7.2 of the SSH transport layer protocol <xref target="RFC4253"/> as the secret output of a key exchange method can be replaced with the <tt>string</tt> <tt>K'</tt>.</t>
<t>The exchange hash <tt>H</tt> is computed as in section 4 of <xref target="RFC5656"/>, with <tt>Q_C = pub || nonce</tt> and <tt>Q_S = ct</tt>.</t>
</section>

<section><name>Security considerations</name>
<t>The exchange hash <tt>H</tt> is computed using the hash algorithm specified by the key exchange method.
This limits the security of authentication in both directions to the second-preimage resistance of the hash function specified by the weakest KEX accepted by both parties.</t>
<t>Reuse of an NTRU keypair for more than one <tt>Decapsulate</tt> operation is intended and believed to be safe, and the nonce sent by the client is used to prevent a replay of the server's ciphertext from producing the same exchange hash <tt>H</tt> or shared secret <tt>K</tt>.
However, reusing a keypair discloses that multiple connections originated from the same client.
Clients which support reuse of NTRU keypairs <bcp14>MUST</bcp14> document this key reuse, and <bcp14>SHOULD</bcp14> provide a way to disable it.</t>
<t>Section 7.2 of <xref target="RFC4253"/> specifies that the shared secret <tt>K</tt> is to be encoded as an <tt>mpint</tt>, in which bytes must be removed or added at the beginning to ensure certain conditions on the leading byte.
As section 4 of <xref target="RFC8731"/> points out, this is likely to introduce a side-channel attack.
This key exchange method prepends a fixed non-zero padding byte, to eliminate that side-channel risk without requiring extensive reworking of implementations which internally handle <tt>K</tt> as an <tt>mpint</tt>.</t>
</section>

<section><name>IANA considerations</name>
<t>This document specifies the following names to be added to the “Key Exchange Method Names” registry for SSH <xref target="IANA-KEX"/>, as follows:</t>
<table><name>Key exchange method names</name>
<thead>
<tr><th>Key exchange method name</th><th>Hash function</th><th>NTRU parameter set</th></tr>
</thead>
<tbody>
<tr><td>client-ntruhps4096821-sha3-512</td><td>SHA3-512</td><td>ntruhps4096821</td></tr>
<tr><td>client-ntruhps4096821-sha256</td><td>SHA-256</td><td>ntruhps4096821</td></tr>
</tbody>
</table>
</section>

</middle>

<back>
<references><name>References</name>

<reference anchor="RFC4253" target="https://www.rfc-editor.org/info/rfc4253">
<front>
<title>The Secure Shell (SSH) Transport Layer Protocol</title>
<seriesInfo name="RFC" value="4253"/>
<author initials="T." surname="Ylonen" fullname="Tatu Ylonen" />
<author initials="C." surname="Lonvick" fullname="Chris Lonvick" role="editor" />
<date year="2006" month="January" />
</front>
</reference>

<reference anchor="NTRU" target="">
<front>
<title>NTRU - Algorithm Specifications and Supporting Documentation</title>
<author initials="C." surname="Chen" fullname="Cong Chen" />
<author initials="O." surname="Danba" fullname="Oussama Danba" />
<author initials="J." surname="Hoffstein" fullname="Jeffrey Hoffstein" />
<author initials="A." asciiSurname="Hulsing" asciiFullname="Andreas Hulsing"
        surname="Hülsing" fullname="Andreas Hülsing" />
<author initials="J." surname="Rijneveld" fullname="Joost Rijneveld" />
<author initials="J. M." surname="Schanck" fullname="John M. Schanck" />
<author initials="P." surname="Schwabe" fullname="Peter Schwabe" />
<author initials="W." surname="Whyte" fullname="William Whyte" />
<author initials="Z." surname="Zhang" fullname="Zhenfei Zhang" />
<date year="2019" month="March" day="30" />
</front>
<refcontent>NIST Post-Quantum Cryptography project submission document</refcontent>
</reference>

<reference anchor="RFC5656" target="https://www.rfc-editor.org/info/rfc5656">
<front>
<title>Elliptic Curve Algorithm Integration in the Secure Shell Transport Layer</title>
<seriesInfo name="RFC" value="5656"/>
<author initials="D." surname="Stebila" fullname="Douglas Stebila" />
<author initials="J." surname="Green" fullname="Jon Green" />
<date year="2009" month="December" />
</front>
</reference>

<reference anchor="RFC8731" target="https://www.rfc-editor.org/info/rfc8731">
<front>
<title>Secure Shell (SSH) Key Exchange Method Using Curve25519 and Curve448</title>
<seriesInfo name="RFC" value="8731"/>
<author initials="A." surname="Adamantiadis" fullname="Aris Adamantiadis" />
<author initials="S." surname="Josefsson" fullname="Simon Josefsson" />
<author initials="M." surname="Baushke" fullname="Mark D. Bradner" />
<date year="2020" month="February" />
</front>
</reference>

<reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
<front>
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
<seriesInfo name="RFC" value="2119"/>
<author initials="S." surname="Bradner" fullname="Scott Bradner" />
<date year="1997" month="March" />
</front>
</reference>

<reference anchor="IANA-KEX" target="https://www.iana.org/assignments/ssh-parameters/">
<front>
<title>Secure Shell (SSH) Protocol Parameters: Key Exchange Method Names</title>
<author surname="IANA" fullname="IANA" />
</front>
</reference>

</references>
</back>
</rfc>
