Move PKey comparison func to public_eq()
This commit is contained in:
parent
123d400277
commit
b0bcb44556
|
|
@ -350,10 +350,8 @@ impl PKey {
|
|||
pub unsafe fn get_handle(&self) -> *mut ffi::EVP_PKEY {
|
||||
return self.evp
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<PKey> for PKey {
|
||||
fn eq(&self, other: &PKey) -> bool {
|
||||
pub fn public_eq(&self, other: &PKey) -> bool {
|
||||
unsafe { ffi::EVP_PKEY_cmp(self.evp, other.evp) == 1 }
|
||||
}
|
||||
}
|
||||
|
|
@ -379,7 +377,7 @@ mod tests {
|
|||
k0.gen(512);
|
||||
k1.load_pub(&k0.save_pub());
|
||||
assert_eq!(k0.save_pub(), k1.save_pub());
|
||||
assert!(k0 == k1);
|
||||
assert!(k0.public_eq(&k1));
|
||||
assert_eq!(k0.size(), k1.size());
|
||||
assert!(k0.can(super::Role::Encrypt));
|
||||
assert!(k0.can(super::Role::Decrypt));
|
||||
|
|
@ -398,7 +396,7 @@ mod tests {
|
|||
k0.gen(512);
|
||||
k1.load_priv(&k0.save_priv());
|
||||
assert_eq!(k0.save_priv(), k1.save_priv());
|
||||
assert!(k0 == k1);
|
||||
assert!(k0.public_eq(&k1));
|
||||
assert_eq!(k0.size(), k1.size());
|
||||
assert!(k0.can(super::Role::Encrypt));
|
||||
assert!(k0.can(super::Role::Decrypt));
|
||||
|
|
@ -481,14 +479,16 @@ mod tests {
|
|||
p0.load_pub(&k0.save_pub());
|
||||
p1.load_pub(&k1.save_pub());
|
||||
|
||||
assert!(k0 == k0);
|
||||
assert!(k1 == k1);
|
||||
assert!(p0 == p0);
|
||||
assert!(p1 == p1);
|
||||
assert!(k0.public_eq(&k0));
|
||||
assert!(k1.public_eq(&k1));
|
||||
assert!(p0.public_eq(&p0));
|
||||
assert!(p1.public_eq(&p1));
|
||||
assert!(k0.public_eq(&p0));
|
||||
assert!(k1.public_eq(&p1));
|
||||
|
||||
assert!(k0 != k1);
|
||||
assert!(p0 != p1);
|
||||
assert!(k0 != p1);
|
||||
assert!(p0 != k1);
|
||||
assert!(!k0.public_eq(&k1));
|
||||
assert!(!p0.public_eq(&p1));
|
||||
assert!(!k0.public_eq(&p1));
|
||||
assert!(!p0.public_eq(&k1));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue