summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/crypto/ssh/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/crypto/ssh/client.go')
-rw-r--r--vendor/golang.org/x/crypto/ssh/client.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/vendor/golang.org/x/crypto/ssh/client.go b/vendor/golang.org/x/crypto/ssh/client.go
index 99f68bd3..ba8621a8 100644
--- a/vendor/golang.org/x/crypto/ssh/client.go
+++ b/vendor/golang.org/x/crypto/ssh/client.go
@@ -115,12 +115,25 @@ func (c *connection) clientHandshake(dialAddress string, config *ClientConfig) e
// verifyHostKeySignature verifies the host key obtained in the key
// exchange.
-func verifyHostKeySignature(hostKey PublicKey, result *kexResult) error {
+func verifyHostKeySignature(hostKey PublicKey, algo string, result *kexResult) error {
sig, rest, ok := parseSignatureBody(result.Signature)
if len(rest) > 0 || !ok {
return errors.New("ssh: signature parse error")
}
+ // For keys, underlyingAlgo is exactly algo. For certificates,
+ // we have to look up the underlying key algorithm that SSH
+ // uses to evaluate signatures.
+ underlyingAlgo := algo
+ for sigAlgo, certAlgo := range certAlgoNames {
+ if certAlgo == algo {
+ underlyingAlgo = sigAlgo
+ }
+ }
+ if sig.Format != underlyingAlgo {
+ return fmt.Errorf("ssh: invalid signature algorithm %q, expected %q", sig.Format, underlyingAlgo)
+ }
+
return hostKey.Verify(result.H, sig)
}