Skip to content

Commit fcc990c

Browse files
committed
ssh: deprecate and replace SigAlgo constants
RFC 8332, Section 2 sets up two overlapping namespaces: public key formats and public key algorithms. * The formats are what we currently have KeyAlgo constants for, and they appear in PublicKey.Type. * The algorithms are the set of both KeyAlgo and SigAlgo constants, and they appear in Signature.Format (amongst other places). This is incoherent, because that means Signature.Format can be both a KeyAlgo (like KeyAlgoECDSA256) or a SigAlgo (like SigAlgoRSASHA2256). One solution would be to duplicate all the KeyAlgo constants into the SigAlgo namespace, but that would be confusing because applications are currently using KeyAlgos where they'd be supposed to use the new SigAlgos (while we can't deprecate the KeyAlgos because they are still necessary for the PublicKey.Type namespace). Instead, drop the separate namespaces, and use KeyAlgos throughout. There are simply some KeyAlgos that can't be a PublicKey.Type. Take the opportunity to fix the stuttering SHA22565/SHA2512 names. It's totally ok to call those hashes SHA-256 and SHA-512 without the family infix. For golang/go#49952 Change-Id: Ia1fce3912a7e60aa70a88f75ed311be331fd19d5 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/392354 Trust: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
1 parent 4d39909 commit fcc990c

13 files changed

+93
-82
lines changed

ssh/agent/client_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ func testAgentInterface(t *testing.T, agent ExtendedAgent, key interface{}, cert
182182
t.Fatalf("Verify(%s): %v", pubKey.Type(), err)
183183
}
184184
}
185-
sshFlagTest(0, ssh.SigAlgoRSA)
186-
sshFlagTest(SignatureFlagRsaSha256, ssh.SigAlgoRSASHA2256)
187-
sshFlagTest(SignatureFlagRsaSha512, ssh.SigAlgoRSASHA2512)
185+
sshFlagTest(0, ssh.KeyAlgoRSA)
186+
sshFlagTest(SignatureFlagRsaSha256, ssh.KeyAlgoRSASHA256)
187+
sshFlagTest(SignatureFlagRsaSha512, ssh.KeyAlgoRSASHA512)
188188
}
189189

190190
// If the key has a lifetime, is it removed when it should be?

