Skip to content

Commit a1aeb9b

Browse files
drakkangopherbot
authored andcommitted
ssh: add test cases for compatibility with old (buggy) clients
Improved test cases for CL 506835. Change-Id: If4a98ae4a7b39d2e59b203d10080b71283e1a80e Reviewed-on: https://go-review.googlesource.com/c/crypto/+/525735 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Run-TryBot: Filippo Valsorda <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Filippo Valsorda <[email protected]> Auto-Submit: Filippo Valsorda <[email protected]>
1 parent 28c53ff commit a1aeb9b

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

ssh/client_auth_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,3 +1234,51 @@ func TestPublicKeyAndAlgoCompatibility(t *testing.T) {
12341234
t.Error("cert login passed with incompatible public key type and algorithm")
12351235
}
12361236
}
1237+
1238+
func TestClientAuthGPGAgentCompat(t *testing.T) {
1239+
clientConfig := &ClientConfig{
1240+
User: "testuser",
1241+
HostKeyCallback: InsecureIgnoreHostKey(),
1242+
Auth: []AuthMethod{
1243+
// algorithm rsa-sha2-512 and signature format ssh-rsa.
1244+
configurablePublicKeyCallback{
1245+
signer: testSigners["rsa"].(AlgorithmSigner),
1246+
signatureAlgo: KeyAlgoRSASHA512,
1247+
signatureFormat: KeyAlgoRSA,
1248+
},
1249+
},
1250+
}
1251+
if err := tryAuth(t, clientConfig); err != nil {
1252+
t.Fatalf("unable to dial remote side: %s", err)
1253+
}
1254+
}
1255+
1256+
func TestCertAuthOpenSSHCompat(t *testing.T) {
1257+
cert := &Certificate{
1258+
Key: testPublicKeys["rsa"],
1259+
ValidBefore: CertTimeInfinity,
1260+
CertType: UserCert,
1261+
}
1262+
cert.SignCert(rand.Reader, testSigners["ecdsa"])
1263+
certSigner, err := NewCertSigner(cert, testSigners["rsa"])
1264+
if err != nil {
1265+
t.Fatalf("NewCertSigner: %v", err)
1266+
}
1267+
1268+
clientConfig := &ClientConfig{
1269+
User: "user",
1270+
HostKeyCallback: InsecureIgnoreHostKey(),
1271+
Auth: []AuthMethod{
1272+
// algorithm [email protected] and signature format
1273+
// rsa-sha2-256.
1274+
configurablePublicKeyCallback{
1275+
signer: certSigner.(AlgorithmSigner),
1276+
signatureAlgo: CertAlgoRSAv01,
1277+
signatureFormat: KeyAlgoRSASHA256,
1278+
},
1279+
},
1280+
}
1281+
if err := tryAuth(t, clientConfig); err != nil {
1282+
t.Fatalf("unable to dial remote side: %s", err)
1283+
}
1284+
}

0 commit comments

Comments
 (0)