aboutsummaryrefslogtreecommitdiff
path: root/ed25519.go
diff options
context:
space:
mode:
Diffstat (limited to 'ed25519.go')
-rw-r--r--ed25519.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/ed25519.go b/ed25519.go
index f7a0e12..cb56a70 100644
--- a/ed25519.go
+++ b/ed25519.go
@@ -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
}