0
0
Fork 0

add MarshalPem() to rsa public key

This commit is contained in:
Gibheer 2015-02-18 21:55:43 +01:00
parent 23f83f3c6e
commit 577538a5ff
1 changed files with 4 additions and 1 deletions

5
rsa.go
View File

@ -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) {