@@ -317,64 +317,7 @@ func Listen(host string, port int, ciphers, keyExchanges, macs []string) {
317
317
}
318
318
}
319
319
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
-
344
320
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
378
321
}
379
322
380
323
// GenKeyPair make a pair of public and private keys for SSH access.
0 commit comments