ssh/agent/keyring.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ func (r *keyring) SignWithFlags(key ssh.PublicKey, data []byte, flags SignatureF
205205
var algorithm string
206206
switch flags {
207207
case SignatureFlagRsaSha256:
208-
algorithm = ssh.SigAlgoRSASHA2256
208+
algorithm = ssh.KeyAlgoRSASHA256
209209
case SignatureFlagRsaSha512:
210-
algorithm = ssh.SigAlgoRSASHA2512
210+
algorithm = ssh.KeyAlgoRSASHA512
211211
default:
212212
return nil, fmt.Errorf("agent: unsupported signature flags: %d", flags)
213213
}

ssh/certs.go

+22-15
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import (
1414
"time"
1515
)
1616

17-
// These constants from [PROTOCOL.certkeys] represent the key algorithm names
18-
// for certificate types supported by this package.
17+
// Certificate algorithm names from [PROTOCOL.certkeys]. These values can appear
18+
// in Certificate.Type, PublicKey.Type, and ClientConfig.HostKeyAlgorithms.
19+
// Unlike key algorithm names, these are not passed to AlgorithmSigner and don't
20+
// appear in the Signature.Format field.
1921
const (
2022
CertAlgoRSAv01 = "ssh-rsa-cert-v01@openssh.com"
2123
CertAlgoDSAv01 = "ssh-dss-cert-v01@openssh.com"
@@ -25,14 +27,21 @@ const (
2527
CertAlgoSKECDSA256v01 = "sk-ecdsa-sha2-nistp256-cert-v01@openssh.com"
2628
CertAlgoED25519v01 = "ssh-ed25519-cert-v01@openssh.com"
2729
CertAlgoSKED25519v01 = "sk-ssh-ed25519-cert-v01@openssh.com"
30+
31+
// CertAlgoRSASHA256v01 and CertAlgoRSASHA512v01 can't appear as a
32+
// Certificate.Type (or PublicKey.Type), but only in
33+
// ClientConfig.HostKeyAlgorithms.
34+
CertAlgoRSASHA256v01 = "rsa-sha2-256-cert-v01@openssh.com"
35+
CertAlgoRSASHA512v01 = "rsa-sha2-512-cert-v01@openssh.com"
2836
)
2937

30-
// These constants from [PROTOCOL.certkeys] represent additional signature
31-
// algorithm names for certificate types supported by this package.
3238
const (
33-
CertSigAlgoRSAv01 = "ssh-rsa-cert-v01@openssh.com"
34-
CertSigAlgoRSASHA2256v01 = "rsa-sha2-256-cert-v01@openssh.com"
35-
CertSigAlgoRSASHA2512v01 = "rsa-sha2-512-cert-v01@openssh.com"
39+
// Deprecated: use CertAlgoRSAv01.
40+
CertSigAlgoRSAv01 = CertAlgoRSAv01
41+
// Deprecated: use CertAlgoRSASHA256v01.
42+
CertSigAlgoRSASHA2256v01 = CertAlgoRSASHA256v01
43+
// Deprecated: use CertAlgoRSASHA512v01.
44+
CertSigAlgoRSASHA2512v01 = CertAlgoRSASHA512v01
3645
)
3746

3847
// Certificate types distinguish between host and user
@@ -433,7 +442,7 @@ func (c *Certificate) SignCert(rand io.Reader, authority Signer) error {
433442

434443
if v, ok := authority.(AlgorithmSigner); ok {
435444
if v.PublicKey().Type() == KeyAlgoRSA {
436-
authority = &rsaSigner{v, SigAlgoRSASHA2512}
445+
authority = &rsaSigner{v, KeyAlgoRSASHA512}
437446
}
438447
}
439448

@@ -446,13 +455,11 @@ func (c *Certificate) SignCert(rand io.Reader, authority Signer) error {
446455
}
447456

448457
// certAlgoNames includes a mapping from signature algorithms to the
449-
// corresponding certificate signature algorithm. When a key type (such
450-
// as ED25516) is associated with only one algorithm, the KeyAlgo
451-
// constant is used instead of the SigAlgo.
458+
// corresponding certificate signature algorithm.
452459
var certAlgoNames = map[string]string{
453-
SigAlgoRSA: CertSigAlgoRSAv01,
454-
SigAlgoRSASHA2256: CertSigAlgoRSASHA2256v01,
455-
SigAlgoRSASHA2512: CertSigAlgoRSASHA2512v01,
460+
KeyAlgoRSA: CertAlgoRSAv01,
461+
KeyAlgoRSASHA256: CertAlgoRSASHA256v01,
462+
KeyAlgoRSASHA512: CertAlgoRSASHA512v01,
456463
KeyAlgoDSA: CertAlgoDSAv01,
457464
KeyAlgoECDSA256: CertAlgoECDSA256v01,
458465
KeyAlgoECDSA384: CertAlgoECDSA384v01,
@@ -514,7 +521,7 @@ func (c *Certificate) Marshal() []byte {
514521
return result
515522
}
516523

517-
// Type returns the key name. It is part of the PublicKey interface.
524+
// Type returns the certificate algorithm name. It is part of the PublicKey interface.
518525
func (c *Certificate) Type() string {
519526
algo, ok := certAlgoNames[c.Key.Type()]
520527
if !ok {

ssh/certs_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func (s *legacyRSASigner) Sign(rand io.Reader, data []byte) (*Signature, error)
235235
if !ok {
236236
return nil, fmt.Errorf("invalid signer")
237237
}
238-
return v.SignWithAlgorithm(rand, data, SigAlgoRSA)
238+
return v.SignWithAlgorithm(rand, data, KeyAlgoRSA)
239239
}
240240

241241
func TestCertTypes(t *testing.T) {
@@ -248,10 +248,10 @@ func TestCertTypes(t *testing.T) {
248248
{CertAlgoECDSA384v01, testSigners["ecdsap384"], ""},
249249
{CertAlgoECDSA521v01, testSigners["ecdsap521"], ""},
250250
{CertAlgoED25519v01, testSigners["ed25519"], ""},
251-
{CertAlgoRSAv01, testSigners["rsa"], SigAlgoRSASHA2512},
252-
{CertAlgoRSAv01, &legacyRSASigner{testSigners["rsa"]}, SigAlgoRSA},
253-
{CertAlgoRSAv01, testSigners["rsa-sha2-256"], SigAlgoRSASHA2512},
254-
{CertAlgoRSAv01, testSigners["rsa-sha2-512"], SigAlgoRSASHA2512},
251+
{CertAlgoRSAv01, testSigners["rsa"], KeyAlgoRSASHA512},
252+
{CertAlgoRSAv01, &legacyRSASigner{testSigners["rsa"]}, KeyAlgoRSA},
253+
{CertAlgoRSAv01, testSigners["rsa-sha2-256"], KeyAlgoRSASHA512},
254+
{CertAlgoRSAv01, testSigners["rsa-sha2-512"], KeyAlgoRSASHA512},
255255
{CertAlgoDSAv01, testSigners["dsa"], ""},
256256
}
257257

ssh/client.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ type ClientConfig struct {
237237
// be used for the connection. If empty, a reasonable default is used.
238238
ClientVersion string
239239

240-
// HostKeyAlgorithms lists the key types that the client will
241-
// accept from the server as host key, in order of
240+
// HostKeyAlgorithms lists the public key algorithms that the client will
241+
// accept from the server for host key authentication, in order of
242242
// preference. If empty, a reasonable default is used. Any
243-
// string returned from PublicKey.Type method may be used, or
244-
// any of the CertAlgoXxxx and KeyAlgoXxxx constants.
243+
// string returned from a PublicKey.Type method may be used, or
244+
// any of the CertAlgo and KeyAlgo constants.
245245
HostKeyAlgorithms []string
246246

247247
// Timeout is the maximum amount of time for the TCP connection to establish.

ssh/client_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ func TestVerifyHostKeySignature(t *testing.T) {
125125
verifyAlgo string
126126
wantError string
127127
}{
128-
{"rsa", SigAlgoRSA, SigAlgoRSA, ""},
129-
{"rsa", SigAlgoRSASHA2256, SigAlgoRSASHA2256, ""},
130-
{"rsa", SigAlgoRSA, SigAlgoRSASHA2512, `ssh: invalid signature algorithm "ssh-rsa", expected "rsa-sha2-512"`},
128+
{"rsa", KeyAlgoRSA, KeyAlgoRSA, ""},
129+
{"rsa", KeyAlgoRSASHA256, KeyAlgoRSASHA256, ""},
130+
{"rsa", KeyAlgoRSA, KeyAlgoRSASHA512, `ssh: invalid signature algorithm "ssh-rsa", expected "rsa-sha2-512"`},
131131
{"ed25519", KeyAlgoED25519, KeyAlgoED25519, ""},
132132
} {
133133
key := testSigners[tt.key].PublicKey()

ssh/common.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ var preferredKexAlgos = []string{
6969
// supportedHostKeyAlgos specifies the supported host-key algorithms (i.e. methods
7070
// of authenticating servers) in preference order.
7171
var supportedHostKeyAlgos = []string{
72-
CertSigAlgoRSASHA2512v01, CertSigAlgoRSASHA2256v01,
73-
CertSigAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01,
72+
CertAlgoRSASHA512v01, CertAlgoRSASHA256v01,
73+
CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01,
7474
CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoED25519v01,
7575

7676
KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521,
77-
SigAlgoRSASHA2512, SigAlgoRSASHA2256,
78-
SigAlgoRSA, KeyAlgoDSA,
77+
KeyAlgoRSASHA512, KeyAlgoRSASHA256,
78+
KeyAlgoRSA, KeyAlgoDSA,
7979

8080
KeyAlgoED25519,
8181
}
@@ -92,20 +92,20 @@ var supportedCompressions = []string{compressionNone}
9292
// hashFuncs keeps the mapping of supported algorithms to their respective
9393
// hashes needed for signature verification.
9494
var hashFuncs = map[string]crypto.Hash{
95-
SigAlgoRSA: crypto.SHA1,
96-
SigAlgoRSASHA2256: crypto.SHA256,
97-
SigAlgoRSASHA2512: crypto.SHA512,
98-
KeyAlgoDSA: crypto.SHA1,
99-
KeyAlgoECDSA256: crypto.SHA256,
100-
KeyAlgoECDSA384: crypto.SHA384,
101-
KeyAlgoECDSA521: crypto.SHA512,
102-
CertSigAlgoRSAv01: crypto.SHA1,
103-
CertSigAlgoRSASHA2256v01: crypto.SHA256,
104-
CertSigAlgoRSASHA2512v01: crypto.SHA512,
105-
CertAlgoDSAv01: crypto.SHA1,
106-
CertAlgoECDSA256v01: crypto.SHA256,
107-
CertAlgoECDSA384v01: crypto.SHA384,
108-
CertAlgoECDSA521v01: crypto.SHA512,
95+
KeyAlgoRSA: crypto.SHA1,
96+
KeyAlgoRSASHA256: crypto.SHA256,
97+
KeyAlgoRSASHA512: crypto.SHA512,
98+
KeyAlgoDSA: crypto.SHA1,
99+
KeyAlgoECDSA256: crypto.SHA256,
100+
KeyAlgoECDSA384: crypto.SHA384,
101+
KeyAlgoECDSA521: crypto.SHA512,
102+
CertAlgoRSAv01: crypto.SHA1,
103+
CertAlgoRSASHA256v01: crypto.SHA256,
104+
CertAlgoRSASHA512v01: crypto.SHA512,
105+
CertAlgoDSAv01: crypto.SHA1,
106+
CertAlgoECDSA256v01: crypto.SHA256,
107+
CertAlgoECDSA384v01: crypto.SHA384,
108+
CertAlgoECDSA521v01: crypto.SHA512,
109109
}
110110

111111
// unexpectedMessageError results when the SSH message that we received didn't

ssh/handshake.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,9 @@ func (t *handshakeTransport) sendKexInit() error {
460460
algo := k.PublicKey().Type()
461461
switch algo {
462462
case KeyAlgoRSA:
463-
msg.ServerHostKeyAlgos = append(msg.ServerHostKeyAlgos, []string{SigAlgoRSASHA2512, SigAlgoRSASHA2256, SigAlgoRSA}...)
463+
msg.ServerHostKeyAlgos = append(msg.ServerHostKeyAlgos, []string{KeyAlgoRSASHA512, KeyAlgoRSASHA256, KeyAlgoRSA}...)
464464
case CertAlgoRSAv01:
465-
msg.ServerHostKeyAlgos = append(msg.ServerHostKeyAlgos, []string{CertSigAlgoRSASHA2512v01, CertSigAlgoRSASHA2256v01, CertSigAlgoRSAv01}...)
465+
msg.ServerHostKeyAlgos = append(msg.ServerHostKeyAlgos, []string{CertAlgoRSASHA512v01, CertAlgoRSASHA256v01, CertAlgoRSAv01}...)
466466
default:
467467
msg.ServerHostKeyAlgos = append(msg.ServerHostKeyAlgos, algo)
468468
}
@@ -629,11 +629,11 @@ func (t *handshakeTransport) server(kex kexAlgorithm, algs *algorithms, magics *
629629
// so we have to manually check for a compatible host key.
630630
switch kt {
631631
case KeyAlgoRSA:
632-
if algs.hostKey == SigAlgoRSASHA2256 || algs.hostKey == SigAlgoRSASHA2512 {
632+
if algs.hostKey == KeyAlgoRSASHA256 || algs.hostKey == KeyAlgoRSASHA512 {
633633
hostKey = &rsaSigner{signer, algs.hostKey}
634634
}
635635
case CertAlgoRSAv01:
636-
if algs.hostKey == CertSigAlgoRSASHA2256v01 || algs.hostKey == CertSigAlgoRSASHA2512v01 {
636+
if algs.hostKey == CertAlgoRSASHA256v01 || algs.hostKey == CertAlgoRSASHA512v01 {
637637
hostKey = &rsaSigner{signer, certToPrivAlgo(algs.hostKey)}
638638
}
639639
}

ssh/keys.go

+25-21
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ import (
3030
"golang.org/x/crypto/ssh/internal/bcrypt_pbkdf"
3131
)
3232

33-
// These constants represent the algorithm names for key types supported by this
34-
// package.
33+
// Public key algorithms names. These values can appear in PublicKey.Type,
34+
// ClientConfig.HostKeyAlgorithms, Signature.Format, or as AlgorithmSigner
35+
// arguments.
3536
const (
3637
KeyAlgoRSA = "ssh-rsa"
3738
KeyAlgoDSA = "ssh-dss"
@@ -41,16 +42,21 @@ const (
4142
KeyAlgoECDSA521 = "ecdsa-sha2-nistp521"
4243
KeyAlgoED25519 = "ssh-ed25519"
4344
KeyAlgoSKED25519 = "sk-ssh-ed25519@openssh.com"
45+
46+
// KeyAlgoRSASHA256 and KeyAlgoRSASHA512 are only public key algorithms, not
47+
// public key formats, so they can't appear as a PublicKey.Type. The
48+
// corresponding PublicKey.Type is KeyAlgoRSA. See RFC 8332, Section 2.
49+
KeyAlgoRSASHA256 = "rsa-sha2-256"
50+
KeyAlgoRSASHA512 = "rsa-sha2-512"
4451
)
4552

46-
// These constants represent non-default signature algorithms that are supported
47-
// as algorithm parameters to AlgorithmSigner.SignWithAlgorithm methods. See
48-
// [PROTOCOL.agent] section 4.5.1 and
49-
// https://tools.ietf.org/html/draft-ietf-curdle-rsa-sha2-10
5053
const (
51-
SigAlgoRSA = "ssh-rsa"
52-
SigAlgoRSASHA2256 = "rsa-sha2-256"
53-
SigAlgoRSASHA2512 = "rsa-sha2-512"
54+
// Deprecated: use KeyAlgoRSA.
55+
SigAlgoRSA = KeyAlgoRSA
56+
// Deprecated: use KeyAlgoRSASHA256.
57+
SigAlgoRSASHA2256 = KeyAlgoRSASHA256
58+
// Deprecated: use KeyAlgoRSASHA512.
59+
SigAlgoRSASHA2512 = KeyAlgoRSASHA512
5460
)
5561

5662
// parsePubKey parses a public key of the given algorithm.
@@ -325,11 +331,9 @@ type Signer interface {
325331
type AlgorithmSigner interface {
326332
Signer
327333

328-
// SignWithAlgorithm is like Signer.Sign, but allows specification of a
329-
// non-default signing algorithm. See the SigAlgo* constants in this
330-
// package for signature algorithms supported by this package. Callers may
331-
// pass an empty string for the algorithm in which case the AlgorithmSigner
332-
// will use its default algorithm.
334+
// SignWithAlgorithm is like Signer.Sign, but allows specifying a desired
335+
// signing algorithm. Callers may pass an empty string for the algorithm in
336+
// which case the AlgorithmSigner will use a default algorithm.
333337
SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error)
334338
}
335339

@@ -383,11 +387,11 @@ func (r *rsaPublicKey) Marshal() []byte {
383387
func (r *rsaPublicKey) Verify(data []byte, sig *Signature) error {
384388
var hash crypto.Hash
385389
switch sig.Format {
386-
case SigAlgoRSA:
390+
case KeyAlgoRSA:
387391
hash = crypto.SHA1
388-
case SigAlgoRSASHA2256:
392+
case KeyAlgoRSASHA256:
389393
hash = crypto.SHA256
390-
case SigAlgoRSASHA2512:
394+
case KeyAlgoRSASHA512:
391395
hash = crypto.SHA512
392396
default:
393397
return fmt.Errorf("ssh: signature type %s for key type %s", sig.Format, r.Type())
@@ -979,12 +983,12 @@ func (s *wrappedSigner) SignWithAlgorithm(rand io.Reader, data []byte, algorithm
979983
if _, ok := s.pubKey.(*rsaPublicKey); ok {
980984
// RSA keys support a few hash functions determined by the requested signature algorithm
981985
switch algorithm {
982-
case "", SigAlgoRSA:
983-
algorithm = SigAlgoRSA
986+
case "", KeyAlgoRSA:
987+
algorithm = KeyAlgoRSA
984988
hashFunc = crypto.SHA1
985-
case SigAlgoRSASHA2256:
989+
case KeyAlgoRSASHA256:
986990
hashFunc = crypto.SHA256
987-
case SigAlgoRSASHA2512:
991+
case KeyAlgoRSASHA512:
988992
hashFunc = crypto.SHA512
989993
default:
990994
return nil, fmt.Errorf("ssh: unsupported signature algorithm %s", algorithm)

ssh/keys_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestKeySignWithAlgorithmVerify(t *testing.T) {
145145

146146
// RSA keys are the only ones which currently support more than one signing algorithm
147147
if pub.Type() == KeyAlgoRSA {
148-
for _, algorithm := range []string{SigAlgoRSA, SigAlgoRSASHA2256, SigAlgoRSASHA2512} {
148+
for _, algorithm := range []string{KeyAlgoRSA, KeyAlgoRSASHA256, KeyAlgoRSASHA512} {
149149
signWithAlgTestCase(algorithm, algorithm)
150150
}
151151
}

ssh/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ type ServerConfig struct {
120120
}
121121

122122
// AddHostKey adds a private key as a host key. If an existing host
123-
// key exists with the same algorithm, it is overwritten. Each server
123+
// key exists with the same public key format, it is replaced. Each server
124124
// config must have at least one host key.
125125
func (s *ServerConfig) AddHostKey(key Signer) {
126126
for i, k := range s.hostKeys {
@@ -284,7 +284,7 @@ func (s *connection) serverHandshake(config *ServerConfig) (*Permissions, error)
284284

285285
func isAcceptableAlgo(algo string) bool {
286286
switch algo {
287-
case SigAlgoRSA, SigAlgoRSASHA2256, SigAlgoRSASHA2512, KeyAlgoDSA, KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521, KeyAlgoSKECDSA256, KeyAlgoED25519, KeyAlgoSKED25519,
287+
case KeyAlgoRSA, KeyAlgoRSASHA256, KeyAlgoRSASHA512, KeyAlgoDSA, KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521, KeyAlgoSKECDSA256, KeyAlgoED25519, KeyAlgoSKED25519,
288288
CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01, CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoSKECDSA256v01, CertAlgoED25519v01, CertAlgoSKED25519v01:
289289
return true
290290
}

ssh/session_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,11 @@ func TestHostKeyAlgorithms(t *testing.T) {
757757
connect(clientConf, KeyAlgoECDSA256)
758758

759759
// Client asks for RSA explicitly.
760-
clientConf.HostKeyAlgorithms = []string{SigAlgoRSA}
760+
clientConf.HostKeyAlgorithms = []string{KeyAlgoRSA}
761761
connect(clientConf, KeyAlgoRSA)
762762

763763
// Client asks for RSA-SHA2-512 explicitly.
764-
clientConf.HostKeyAlgorithms = []string{SigAlgoRSASHA2512}
764+
clientConf.HostKeyAlgorithms = []string{KeyAlgoRSASHA512}
765765
// We get back an "ssh-rsa" key but the verification happened
766766
// with an RSA-SHA2-512 signature.
767767
connect(clientConf, KeyAlgoRSA)

ssh/testdata_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ func init() {
3737
if v, ok := testSigners[t].(*rsaSigner); ok {
3838
switch t {
3939
case "rsa-sha2-256":
40-
testSigners[t] = &rsaSigner{v, SigAlgoRSASHA2256}
40+
testSigners[t] = &rsaSigner{v, KeyAlgoRSASHA256}
4141
case "rsa-sha2-512":
42-
testSigners[t] = &rsaSigner{v, SigAlgoRSASHA2512}
42+
testSigners[t] = &rsaSigner{v, KeyAlgoRSASHA512}
4343
}
4444
}
4545
if err != nil {

0 commit comments

Comments
 (0)