<?xml version='1.0' encoding='US-ASCII'?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2119 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC4251 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4251.xml">
<!ENTITY RFC4252 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4252.xml">
<!ENTITY RFC4253 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4253.xml">
<!ENTITY RFC4250 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4250.xml">
<!ENTITY RFC8017 SYSTEM
"https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8017.xml">
<!ENTITY RFC8174 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml">
]>

<!-- XML source generated ing id2xml January 2018 -->

<rfc number="8332" submissionType="IETF" consensus="yes"
     category="std" updates="4252, 4253" ipr="pre5378Trust200902">

        <?rfc toc="yes"?>
        <?rfc compact="yes"?>
	<?rfc text-list-symbols="o*+-"?>
	<?rfc subcompact="no"?>
	<?rfc sortrefs="no"?>
	<?rfc symrefs="yes"?>

	<front>
	<title abbrev="Use of RSA Keys with SHA-256 and SHA-512">Use of RSA
	Keys with SHA-256 and SHA-512 in&nbsp;the&nbsp;Secure&nbsp;Shell&nbsp;(SSH)&nbsp;Protocol</title>
	<author fullname="Denis Bider" initials="D." surname="Bider">
	<organization>Bitvise Limited</organization>
	<address><postal><street>4105 Lombardy Court</street>
	<street>Colleyville, Texas  76034</street>
	<street>United States of America</street>
	</postal>
	<email>ietf-ssh3@denisbider.com</email>
	<uri>https://www.bitvise.com/</uri>
	</address>
	</author>

	<date month="March" year="2018"/>

<keyword>rsa-sha2-256</keyword>
<keyword>rsa-sha2-512</keyword>
<keyword>ssh-rsa</keyword>
<keyword>publickey</keyword>
<keyword>server-sig-algs</keyword>
<keyword>signature</keyword>
<keyword>authentication</keyword>

	<abstract><t>
This memo updates RFCs 4252 and 4253 to define new public key
algorithms for use of RSA keys with SHA-256 and SHA-512 for server and
client authentication in SSH connections.
	</t>	</abstract>
	</front>

	<middle>
	<section title="Overview and Rationale" anchor="section-1"><t>
Secure Shell (SSH) is a common protocol for secure communication on
the Internet. In <xref target="RFC4253"/>, SSH originally defined the public key
algorithms "ssh-rsa" for server and client authentication using RSA
with SHA-1, and "ssh-dss" using 1024-bit DSA and SHA-1. These
algorithms are now considered deficient. For US government use, NIST
has disallowed 1024-bit RSA and DSA, and use of SHA-1 for signing
<xref target="NIST.800-131A"/>.</t>

<t>This memo updates RFCs 4252 and 4253 to define new public key
algorithms allowing for interoperable use of existing and new RSA keys
with SHA-256 and SHA-512.</t>

	<section title="Requirements Terminology" anchor="section-1.1">
        <t>
    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
    NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
    "MAY", and "OPTIONAL" in this document are to be interpreted as
    described in BCP&nbsp;14 <xref target="RFC2119"/> <xref target="RFC8174"/> 
    when, and only when, they appear in all capitals, as shown here.
        </t>

	</section>

	<section title="Wire Encoding Terminology" anchor="section-1.2">
<t>The wire encoding types in this document -- "boolean", "byte",
"string", "mpint" -- have meanings as described in <xref target="RFC4251"/>.</t>
	</section>
	</section>

	<section title="Public Key Format vs. Public Key Algorithm"
		 anchor="section-2">
<t>
In <xref target="RFC4252"/>, the concept "public key algorithm" is used to establish
a relationship between one algorithm name, and:
<list style="format %C.">
<?rfc subcompact="yes"?>
<t>procedures used to generate and validate a private/public keypair;</t>

<t>a format used to encode a public key; and</t>

<t>procedures used to calculate, encode, and verify a
signature.</t>
</list></t>
<?rfc subcompact="no"?>

