Skip to content

Commit c1e6be4

Browse files
author
Gusted
authored
Update golang.org/x/crypto (#19097) (#19098)
Backport #19097 * Update golang.org/x/crypto (#19097) - Backport #19097 * Fix deprecation notice * Backport workaround removal
1 parent 79a5e68 commit c1e6be4

File tree

3 files changed

+3
-59
lines changed

3 files changed

+3
-59
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ require (
121121
go.uber.org/atomic v1.9.0 // indirect
122122
go.uber.org/multierr v1.7.0 // indirect
123123
go.uber.org/zap v1.19.0 // indirect
124-
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871
124+
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd
125125
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
126126
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
127127
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e

go.sum

+2-1
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,9 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm
12621262
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
12631263
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
12641264
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
1265-
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 h1:/pEO3GD/ABYAjuakUS6xSEmmlyVS4kxBNkeA9tLJiTI=
12661265
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
1266+
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38=
1267+
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
12671268
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
12681269
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
12691270
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=

modules/ssh/ssh.go

-57
Original file line numberDiff line numberDiff line change
@@ -317,64 +317,7 @@ func Listen(host string, port int, ciphers, keyExchanges, macs []string) {
317317
}
318318
}
319319

320-
// Workaround slightly broken behaviour in x/crypto/ssh/handshake.go:458-463
321-
//
322-
// Fundamentally the issue here is that HostKeyAlgos make the incorrect assumption
323-
// that the PublicKey().Type() matches the signature algorithm.
324-
//
325-
// Therefore we need to add duplicates for the RSA with different signing algorithms.
326-
signers := make([]ssh.Signer, 0, len(srv.HostSigners))
327-
for _, signer := range srv.HostSigners {
328-
if signer.PublicKey().Type() == "ssh-rsa" {
329-
signers = append(signers,
330-
&wrapSigner{
331-
Signer: signer,
332-
algorithm: gossh.SigAlgoRSASHA2512,
333-
},
334-
&wrapSigner{
335-
Signer: signer,
336-
algorithm: gossh.SigAlgoRSASHA2256,
337-
},
338-
)
339-
}
340-
signers = append(signers, signer)
341-
}
342-
srv.HostSigners = signers
343-
344320
go listen(&srv)
345-
346-
}
347-
348-
// wrapSigner wraps a signer and overrides its public key type with the provided algorithm
349-
type wrapSigner struct {
350-
ssh.Signer
351-
algorithm string
352-
}
353-
354-
// PublicKey returns an associated PublicKey instance.
355-
func (s *wrapSigner) PublicKey() gossh.PublicKey {
356-
return &wrapPublicKey{
357-
PublicKey: s.Signer.PublicKey(),
358-
algorithm: s.algorithm,
359-
}
360-
}
361-
362-
// Sign returns raw signature for the given data. This method
363-
// will apply the hash specified for the keytype to the data using
364-
// the algorithm assigned for this key
365-
func (s *wrapSigner) Sign(rand io.Reader, data []byte) (*gossh.Signature, error) {
366-
return s.Signer.(gossh.AlgorithmSigner).SignWithAlgorithm(rand, data, s.algorithm)
367-
}
368-
369-
// wrapPublicKey wraps a PublicKey and overrides its type
370-
type wrapPublicKey struct {
371-
gossh.PublicKey
372-
algorithm string
373-
}
374-
375-
// Type returns the algorithm
376-
func (k *wrapPublicKey) Type() string {
377-
return k.algorithm
378321
}
379322

380323
// GenKeyPair make a pair of public and private keys for SSH access.

0 commit comments

Comments
 (0)