diff --git a/README.md b/README.md index 6b46106..62ac7dc 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Forked from https://github.com/spacemonkeygo/openssl (unmaintained) to add: 1. FreeBSD support. 2. Key equality checking. +3. A function to get the size of signatures produced by a key. --- diff --git a/go.mod b/go.mod index 13d7bed..51068e7 100644 --- a/go.mod +++ b/go.mod @@ -4,3 +4,5 @@ require ( github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb // indirect ) + +go 1.12 diff --git a/key.go b/key.go index 3b36fa0..268ff01 100644 --- a/key.go +++ b/key.go @@ -88,6 +88,9 @@ type PublicKey interface { // Equal compares the key with the passed in key. Equal(key PublicKey) bool + // Size returns the size (in bytes) of signatures created with this key. + Size() int + evpPKey() *C.EVP_PKEY } @@ -120,6 +123,10 @@ func (key *pKey) KeyType() NID { return NID(C.EVP_PKEY_id(key.key)) } +func (key *pKey) Size() int { + return int(C.EVP_PKEY_size(key.key)) +} + func (key *pKey) BaseType() NID { return NID(C.EVP_PKEY_base_id(key.key)) }