<t>This document uses the term "public key format" to identify only A and
B in isolation. The term "public key algorithm" continues to identify
all three aspects -- A, B, and C.</t>

	</section>

	<section title="New RSA Public Key Algorithms" anchor="section-3">
<t>This memo adopts the style and conventions of <xref target="RFC4253"/> in specifying
how use of a public key algorithm is indicated in SSH.</t>

<t>The following new public key algorithms are defined:</t>

<figure><artwork><![CDATA[
  rsa-sha2-256        RECOMMENDED    sign    Raw RSA key
  rsa-sha2-512        OPTIONAL       sign    Raw RSA key
]]></artwork></figure>

<t>These algorithms are suitable for use both in the SSH transport layer
<xref target="RFC4253"/> for server authentication and in the authentication layer
<xref target="RFC4252"/> for client authentication.</t>

<t>Since RSA keys are not dependent on the choice of hash function, the
new public key algorithms reuse the "ssh-rsa" public key format as
defined in <xref target="RFC4253"/>:</t>

<figure><artwork><![CDATA[
string    "ssh-rsa"
mpint     e
mpint     n
]]></artwork></figure>

<t>All aspects of the "ssh-rsa" format are kept, including the encoded
string "ssh-rsa". This allows existing RSA keys to be used with the
new public key algorithms, without requiring re-encoding or affecting
already trusted key fingerprints.</t>

<t>Signing and verifying using these algorithms is performed according to
the RSASSA-PKCS1-v1_5 scheme in <xref target="RFC8017"/> using SHA-2 <xref target="SHS"/> as hash.</t>
<figure><artwork><![CDATA[
For the algorithm "rsa-sha2-256", the hash used is SHA-256.
For the algorithm "rsa-sha2-512", the hash used is SHA-512.
]]></artwork></figure>

<t>The resulting signature is encoded as follows:</t>
<figure><artwork><![CDATA[
string   "rsa-sha2-256" / "rsa-sha2-512"
string    rsa_signature_blob
]]></artwork></figure>

<t>
   The value for 'rsa_signature_blob' is encoded as a string that contains
   an octet string S (which is the output of RSASSA-PKCS1-v1_5) and that
   has the same length (in octets) as the RSA modulus.
   When S contains leading zeros, there exist signers that will send
   a shorter encoding of S that omits them. A verifier MAY accept shorter
   encodings of S with one or more leading zeros omitted.
 </t>

	<section title="Use for Server Authentication" anchor="section-3.1">
<t>To express support and preference for one or both of these algorithms
for server authentication, the SSH client or server includes one or
both algorithm names, "rsa-sha2-256" and/or "rsa-sha2-512", in the
name-list field "server_host_key_algorithms" in the SSH_MSG_KEXINIT
packet <xref target="RFC4253"/>. If one of the two host key algorithms is negotiated,
the server sends an "ssh-rsa" public key as part of the negotiated key
exchange method (e.g., in SSH_MSG_KEXDH_REPLY) and encodes a signature
with the appropriate signature algorithm name -- either "rsa-sha2-256"
or "rsa-sha2-512".</t>

	</section>

	<section title="Use for Client Authentication" anchor="section-3.2">
<t>To use this algorithm for client authentication, the SSH client sends
an SSH_MSG_USERAUTH_REQUEST message <xref target="RFC4252"/> encoding the "publickey"
method and encoding the string field "public key algorithm name" with
the value "rsa-sha2-256" or "rsa-sha2-512". The "public key blob"
field encodes the RSA public key using the "ssh&nbhy;rsa" public key
format.</t>

