MCPcopy Create free account
hub / github.com/gogs/gogs / extractTypeFromBase64Key

Function extractTypeFromBase64Key

internal/database/ssh_key.go:92–104  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

90}
91
92func extractTypeFromBase64Key(key string) (string, error) {
93 b, err := base64.StdEncoding.DecodeString(key)
94 if err != nil || len(b) < 4 {
95 return "", errors.Newf("invalid key format: %v", err)
96 }
97
98 keyLength := int(binary.BigEndian.Uint32(b))
99 if len(b) < 4+keyLength {
100 return "", errors.Newf("invalid key format: not enough length %d", keyLength)
101 }
102
103 return string(b[4 : 4+keyLength]), nil
104}
105
106// parseKeyString parses any key string in OpenSSH or SSH2 format to clean OpenSSH string (RFC4253).
107func parseKeyString(content string) (string, error) {

Callers 1

parseKeyStringFunction · 0.85

Calls 1

stringFunction · 0.85

Tested by

no test coverage detected