MCPcopy Index your code
hub / github.com/smallstep/cli / PublicKey

Function PublicKey

internal/sshutil/sshutil.go:48–66  ·  view source on GitHub ↗

PublicKey returns the Go's crypto.PublicKey of an ssh.PublicKey.

(key ssh.PublicKey)

Source from the content-addressed store, hash-verified

46
47// PublicKey returns the Go's crypto.PublicKey of an ssh.PublicKey.
48func PublicKey(key ssh.PublicKey) (crypto.PublicKey, error) {
49 _, in, ok := parseString(key.Marshal())
50 if !ok {
51 return nil, errors.New("public key is invalid")
52 }
53
54 switch key.Type() {
55 case ssh.KeyAlgoRSA:
56 return parseRSA(in)
57 case ssh.KeyAlgoECDSA256, ssh.KeyAlgoECDSA384, ssh.KeyAlgoECDSA521, ssh.KeyAlgoSKECDSA256:
58 return parseECDSA(in)
59 case ssh.KeyAlgoED25519, ssh.KeyAlgoSKED25519:
60 return parseED25519(in)
61 case ssh.InsecureKeyAlgoDSA: //nolint:staticcheck // compatibility with older tooling
62 return parseDSA(in)
63 default:
64 return nil, errors.Errorf("public key %s is not supported", key.Type())
65 }
66}
67
68func publicKeyTypeAndSize(key ssh.PublicKey) (string, int, error) {
69 var isCert bool

Callers

nothing calls this directly

Calls 6

parseStringFunction · 0.85
parseRSAFunction · 0.85
parseECDSAFunction · 0.85
parseED25519Function · 0.85
parseDSAFunction · 0.85
TypeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…