mirror of
https://github.com/libp2p/go-openssl.git
synced 2026-08-21 15:13:28 +08:00
7
key.go
7
key.go
@@ -85,6 +85,9 @@ type PublicKey interface {
|
||||
// `KeyType() == KeyTypeRSA2` would both have `BaseType() == KeyTypeRSA`.
|
||||
BaseType() NID
|
||||
|
||||
// Equal compares the key with the passed in key.
|
||||
Equal(key PublicKey) bool
|
||||
|
||||
evpPKey() *C.EVP_PKEY
|
||||
}
|
||||
|
||||
@@ -109,6 +112,10 @@ type pKey struct {
|
||||
|
||||
func (key *pKey) evpPKey() *C.EVP_PKEY { return key.key }
|
||||
|
||||
func (key *pKey) Equal(other PublicKey) bool {
|
||||
return C.EVP_PKEY_cmp(key.key, other.evpPKey()) == 1
|
||||
}
|
||||
|
||||
func (key *pKey) KeyType() NID {
|
||||
return NID(C.EVP_PKEY_id(key.key))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user