feat: add Size function to PublicKey

This allows us to determine the size of signatures produced by a public key.
Incidentally, this also allows us to determine the size of an RSA key's modulus.
This commit is contained in:
Steven Allen
2019-10-21 15:24:42 -07:00
parent 1934e456a0
commit f99684446c
3 changed files with 10 additions and 0 deletions

7
key.go
View File

@@ -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))
}