aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-11-12 11:00:15 +0000
committerSteven Fackler <[email protected]>2016-11-12 11:00:15 +0000
commit9b5c62b053fb84dc233c69ba1700bee9b8a4387f (patch)
tree439e5bf0affe5325ebcc0df1e3d62d86f2c1aa87 /openssl/src
parentFix function signature (diff)
downloadrust-openssl-9b5c62b053fb84dc233c69ba1700bee9b8a4387f.tar.xz
rust-openssl-9b5c62b053fb84dc233c69ba1700bee9b8a4387f.zip
Add PKey::bits
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/pkey.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/openssl/src/pkey.rs b/openssl/src/pkey.rs
index b1c196bd..c9772d52 100644
--- a/openssl/src/pkey.rs
+++ b/openssl/src/pkey.rs
@@ -92,6 +92,15 @@ impl PKeyRef {
Ok(mem_bio.get_buf().to_owned())
}
+ /// Returns the size of the key.
+ ///
+ /// This corresponds to the bit length of the modulus of an RSA key, and the bit length of the
+ /// group order for an elliptic curve key, for example.
+ pub fn bits(&self) -> usize {
+ unsafe { ffi::EVP_PKEY_bits(self.as_ptr()) as usize }
+ }
+
+ /// Compares the public component of this key with another.
pub fn public_eq(&self, other: &PKeyRef) -> bool {
unsafe { ffi::EVP_PKEY_cmp(self.as_ptr(), other.as_ptr()) == 1 }
}