@@ -772,7 +772,7 @@ func (s *agentKeyringSigner) Sign(rand io.Reader, data []byte) (*ssh.Signature,
772
772
}
773
773
774
774
func (s * agentKeyringSigner ) SignWithAlgorithm (rand io.Reader , data []byte , algorithm string ) (* ssh.Signature , error ) {
775
- if algorithm == "" || algorithm == s .pub .Type () {
775
+ if algorithm == "" || algorithm == underlyingAlgo ( s .pub .Type () ) {
776
776
return s .Sign (rand , data )
777
777
}
778
778
@@ -791,6 +791,33 @@ func (s *agentKeyringSigner) SignWithAlgorithm(rand io.Reader, data []byte, algo
791
791
792
792
var _ ssh.AlgorithmSigner = & agentKeyringSigner {}
793
793
794
+ // certKeyAlgoNames is a mapping from known certificate algorithm names to the
795
+ // corresponding public key signature algorithm.
796
+ //
797
+ // This map must be kept in sync with the one in certs.go.
798
+ var certKeyAlgoNames = map [string ]string {
799
+ ssh .CertAlgoRSAv01 : ssh .KeyAlgoRSA ,
800
+ ssh .CertAlgoRSASHA256v01 : ssh .KeyAlgoRSASHA256 ,
801
+ ssh .CertAlgoRSASHA512v01 : ssh .KeyAlgoRSASHA512 ,
802
+ ssh .CertAlgoDSAv01 : ssh .KeyAlgoDSA ,
803
+ ssh .CertAlgoECDSA256v01 : ssh .KeyAlgoECDSA256 ,
804
+ ssh .CertAlgoECDSA384v01 : ssh .KeyAlgoECDSA384 ,
805
+ ssh .CertAlgoECDSA521v01 : ssh .KeyAlgoECDSA521 ,
806
+ ssh .CertAlgoSKECDSA256v01 : ssh .KeyAlgoSKECDSA256 ,
807
+ ssh .CertAlgoED25519v01 : ssh .KeyAlgoED25519 ,
808
+ ssh .CertAlgoSKED25519v01 : ssh .KeyAlgoSKED25519 ,
809
+ }
810
+
811
+ // underlyingAlgo returns the signature algorithm associated with algo (which is
812
+ // an advertised or negotiated public key or host key algorithm). These are
813
+ // usually the same, except for certificate algorithms.
814
+ func underlyingAlgo (algo string ) string {
815
+ if a , ok := certKeyAlgoNames [algo ]; ok {
816
+ return a
817
+ }
818
+ return algo
819
+ }
820
+
794
821
// Calls an extension method. It is up to the agent implementation as to whether or not
795
822
// any particular extension is supported and may always return an error. Because the
796
823
// type of the response is up to the implementation, this returns the bytes of the
0 commit comments