Skip to content

Commit

Permalink
ssh: add test cases for compatibility with old (buggy) clients
Browse files Browse the repository at this point in the history
Improved test cases for CL 506835.

Change-Id: If4a98ae4a7b39d2e59b203d10080b71283e1a80e
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/525735
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
  • Loading branch information
drakkan authored and gopherbot committed Sep 20, 2023
1 parent 28c53ff commit a1aeb9b
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions ssh/client_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1234,3 +1234,51 @@ func TestPublicKeyAndAlgoCompatibility(t *testing.T) {
t.Error("cert login passed with incompatible public key type and algorithm")
}
}

func TestClientAuthGPGAgentCompat(t *testing.T) {
clientConfig := &ClientConfig{
User: "testuser",
HostKeyCallback: InsecureIgnoreHostKey(),
Auth: []AuthMethod{
// algorithm rsa-sha2-512 and signature format ssh-rsa.
configurablePublicKeyCallback{
signer: testSigners["rsa"].(AlgorithmSigner),
signatureAlgo: KeyAlgoRSASHA512,
signatureFormat: KeyAlgoRSA,
},
},
}
if err := tryAuth(t, clientConfig); err != nil {
t.Fatalf("unable to dial remote side: %s", err)
}
}

func TestCertAuthOpenSSHCompat(t *testing.T) {
cert := &Certificate{
Key: testPublicKeys["rsa"],
ValidBefore: CertTimeInfinity,
CertType: UserCert,
}
cert.SignCert(rand.Reader, testSigners["ecdsa"])
certSigner, err := NewCertSigner(cert, testSigners["rsa"])
if err != nil {
t.Fatalf("NewCertSigner: %v", err)
}

clientConfig := &ClientConfig{
User: "user",
HostKeyCallback: InsecureIgnoreHostKey(),
Auth: []AuthMethod{
// algorithm ssh-rsa-cert-v01@openssh.com and signature format
// rsa-sha2-256.
configurablePublicKeyCallback{
signer: certSigner.(AlgorithmSigner),
signatureAlgo: CertAlgoRSAv01,
signatureFormat: KeyAlgoRSASHA256,
},
},
}
if err := tryAuth(t, clientConfig); err != nil {
t.Fatalf("unable to dial remote side: %s", err)
}
}

0 comments on commit a1aeb9b

Please sign in to comment.