UnmarshalText populates k from its PEM encoding.
(data []byte)
| 81 | |
| 82 | // UnmarshalText populates k from its PEM encoding. |
| 83 | func (k *PrivateKey) UnmarshalText(data []byte) error { |
| 84 | block, _ := pem.Decode(data) |
| 85 | |
| 86 | if block == nil || block.Type != pemLabelECDSAKey { |
| 87 | return fmt.Errorf("not a PEM-encoded private key") |
| 88 | } |
| 89 | |
| 90 | key, err := x509.ParseECPrivateKey(block.Bytes) |
| 91 | if err == nil { |
| 92 | k.ecdsa = key |
| 93 | } |
| 94 | return err |
| 95 | } |
no outgoing calls