Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preferred key algorithms #99

Merged
merged 3 commits into from
Apr 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ssh/kex.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package ssh

import "golang.org/x/crypto/ssh"

// These string constant are gotten from golang/crypto
hiddeco marked this conversation as resolved.
Show resolved Hide resolved
// https://github.com/golang/crypto/blob/0c34fe9e7dc2486962ef9867e3edb3503537209f/ssh/kex.go#L23-L34
const (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would add a comment here that points to the origin the strings were copied from so that it will be easier to sync them in the future.

kexAlgoDH1SHA1 = "diffie-hellman-group1-sha1"
kexAlgoDH14SHA1 = "diffie-hellman-group14-sha1"
Expand All @@ -33,14 +35,16 @@ const (
kexAlgoDHGEXSHA256 = "diffie-hellman-group-exchange-sha256"
)

// This is aligned with the preferredKeyAlgos from golang/crypto but includes kexAlgoDHGEXSHA256.

var PreferredKexAlgos = []string{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would add a comment here that it is aligned with the preferredKeyAlgos from golang/crypto, but includes kexAlgoDHGEXSHA256.

hiddeco marked this conversation as resolved.
Show resolved Hide resolved
kexAlgoCurve25519SHA256,
kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521,
kexAlgoDH14SHA1,
kexAlgoDHGEXSHA256,
}

// SetPreferredKeyAlgos sets default key algorithms on ClientConfig
// SetPreferredKeyAlgos sets the PreferredKexAlgos algorithms on a given ClientConfig
hiddeco marked this conversation as resolved.
Show resolved Hide resolved
func SetPreferredKeyAlgos(config *ssh.ClientConfig) {
if config != nil {
config.KeyExchanges = PreferredKexAlgos
Expand Down