From 577538a5ffb21b402b7ed53279d4b4dce30ace24 Mon Sep 17 00:00:00 2001 From: Gibheer Date: Wed, 18 Feb 2015 21:55:43 +0100 Subject: add MarshalPem() to rsa public key --- rsa.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'rsa.go') diff --git a/rsa.go b/rsa.go index c0f9986..71acd55 100644 --- a/rsa.go +++ b/rsa.go @@ -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) { -- cgit v1.2.3-70-g09d2