From bb226e340e6c5ee66b4bf608760f9e341b8783c4 Mon Sep 17 00:00:00 2001 From: Morten Linderud Date: Thu, 26 Dec 2024 00:18:04 +0100 Subject: [PATCH] ssh/agent: parse public key with ssh.ParsePublicKey When the server gets an `agentSignRequest` it can be `ssh.PublicKey` or `ssh.Certificate` formatted keys. As the server only parsed these into `ssh.Key` they would require a `Marshal()` to `ParsePublicKey()` dance when the passed key is a certificate. Use `ssh.ParsePublicKey` instead of the `ssh.Key` struct directly. Signed-off-by: Morten Linderud --- ssh/agent/server.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ssh/agent/server.go b/ssh/agent/server.go index e35ca7ce31..e87153ba7a 100644 --- a/ssh/agent/server.go +++ b/ssh/agent/server.go @@ -123,13 +123,13 @@ func (s *server) processRequest(data []byte) (interface{}, error) { return nil, err } - k := &Key{ - Format: wk.Format, - Blob: req.KeyBlob, + var err error + k, err := ssh.ParsePublicKey(req.KeyBlob) + if err != nil { + return nil, err } var sig *ssh.Signature - var err error if extendedAgent, ok := s.agent.(ExtendedAgent); ok { sig, err = extendedAgent.SignWithFlags(k, req.Data, SignatureFlags(req.Flags)) } else {