Skip to content

Commit 9b07691

Browse files
Finn9000FiloSottile
andcommitted
ssh: support new curve25519-sha256 kex name
RFC 8731 standardized [email protected] as curve25519-sha256, and some systems only advertise support for the new name. Fixes golang/go#48756 Change-Id: Ice35874cd8c07ad48752686ac368bf11ab793f77 Co-authored-by: Filippo Valsorda <[email protected]> Reviewed-on: https://go-review.googlesource.com/c/crypto/+/385394 Trust: Filippo Valsorda <[email protected]> Run-TryBot: Filippo Valsorda <[email protected]> Trust: Matt Layher <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Roland Shoemaker <[email protected]>
1 parent b769efc commit 9b07691

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

ssh/common.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var preferredCiphers = []string{
4444
// supportedKexAlgos specifies the supported key-exchange algorithms in
4545
// preference order.
4646
var supportedKexAlgos = []string{
47-
kexAlgoCurve25519SHA256,
47+
kexAlgoCurve25519SHA256, kexAlgoCurve25519SHA256LibSSH,
4848
// P384 and P521 are not constant-time yet, but since we don't
4949
// reuse ephemeral keys, using them for ECDH should be OK.
5050
kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521,
@@ -61,7 +61,7 @@ var serverForbiddenKexAlgos = map[string]struct{}{
6161
// preferredKexAlgos specifies the default preference for key-exchange algorithms
6262
// in preference order.
6363
var preferredKexAlgos = []string{
64-
kexAlgoCurve25519SHA256,
64+
kexAlgoCurve25519SHA256, kexAlgoCurve25519SHA256LibSSH,
6565
kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521,
6666
kexAlgoDH14SHA1,
6767
}

ssh/kex.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import (
2020
)
2121

2222
const (
23-
kexAlgoDH1SHA1 = "diffie-hellman-group1-sha1"
24-
kexAlgoDH14SHA1 = "diffie-hellman-group14-sha1"
25-
kexAlgoECDH256 = "ecdh-sha2-nistp256"
26-
kexAlgoECDH384 = "ecdh-sha2-nistp384"
27-
kexAlgoECDH521 = "ecdh-sha2-nistp521"
28-
kexAlgoCurve25519SHA256 = "[email protected]"
23+
kexAlgoDH1SHA1 = "diffie-hellman-group1-sha1"
24+
kexAlgoDH14SHA1 = "diffie-hellman-group14-sha1"
25+
kexAlgoECDH256 = "ecdh-sha2-nistp256"
26+
kexAlgoECDH384 = "ecdh-sha2-nistp384"
27+
kexAlgoECDH521 = "ecdh-sha2-nistp521"
28+
kexAlgoCurve25519SHA256LibSSH = "[email protected]"
29+
kexAlgoCurve25519SHA256 = "curve25519-sha256"
2930

3031
// For the following kex only the client half contains a production
3132
// ready implementation. The server half only consists of a minimal
@@ -410,13 +411,13 @@ func init() {
410411
kexAlgoMap[kexAlgoECDH384] = &ecdh{elliptic.P384()}
411412
kexAlgoMap[kexAlgoECDH256] = &ecdh{elliptic.P256()}
412413
kexAlgoMap[kexAlgoCurve25519SHA256] = &curve25519sha256{}
414+
kexAlgoMap[kexAlgoCurve25519SHA256LibSSH] = &curve25519sha256{}
413415
kexAlgoMap[kexAlgoDHGEXSHA1] = &dhGEXSHA{hashFunc: crypto.SHA1}
414416
kexAlgoMap[kexAlgoDHGEXSHA256] = &dhGEXSHA{hashFunc: crypto.SHA256}
415417
}
416418

417-
// curve25519sha256 implements the [email protected] key
418-
// agreement protocol, as described in
419-
// https://git.libssh.org/projects/libssh.git/tree/doc/[email protected]
419+
// curve25519sha256 implements the curve25519-sha256 (formerly known as
420+
// [email protected]) key exchange method, as described in RFC 8731.
420421
type curve25519sha256 struct{}
421422

422423
type curve25519KeyPair struct {

0 commit comments

Comments
 (0)