Skip to content

Commit cc6ca7e

Browse files
author
Gusted
committed
Remove workaround
- Introduced in go-gitea#17281 - Fixed in x/crypto: - golang/crypto@5d542ad - & golang/crypto@3147a52
1 parent 042596e commit cc6ca7e

File tree

1 file changed

+0
-56
lines changed

1 file changed

+0
-56
lines changed

modules/ssh/ssh.go

-56
Original file line numberDiff line numberDiff line change
@@ -317,65 +317,9 @@ 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.KeyAlgoRSASHA512,
333-
},
334-
&wrapSigner{
335-
Signer: signer,
336-
algorithm: gossh.KeyAlgoRSASHA256,
337-
},
338-
)
339-
}
340-
signers = append(signers, signer)
341-
}
342-
srv.HostSigners = signers
343-
344320
go listen(&srv)
345321
}
346322

347-
// wrapSigner wraps a signer and overrides its public key type with the provided algorithm
348-
type wrapSigner struct {
349-
ssh.Signer
350-
algorithm string
351-
}
352-
353-
// PublicKey returns an associated PublicKey instance.
354-
func (s *wrapSigner) PublicKey() gossh.PublicKey {
355-
return &wrapPublicKey{
356-
PublicKey: s.Signer.PublicKey(),
357-
algorithm: s.algorithm,
358-
}
359-
}
360-
361-
// Sign returns raw signature for the given data. This method
362-
// will apply the hash specified for the keytype to the data using
363-
// the algorithm assigned for this key
364-
func (s *wrapSigner) Sign(rand io.Reader, data []byte) (*gossh.Signature, error) {
365-
return s.Signer.(gossh.AlgorithmSigner).SignWithAlgorithm(rand, data, s.algorithm)
366-
}
367-
368-
// wrapPublicKey wraps a PublicKey and overrides its type
369-
type wrapPublicKey struct {
370-
gossh.PublicKey
371-
algorithm string
372-
}
373-
374-
// Type returns the algorithm
375-
func (k *wrapPublicKey) Type() string {
376-
return k.algorithm
377-
}
378-
379323
// GenKeyPair make a pair of public and private keys for SSH access.
380324
// Public key is encoded in the format for inclusion in an OpenSSH authorized_keys file.
381325
// Private Key generated is PEM encoded

0 commit comments

Comments
 (0)