diff options
Diffstat (limited to 'ecdsa.go')
-rw-r--r-- | ecdsa.go | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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!") |