generated from moul/golang-repo-template
/
guess_ssh.go
42 lines (36 loc) · 907 Bytes
/
guess_ssh.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package cryptoguess
import "golang.org/x/crypto/ssh"
func init() {
AvailableExperiments = append(AvailableExperiments, NewSSHAuthorizedKey)
}
type SSHAuthorizedKey struct{ *baseExperiment }
type ParsedSSHAuthorizedKey struct {
PublicKey ssh.PublicKey
Comment string
Options []string
}
func runSSHAuthorizedKey(exp Experiment) []Result {
results := []Result{}
pubkey, comment, options, _, err := ssh.ParseAuthorizedKey(exp.Input())
result := &baseResult{
exp: exp,
data: &ParsedSSHAuthorizedKey{
PublicKey: pubkey,
Comment: comment,
Options: options,
},
err: err,
}
results = append(results, result)
// FIXME: return more info: RSA, length, etc
return results
}
func NewSSHAuthorizedKey(input []byte) Experiment {
return &SSHAuthorizedKey{
baseExperiment: &baseExperiment{
input: input,
name: "SSH authorized key",
run: runSSHAuthorizedKey,
},
}
}