aboutsummaryrefslogtreecommitdiff
path: root/ed25519.go
diff options
context:
space:
mode:
authorGibheer <gibheer+git@zero-knowledge.org>2017-05-12 15:27:44 +0200
committerGibheer <gibheer+git@zero-knowledge.org>2017-05-12 15:27:44 +0200
commitb6c44317f540dac8763e720767b0e73940a0b6c5 (patch)
treefac6e911056ba12da589dac4ad1f32aa63430f78 /ed25519.go
parentfd88bca2872e589b451cde3767dbc59d82bd1c83 (diff)
add proper pem interface
This should finally resolve the completely broken and wrong API to get a pem representation of a resource.
Diffstat (limited to 'ed25519.go')
-rw-r--r--ed25519.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/ed25519.go b/ed25519.go
index 602ac52..f7a0e12 100644
--- a/ed25519.go
+++ b/ed25519.go
@@ -70,10 +70,17 @@ func (pr *Ed25519PrivateKey) Sign(message []byte, hash crypto.Hash) ([]byte, err
// Export the private key into the Pem format.
func (pr Ed25519PrivateKey) MarshalPem() (io.WriterTo, error) {
- pem_block := pem.Block{Type: PemLabelEd25519, Bytes: pr.private_key[:]}
+ pem_block, err := pr.ToPem()
+ if err != nil { // it does not currently return an error, but maybe that will change
+ return nil, err
+ }
return marshalledPemBlock(pem.EncodeToMemory(&pem_block)), nil
}
+func (pr Ed25519PrivateKey) ToPem() (pem.Block, error) {
+ return pem.Block{Type: PemLabelEd25519, Bytes: pr.private_key[:]}, nil
+}
+
// Load the public key from a raw byte stream.
// TODO should this be read from ASN.1? All other functions do that.
func LoadPublicKeyEd25519(raw []byte) (*Ed25519PublicKey, error) {