Loading openssl/src/pkey.rs +19 −1 Original line number Diff line number Diff line Loading @@ -244,7 +244,11 @@ where where U: HasPublic, { unsafe { ffi::EVP_PKEY_cmp(self.as_ptr(), other.as_ptr()) == 1 } let res = unsafe { ffi::EVP_PKEY_cmp(self.as_ptr(), other.as_ptr()) == 1 }; // Clear the stack. OpenSSL will put an error on the stack when the // keys are different types in some situations. let _ = ErrorStack::get(); res } /// Raw byte representation of a public key. Loading Loading @@ -885,6 +889,7 @@ mod tests { use crate::dh::Dh; use crate::dsa::Dsa; use crate::ec::EcKey; use crate::error::Error; use crate::nid::Nid; use crate::rsa::Rsa; use crate::symm::Cipher; Loading Loading @@ -1168,4 +1173,17 @@ mod tests { let key = PKey::ec_gen("prime256v1").unwrap(); assert!(key.ec_key().is_ok()); } #[test] fn test_public_eq() { let rsa = Rsa::generate(2048).unwrap(); let pkey1 = PKey::from_rsa(rsa).unwrap(); let group = crate::ec::EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap(); let ec_key = EcKey::generate(&group).unwrap(); let pkey2 = PKey::from_ec_key(ec_key).unwrap(); assert!(!pkey1.public_eq(&pkey2)); assert!(Error::get().is_none()); } } Loading
openssl/src/pkey.rs +19 −1 Original line number Diff line number Diff line Loading @@ -244,7 +244,11 @@ where where U: HasPublic, { unsafe { ffi::EVP_PKEY_cmp(self.as_ptr(), other.as_ptr()) == 1 } let res = unsafe { ffi::EVP_PKEY_cmp(self.as_ptr(), other.as_ptr()) == 1 }; // Clear the stack. OpenSSL will put an error on the stack when the // keys are different types in some situations. let _ = ErrorStack::get(); res } /// Raw byte representation of a public key. Loading Loading @@ -885,6 +889,7 @@ mod tests { use crate::dh::Dh; use crate::dsa::Dsa; use crate::ec::EcKey; use crate::error::Error; use crate::nid::Nid; use crate::rsa::Rsa; use crate::symm::Cipher; Loading Loading @@ -1168,4 +1173,17 @@ mod tests { let key = PKey::ec_gen("prime256v1").unwrap(); assert!(key.ec_key().is_ok()); } #[test] fn test_public_eq() { let rsa = Rsa::generate(2048).unwrap(); let pkey1 = PKey::from_rsa(rsa).unwrap(); let group = crate::ec::EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap(); let ec_key = EcKey::generate(&group).unwrap(); let pkey2 = PKey::from_ec_key(ec_key).unwrap(); assert!(!pkey1.public_eq(&pkey2)); assert!(Error::get().is_none()); } }