MCPcopy
hub / github.com/FiloSottile/age / sshKeyType

Function sshKeyType

cmd/age/parse.go:113–134  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

111}
112
113func 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],

Callers 1

parseRecipientsFileFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…