Skip to content

Commit

Permalink
agent: support rsa-sha256
Browse files Browse the repository at this point in the history
This also implements some support for rsa-sha512 but we only do this for
appropriate error messages.

Signed-off-by: Morten Linderud <[email protected]>
  • Loading branch information
Foxboron committed Aug 21, 2023
1 parent dfe0219 commit 2a45add
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,19 @@ func (a *Agent) SignWithFlags(key ssh.PublicKey, data []byte, flags agent.Signat
return nil, err
}

alg := key.Type()
switch {
case alg == ssh.KeyAlgoRSA && flags&agent.SignatureFlagRsaSha256 != 0:
alg = ssh.KeyAlgoRSASHA256
case alg == ssh.KeyAlgoRSA && flags&agent.SignatureFlagRsaSha512 != 0:
alg = ssh.KeyAlgoRSASHA512
}

for _, s := range signers {
if !bytes.Equal(s.PublicKey().Marshal(), key.Marshal()) {
continue
}
return s.(ssh.AlgorithmSigner).SignWithAlgorithm(rand.Reader, data, key.Type())
return s.(ssh.AlgorithmSigner).SignWithAlgorithm(rand.Reader, data, alg)
}

log.Printf("trying to sign as proxy...")
Expand All @@ -157,7 +165,7 @@ func (a *Agent) SignWithFlags(key ssh.PublicKey, data []byte, flags agent.Signat
if !bytes.Equal(s.PublicKey().Marshal(), key.Marshal()) {
continue
}
return s.(ssh.AlgorithmSigner).SignWithAlgorithm(rand.Reader, data, key.Type())
return s.(ssh.AlgorithmSigner).SignWithAlgorithm(rand.Reader, data, alg)
}
}

Expand Down

0 comments on commit 2a45add

Please sign in to comment.