diff options
author | Gibheer <gibheer+git@zero-knowledge.org> | 2017-05-12 22:19:25 +0200 |
---|---|---|
committer | Gibheer <gibheer+git@zero-knowledge.org> | 2017-05-12 22:19:25 +0200 |
commit | e95929ed2641bf6548aada92d9d17a3441f19e2b (patch) | |
tree | c97488fbb3f89d313d452d74de635665f092be0e /ed25519.go | |
parent | b6c44317f540dac8763e720767b0e73940a0b6c5 (diff) |
Add ToPem() to public keys
This was missing before from all public keys.
Diffstat (limited to 'ed25519.go')
-rw-r--r-- | ed25519.go | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -92,9 +92,17 @@ func LoadPublicKeyEd25519(raw []byte) (*Ed25519PublicKey, error) { return &Ed25519PublicKey{pu_loaded}, nil } +// ToPem returns the pem encoded public key. +func (pu Ed25519PublicKey) ToPem() (pem.Block, error) { + return pem.Block{Type: PemLabelPublic, Bytes: pu.public_key[:]}, nil +} + // Export the public key into the pem format. func (pu Ed25519PublicKey) MarshalPem() (io.WriterTo, error) { - pem_block := pem.Block{Type: PemLabelPublic, Bytes: pu.public_key[:]} + pem_block, err := pu.ToPem() + if err != nil { + return nil, err + } return marshalledPemBlock(pem.EncodeToMemory(&pem_block)), nil } |