<t>For example, as defined in <xref target="RFC4252"/> and <xref target="RFC4253"/>, an SSH "publickey"
authentication request using an "rsa-sha2-512" signature would be
properly encoded as follows:</t>
<figure><artwork><![CDATA[
  byte      SSH_MSG_USERAUTH_REQUEST
  string    user name
  string    service name
  string    "publickey"
  boolean   TRUE
  string    "rsa-sha2-512"
  string    public key blob:
      string    "ssh-rsa"
      mpint     e
      mpint     n
  string    signature:
      string    "rsa-sha2-512"
      string    rsa_signature_blob
]]></artwork></figure>

<t>If the client includes the signature field, the client MUST encode the
same algorithm name in the signature as in SSH_MSG_USERAUTH_REQUEST --
either "rsa-sha2-256" or "rsa-sha2-512". If a server receives a
mismatching request, it MAY apply arbitrary authentication penalties,
including but not limited to authentication failure or disconnect.</t>

<t>OpenSSH 7.2 (but not 7.2p2) incorrectly encodes the algorithm in the
signature as "ssh-rsa" when the algorithm in SSH_MSG_USERAUTH_REQUEST
is "rsa-sha2-256" or "rsa-sha2-512". In this case, the signature does
actually use either SHA-256 or SHA-512. 

A server MAY, but is not
required to, accept this variant or another variant that corresponds
to a good-faith implementation and is considered safe to accept.</t>

	</section>

	<section title="Discovery of Public Key Algorithms Supported by Servers" anchor="section-3.3">
<t>Implementation experience has shown that there are servers that apply
authentication penalties to clients attempting public key algorithms
that the SSH server does not support.</t>

<t>Servers that accept rsa-sha2-* signatures for client authentication
SHOULD implement the extension negotiation mechanism defined in
<xref target="RFC8308"/>, including especially the "server-sig-algs" extension.</t>

<t>When authenticating with an RSA key against a server that does not
implement the "server-sig-algs" extension, clients MAY default to an
"ssh-rsa" signature to avoid authentication penalties. When the new
rsa-sha2-* algorithms have been sufficiently widely adopted to warrant
disabling "ssh-rsa", clients MAY default to one of the new algorithms.</t>

	</section>

	</section>

	<section title="IANA Considerations" anchor="section-4">
<t>IANA has updated the "Secure Shell (SSH) Protocol
Parameters" registry, established with <xref target="RFC4250"/>, to extend the table
"Public Key Algorithm Names" <xref target="IANA-PKA"/> as follows.</t>

<?rfc text-list-symbols="-"?>
<t><list style="symbols">
<t>To the immediate right of the column "Public Key Algorithm Name",
  a new column has been added, titled "Public Key Format". For existing
  entries, the column "Public Key Format" has been assigned the same
  value as under "Public Key Algorithm Name".</t>

<t>Immediately following the existing entry for "ssh-rsa", two sibling
  entries have been added:</t></list></t>
<?rfc text-list-symbols="o*+-"?>


<figure><artwork><![CDATA[
   P. K. Alg. Name    P. K. Format      Reference   Note
   rsa-sha2-256       ssh-rsa           RFC 8332    Section 3
   rsa-sha2-512       ssh-rsa           RFC 8332    Section 3
]]></artwork>
	</figure>
	</section>

	<section title="Security Considerations" anchor="section-5">
<t>The security considerations of <xref target="RFC4251"/> apply to this document.</t>

	<section title="Key Size and Signature Hash" anchor="section-5.1">
<t>The National Institute of Standards and Technology (NIST) Special
Publication 800-131A, Revision 1 <xref target="NIST.800-131A"/> disallows RSA
and DSA keys shorter than 2048 bits for US government use. The same
document disallows the SHA-1 hash function for digital signature
generation, except under NIST's protocol-specific guidance.</t>

<t>It is prudent to follow this advice also outside of US government use.</t>
	</section>

	<section title="Transition" anchor="section-5.2"><t>
