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

Function ParsePrivateKey

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

Source from the content-addressed store, hash-verified

38}
39
40func ParsePrivateKey(text []byte) (crypto.PrivateKey, error) {
41 for len(text) > 0 {
42 var block *pem.Block
43 block, text = pem.Decode(text)
44 if block == nil {
45 return nil, errors.New("signingalgorithm: invalid PEM block in private key.")
46 }
47
48 if block.Type == "ENCRYPTED PRIVATE KEY" {
49 if privkey, err := parseEncryptedPrivateKeyBlock(block.Bytes); err == nil {
50 return privkey, nil
51 }
52 } else {
53 if privkey, err := parsePrivateKeyBlock(block.Bytes); err == nil {
54 return privkey, nil
55 }
56 }
57 }
58
59 return nil, errors.New("signingalgorithm: could not find private key.")
60}
61
62func typeSupportedPKCS8key(keyInterface any) (crypto.PrivateKey, error) {
63 switch typedKey := keyInterface.(type) {

Callers 9

TestGetWebBundleIdFunction · 0.92
readPrivateKeyFromFileFunction · 0.92
createTestSignerFunction · 0.92
TestSignedExchangeFunction · 0.92
createTestExchangeFunction · 0.92
runFunction · 0.92
TestSignVerify_ED25519Function · 0.85

Calls 2

parsePrivateKeyBlockFunction · 0.85

Tested by 7

TestGetWebBundleIdFunction · 0.74
createTestSignerFunction · 0.74
TestSignedExchangeFunction · 0.74
createTestExchangeFunction · 0.74
TestSignVerify_ED25519Function · 0.68