MarshalText returns a PEM encoding of k that OpenSSL understands.
()
| 64 | |
| 65 | // MarshalText returns a PEM encoding of k that OpenSSL understands. |
| 66 | func (k PrivateKey) MarshalText() ([]byte, error) { |
| 67 | if k.ecdsa == nil { |
| 68 | k.ecdsa = new(ecdsa.PrivateKey) |
| 69 | } |
| 70 | |
| 71 | der, err := x509.MarshalECPrivateKey(k.ecdsa) |
| 72 | if err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | |
| 76 | return pem.EncodeToMemory(&pem.Block{ |
| 77 | Type: pemLabelECDSAKey, |
| 78 | Bytes: der, |
| 79 | }), nil |
| 80 | } |
| 81 | |
| 82 | // UnmarshalText populates k from its PEM encoding. |
| 83 | func (k *PrivateKey) UnmarshalText(data []byte) error { |
no outgoing calls