mirror of
https://github.com/libp2p/go-openssl.git
synced 2026-08-21 15:13:28 +08:00
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:
7
key.go
7
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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user