This document is based on the premise that RSA is used in environments
where a gradual, compatible transition to improved algorithms will be
better received than one that is abrupt and incompatible. It advises
that SSH implementations add support for new RSA public key algorithms
along with SSH_MSG_EXT_INFO and the "server-sig-algs" extension to
allow coexistence of new deployments with older versions that support
only "ssh-rsa". 

  Nevertheless, implementations SHOULD start to disable
  "ssh-rsa" in their default configurations as soon as the implementers
  believe that new RSA signature algorithms have been widely adopted.
</t>

	</section>

	<section title="PKCS #1 v1.5 Padding and Signature Verification" anchor="section-5.3">
<t>This document prescribes RSASSA-PKCS1-v1_5 signature padding because:</t>
<t><list style="format (%d)">
<?rfc subcompact="yes"?>
<t>RSASSA-PSS is not universally available to all implementations;</t>

<t>PKCS #1 v1.5 is widely supported in existing SSH implementations;</t>

<t>PKCS #1 v1.5 is not known to be insecure for use in this scheme.</t>
<?rfc subcompact="no"?></list></t>

<t>Implementers are advised that a signature with RSASSA-PKCS1-v1_5 padding MUST NOT be verified by applying the RSA key to the signature, and
then parsing the output to extract the hash. This may give an attacker
opportunities to exploit flaws in the parsing and vary the encoding.
Verifiers MUST instead apply RSASSA-PKCS1-v1_5 padding to the expected hash,
then compare the encoded bytes with the output of the RSA operation.</t>
	</section>

	</section>

	</middle>

	<back>
	<references title="Normative References">
	<reference anchor="SHS" target="http://dx.doi.org/10.6028/NIST.FIPS.180-4"><front>
	<title>Secure Hash Standard (SHS)</title>
	<author>
	<organization>NIST</organization>
	</author>

	<date month="August" year="2015"/>
	</front>

	<seriesInfo name="FIPS" value="Publication 180-4"/>
	</reference>
	&RFC2119;
	&RFC4251;
	&RFC4252;
	&RFC4253;
	&RFC8174;

<!--draft-ietf-curdle-ssh-ext-info-15: in queue in AUTH48 RFC-to-be 8308 -->
<reference anchor="RFC8308" target="https://www.rfc-editor.org/info/rfc8308">
<front>
<title>Extension Negotiation in the Secure Shell (SSH) Protocol</title>

<author initials='D' surname='Bider' fullname='Denis Bider'>
    <organization />
</author>

<date month='March' year='2018' />
</front>

<seriesInfo name='RFC' value='8308'/>
<seriesInfo name="DOI" value="10.17487/RFC8308"/>
</reference>

	</references>
	<references title="Informative References">

<reference anchor="NIST.800-131A" target="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar1.pdf">
<front>
<title>Transitions: Recommendation for Transitioning the Use of Cryptographic
Algorithms and Key Lengths</title>
<author>
  <organization>NIST</organization>
</author>
<date month='November' year='2015'/>
</front>
<seriesInfo name="NIST Special Publication" value="800-131A"/>
<seriesInfo name="Revision" value="1"/>
<seriesInfo name="DOI" value="10.6028/NIST.SP.800-131Ar1"/>
</reference>

	&RFC4250;
	&RFC8017;
	<reference anchor="IANA-PKA" target="https://www.iana.org/assignments/ssh-parameters/"><front>
	<title>Secure Shell (SSH) Protocol Parameters</title>
	<author>
	<organization>IANA</organization>
	</author>

	<date/>
	</front>

	</reference>
	</references>

	<section title="Acknowledgments" numbered="no"
		 anchor="acknowledgments">
	  <t>Thanks to Jon Bright, Niels Moeller, Stephen Farrell, Mark
	  D. Baushke, Jeffrey Hutzelman, Hanno Boeck, Peter Gutmann, Damien
	  Miller, Mat Berchtold, Roumen Petrov, Daniel Migault, Eric Rescorla,
	  Russ Housley, Alissa Cooper, Adam Roach, and Ben Campbell for
	  reviews, comments, and suggestions.</t>
	</section>

	</back>

	</rfc>
	
