Skip to content

Commit bb226e3

Browse files
committed
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 <[email protected]>
1 parent 6018723 commit bb226e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ssh/agent/server.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ func (s *server) processRequest(data []byte) (interface{}, error) {
123123
return nil, err
124124
}
125125

126-
k := &Key{
127-
Format: wk.Format,
128-
Blob: req.KeyBlob,
126+
var err error
127+
k, err := ssh.ParsePublicKey(req.KeyBlob)
128+
if err != nil {
129+
return nil, err
129130
}
130131

131132
var sig *ssh.Signature
132-
var err error
133133
if extendedAgent, ok := s.agent.(ExtendedAgent); ok {
134134
sig, err = extendedAgent.SignWithFlags(k, req.Data, SignatureFlags(req.Flags))
135135
} else {

0 commit comments

Comments
 (0)