Merge pull request #1040 from Zolmeister/check-key
Add RsaRef::check_key
This commit is contained in:
commit
53253db0dc
|
|
@ -143,6 +143,9 @@ extern "C" {
|
||||||
k: *mut RSA,
|
k: *mut RSA,
|
||||||
pad: c_int,
|
pad: c_int,
|
||||||
) -> c_int;
|
) -> c_int;
|
||||||
|
pub fn RSA_check_key(
|
||||||
|
r: *const ::RSA,
|
||||||
|
) -> c_int;
|
||||||
pub fn RSA_free(rsa: *mut RSA);
|
pub fn RSA_free(rsa: *mut RSA);
|
||||||
pub fn RSA_up_ref(rsa: *mut RSA) -> c_int;
|
pub fn RSA_up_ref(rsa: *mut RSA) -> c_int;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,22 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Validates RSA parameters for correctness
|
||||||
|
///
|
||||||
|
/// This corresponds to [`RSA_check_key`].
|
||||||
|
///
|
||||||
|
/// [`RSA_check_key`]: https://www.openssl.org/docs/man1.1.0/crypto/RSA_check_key.html
|
||||||
|
pub fn check_key(&self) -> Result<bool, ErrorStack> {
|
||||||
|
unsafe {
|
||||||
|
let result = ffi::RSA_check_key(self.as_ptr()) as i32;
|
||||||
|
if result == -1 {
|
||||||
|
Err(ErrorStack::get())
|
||||||
|
} else {
|
||||||
|
Ok(result == 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> RsaRef<T>
|
impl<T> RsaRef<T>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue