MCPcopy Create free account
hub / github.com/WICG/webpackage / ParsePublicKey

Function ParsePublicKey

go/internal/signingalgorithm/certs.go:108–122  ·  view source on GitHub ↗
(text []byte)

Source from the content-addressed store, hash-verified

106}
107
108func ParsePublicKey(text []byte) (crypto.PublicKey, error) {
109 for len(text) > 0 {
110 var block *pem.Block
111 block, text = pem.Decode(text)
112 if block == nil {
113 return nil, errors.New("signingalgorithm: invalid PEM block in public key.")
114 }
115
116 pubkey, err := parsePublicKeyBlock(block.Bytes)
117 if err == nil {
118 return pubkey, nil
119 }
120 }
121 return nil, errors.New("signingalgorithm: could not find public key.")
122}
123
124// parsePublicKeyBlock parses any allowed type public key. Currently only allows parsing ed25519 type public keys.
125func parsePublicKeyBlock(derKey []byte) (crypto.PublicKey, error) {

Callers 1

Calls 1

parsePublicKeyBlockFunction · 0.85

Tested by

no test coverage detected