(s string)
| 111 | } |
| 112 | |
| 113 | func sshKeyType(s string) (string, bool) { |
| 114 | // TODO: also ignore options? And maybe support multiple spaces and tabs as |
| 115 | // field separators like OpenSSH? |
| 116 | fields := strings.Split(s, " ") |
| 117 | if len(fields) < 2 { |
| 118 | return "", false |
| 119 | } |
| 120 | key, err := base64.StdEncoding.DecodeString(fields[1]) |
| 121 | if err != nil { |
| 122 | return "", false |
| 123 | } |
| 124 | k := cryptobyte.String(key) |
| 125 | var typeLen uint32 |
| 126 | var typeBytes []byte |
| 127 | if !k.ReadUint32(&typeLen) || !k.ReadBytes(&typeBytes, int(typeLen)) { |
| 128 | return "", false |
| 129 | } |
| 130 | if t := fields[0]; t == string(typeBytes) { |
| 131 | return t, true |
| 132 | } |
| 133 | return "", false |
| 134 | } |
| 135 | |
| 136 | // parseIdentitiesFile parses a file that contains age or SSH keys. It returns |
| 137 | // one or more of *[age.X25519Identity], *[age.HybridIdentity], |
no test coverage detected
searching dependent graphs…