-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
proposal: x/crypto/ssh: expose supported Kex algorithms #46232
Comments
cc @FiloSottile |
This proposal has been added to the active column of the proposals project |
/cc @FiloSottile |
It would be nice if—for similar reasons—supported host key algorithms, ciphers and MACs could be exposed too, either as functions as suggested in the issue description, or simply by making those variables public. Supported MACs is especially important until #39397 is resolved to validate the supported algorithms. (Happy to open a separate issue, if you deem it necessary. I felt it was similar enough to just comment here.) |
/cc @FiloSottile |
I’m a little reluctant to add half a dozen SupportedX functions because we don’t really know if support will depend on client/server role or other logic in the future. For example the client-only key exchanges were only added recently. Maybe we can simply embrace the fact that the lists can be a superset, and silently ignore unsupported entries in configs, documenting which ones are special and how. This should still let applications tell their users an approximate list of (potentially) available options. This would mean adding the functions SupportedKeyExchanges, SupportedCiphers, SupportedMACs, and SupportedHostKeyAlgorithms (using Config field names), all returning []string. I’d be ok with that. In any case, since all values are pretty self-describing strings and not opaque IDs, we don’t need to expose all the constants. |
@rsc Yes a function returning a list of algorithms supported by the package would be work for me. There is one thing which is not clear to me with @FiloSottile's comment:
From my understanding, this is not about which algorithms are supported by a client, server or other future logic, but the algorithms supported (i.e. implemented) by |
Why not just have a function Supported that returns a struct { Makes the API a lot simpler and it is easy to extend later with extra fields if needed. |
@beoran one reason is that we typically want to return copies of these lists, so that they cannot be edited by clients, and (computing and) returning copies of lots of lists when the caller only cares about one is inefficient. |
@rsc hmm, that's a good point. In that case, the Supported function could in stead return a struct that has the methods KeyExchanges() []string, Ciphers() []string, MACs() []string, HostKeyAlgorithms() []string. Then you could write Supported().KeyExchanges(). Although it is a matter of taste if this is better than SupportedKeyExchanges(). I tend to like 'fluid" APIs but in this case, probably not. |
The thing is that we already have some algorithm (the negotiated DH kex) that are only supported on the client side. They are technically implemented for the server too, but only for use in test files, and you're not (supposed to be?) able to enable them from an application. |
This is starting to sound like maybe we should decline this proposal? Thoughts? |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Probably.
With
x/crypto/ssh
as of latest commit golang/crypto@c07d793What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
We're using the
x/crypto/ssh
package to implement an SSH client and we want to make allowed Key Exchange (kex) algorithms configurable by the user.Alas, the package doesn't provide us with a method to retrieve the supported algorithms, so we have to copy&paste the constants over to our own package. From a maintenance perspective, this might not be the best approach, because the supported algorithms in
x/crypto/ssh
may change over time and we'd have to track these changes.What did you expect to see?
I did expect a method in the
x/crypto/ssh
package that makes the list of available algorithms available to consumers of the package, e.g.KexAlgorithms() ([]string)
. As far as I understood from the code, client and server implementations support a different set of Kex algorithms, so maybeKexAlgorithmsClient() ([]string)
andKexAlgorithmsServer() ([]string)
could also make sense here.For example, with OpenSSH you can run
ssh -Q kex
to get a list of supported Kex algorithms in the client.What did you see instead?
Private constants in
x/crypto/ssh
package hereThe text was updated successfully, but these errors were encountered: