Secure Shell (SSH) Key Exchange Method Using Curve25519 and Curve448libssharis@badcode.beSJD ABsimon@josefsson.orgJuniper Networks, Inc.mdb@juniper.netInternet Engineering Task ForceEllipticCurveDiffieHellmanECDH
This document describes the specification for using Curve25519
and Curve448 key exchange methods in the Secure Shell (SSH)
protocol.
Status of This Memo
This is an Internet Standards Track document.
This document is a product of the Internet Engineering Task Force
(IETF). It represents the consensus of the IETF community. It has
received public review and has been approved for publication by
the Internet Engineering Steering Group (IESG). Further
information on Internet Standards is available in Section 2 of
RFC 7841.
Information about the current status of this document, any
errata, and how to provide feedback on it may be obtained at
.
Copyright Notice
Copyright (c) 2020 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
() in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with
respect to this document. Code Components extracted from this
document must include Simplified BSD License text as described in
Section 4.e of the Trust Legal Provisions and are provided without
warranty as described in the Simplified BSD License.
Table of Contents
. Introduction
. Requirements Language
. Key Exchange Methods
. Shared Secret Encoding
. Security Considerations
. IANA Considerations
. References
. Normative References
. Informative References
Acknowledgements
Authors' Addresses
Introduction
Secure Shell (SSH) is a secure remote
login protocol. The key exchange protocol described in supports an extensible set of
methods.
defines how elliptic curves are
integrated into this extensible SSH framework, and this
document reuses the Elliptic Curve Diffie-Hellman (ECDH) key
exchange protocol messages defined in Section
ECDH Message
Numbers of . Other parts of
, such as Elliptic Curve
Menezes-Qu-Vanstone (ECMQV) key agreement and Elliptic Curve
Digital Signature Algorithm (ECDSA), are not considered in this
document.
This document describes how to implement key exchange based on
Curve25519 and Curve448 in SSH. For
Curve25519 with SHA-256 , the algorithm described is equivalent
to the
privately defined algorithm "curve25519-sha256@libssh.org",
which at the time of publication was implemented and widely
deployed in libssh and
OpenSSH . The Curve448 key
exchange method is
similar but uses SHA-512 .
Requirements Language
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 14
when, and only when, they appear in all capitals, as shown here.
Key Exchange Methods
The key exchange procedure is similar to the ECDH method
described in , though
with a different wire encoding used for public values and the
final shared secret. Public ephemeral keys are encoded for
transmission as standard SSH strings.
The protocol flow, the SSH_MSG_KEX_ECDH_INIT and
SSH_MSG_KEX_ECDH_REPLY messages, and the structure of the
exchange hash are identical to .
The method names registered by this document are
"curve25519-sha256" and "curve448-sha512".
The methods are based on Curve25519 and Curve448 scalar
multiplication, as described in .
Private and public keys are generated as described therein.
Public keys are defined as strings of 32 bytes for Curve25519
and 56 bytes for Curve448.
The key-agreement schemes "curve25519-sha256" and
"curve448-sha512" perform the Diffie-Hellman protocol using
the functions X25519 and X448, respectively. Implementations
SHOULD compute these functions using the algorithms described
in . When they do so,
implementations MUST check
whether the computed Diffie-Hellman shared secret is the
all-zero value and abort if so, as described in .
Alternative implementations of these functions
SHOULD abort when either the client or the server input
forces the shared secret to one of a small set of values, as
described in Sections and of . Clients and servers MUST also abort if
the length of the received public keys are not the expected
lengths. An abort for these purposes is defined as a
disconnect (SSH_MSG_DISCONNECT) of the session and SHOULD use
the SSH_DISCONNECT_KEY_EXCHANGE_FAILED reason for the message
.
No further validation is required beyond what is described in
. The derived shared secret is 32
bytes when "curve25519-sha256" is used and 56 bytes when
"curve448-sha512" is used. The encodings of all values are
defined in . The hash used is SHA-256
for "curve25519-sha256" and SHA-512 for "curve448-sha512".
Shared Secret Encoding
The following step differs from ,
which uses a different conversion. This is not intended to
modify that text generally, but only to be applicable to the
scope of the mechanism described in this document.
The shared secret, K, is defined in
and as an integer encoded
as a multiple precision integer (mpint). Curve25519/448
outputs a binary string X, which is the 32- or 56-byte point
obtained by scalar multiplication of the other side's public
key and the local private key scalar. The 32 or 56 bytes of
X are converted into K by interpreting the octets as an
unsigned fixed-length integer encoded in network byte order.
The mpint K is then encoded using the process
described in , and the
resulting bytes are fed as described in to the key exchange method's hash
function to generate encryption keys.
When performing the X25519 or X448 operations, the integer
values there will be encoded into byte strings by doing a
fixed-length unsigned little-endian conversion, per . It is only later when these
byte strings
are then passed to the ECDH function in SSH that the bytes
are reinterpreted as a fixed-length unsigned big-endian
integer value K, and then later that K value is encoded as a
variable-length signed "mpint" before being fed to the hash
algorithm used for key generation. The mpint K is then fed
along with other data to the key exchange method's hash
function to generate encryption keys.
Security Considerations
The security considerations of , , and are
inherited.
Curve25519 with SHA-256 provides strong (~128 bits) security,
is efficient on a wide range of architectures, and has
characteristics that allow for better implementation properties
compared to traditional elliptic curves. Curve448 with SHA-512
provides stronger (~224 bits) security with similar
implementation properties; however, it has not received the same
cryptographic review as Curve25519. It is also slower (larger key
material and larger secure hash algorithm), but it is provided
as a hedge to combat unforeseen analytical advances against
Curve25519 and SHA-256 due to the larger number of security
bits.
The way the derived mpint binary secret string is encoded
before it is hashed (i.e., adding or removing zero bytes
for encoding) raises the potential for a side-channel attack,
which could determine the length of what is hashed. This
would leak the most significant bit of the derived secret
and/or allow detection of when the most significant bytes are
zero. For backwards-compatibility reasons, it was decided not
to address this potential problem.
This document provides "curve25519-sha256" as the preferred
choice but suggests that the "curve448-sha512" be implemented
to provide more than 128 bits of security strength should that
become a requirement.
IANA Considerations
IANA has added "curve25519-sha256" and
"curve448-sha512" to the "Key Exchange Method Names" registry
for SSH that was created in
.
ReferencesNormative ReferencesKey words for use in RFCs to Indicate Requirement LevelsIn many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.The Secure Shell (SSH) Protocol Assigned NumbersThis document defines the instructions to the IANA and the initial state of the IANA assigned numbers for the Secure Shell (SSH) protocol. It is intended only for the initialization of the IANA registries referenced in the set of SSH documents. [STANDARDS-TRACK]The Secure Shell (SSH) Protocol ArchitectureThe Secure Shell (SSH) Protocol is a protocol for secure remote login and other secure network services over an insecure network. This document describes the architecture of the SSH protocol, as well as the notation and terminology used in SSH protocol documents. It also discusses the SSH algorithm naming system that allows local extensions. The SSH protocol consists of three major components: The Transport Layer Protocol provides server authentication, confidentiality, and integrity with perfect forward secrecy. The User Authentication Protocol authenticates the client to the server. The Connection Protocol multiplexes the encrypted tunnel into several logical channels. Details of these protocols are described in separate documents. [STANDARDS-TRACK]The Secure Shell (SSH) Transport Layer ProtocolThe Secure Shell (SSH) is a protocol for secure remote login and other secure network services over an insecure network.This document describes the SSH transport layer protocol, which typically runs on top of TCP/IP. The protocol can be used as a basis for a number of secure network services. It provides strong encryption, server authentication, and integrity protection. It may also provide compression.Key exchange method, public key algorithm, symmetric encryption algorithm, message authentication algorithm, and hash algorithm are all negotiated.This document also describes the Diffie-Hellman key exchange method and the minimal set of algorithms that are needed to implement the SSH transport layer protocol. [STANDARDS-TRACK]Elliptic Curve Algorithm Integration in the Secure Shell Transport LayerThis document describes algorithms based on Elliptic Curve Cryptography (ECC) for use within the Secure Shell (SSH) transport protocol. In particular, it specifies Elliptic Curve Diffie-Hellman (ECDH) key agreement, Elliptic Curve Menezes-Qu-Vanstone (ECMQV) key agreement, and Elliptic Curve Digital Signature Algorithm (ECDSA) for use in the SSH Transport Layer protocol. [STANDARDS-TRACK]Ambiguity of Uppercase vs Lowercase in RFC 2119 Key WordsRFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.Secure Hash Standard (SHS)National Institute of Standards and TechnologyInformative ReferencesSecure Shell (SSH) Protocol Parameters: Key Exchange Method NamesIANASecure Shell (SSH) Protocol Parameters: Disconnection Messages Reason Codes and DescriptionsIANAThe SSH LibrarylibsshThe OpenSSH ProjectOpenSSH group of OpenBSDUS Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF)Federal Information Processing Standard, FIPSElliptic Curves for SecurityThis memo specifies two elliptic curves over prime fields that offer a high level of practical security in cryptographic applications, including Transport Layer Security (TLS). These curves are intended to operate at the ~128-bit and ~224-bit security level, respectively, and are generated deterministically based on a list of required properties.Acknowledgements
The "curve25519-sha256" key exchange method is identical to
the "curve25519-sha256@libssh.org" key exchange method created
by and implemented in libssh and OpenSSH.
Thanks to the following people for review and comments: , , , , , , and .
Authors' Addresseslibssharis@badcode.beSJD ABsimon@josefsson.orgJuniper Networks, Inc.mdb@juniper.net