diff options
author | Gibheer <gibheer@gmail.com> | 2015-02-18 21:55:43 +0100 |
---|---|---|
committer | Gibheer <gibheer@gmail.com> | 2015-02-18 21:55:43 +0100 |
commit | 577538a5ffb21b402b7ed53279d4b4dce30ace24 (patch) | |
tree | 788f56f1908f131a2524073db3a6031337a4636c | |
parent | 23f83f3c6eee19349154a06bfb3cc48d85550216 (diff) |
add MarshalPem() to rsa public key
-rw-r--r-- | rsa.go | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -57,7 +57,10 @@ func (pr RsaPrivateKey) MarshalPem() (marshalledPemBlock, error) { } func (pu *RsaPublicKey) MarshalPem() (marshalledPemBlock, error) { - return nil, errors.New("not implemented yet!") + asn1, err := x509.MarshalPKIXPublicKey(pu.public_key) + if err != nil { return nil, err } + pem_block := pem.Block{Type: PemLabelPublic, Bytes: asn1} + return pem.EncodeToMemory(&pem_block), nil } func (pu *RsaPublicKey) Verify(message []byte, signature []byte) (bool, error) { |