aboutsummaryrefslogtreecommitdiff
path: root/ecdsa.go
diff options
context:
space:
mode:
authorGibheer <gibheer@gmail.com>2015-02-17 21:43:21 +0100
committerGibheer <gibheer@gmail.com>2015-02-17 21:43:21 +0100
commit53327f7467343588549d8f38b66012b5e868c9db (patch)
tree7e9718d99216ddc60add2430ef26a4372fb5d19f /ecdsa.go
parent930035ce91cc9e6e66874811167f3c3ff58b55b4 (diff)
add pem support to public key
This adds pem support to public keys which can now be handled the same way as private keys.
Diffstat (limited to 'ecdsa.go')
-rw-r--r--ecdsa.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/ecdsa.go b/ecdsa.go
index 170786b..f8f51b2 100644
--- a/ecdsa.go
+++ b/ecdsa.go
@@ -1,4 +1,4 @@
-package pkilib
+package pki
import (
"crypto"
@@ -63,6 +63,14 @@ func (pr EcdsaPrivateKey) MarshalPem() (marshalledPemBlock, error) {
return pem.EncodeToMemory(&pem_block), nil
}
+// marshal the public key to a pem block
+func (pu *EcdsaPublicKey) MarshalPem() (marshalledPemBlock, error) {
+ 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
+}
+
// verify a message using the ecdsa public key
func (pu *EcdsaPublicKey) Verify(message []byte, signature []byte) (bool, error) {
return false, errors.New("not implemented yet!")