use rand_core::OsRng;
pub use crate::common::{
gen_safe_prime as from_rng, is_safe_prime as check_with,
is_safe_prime_baillie_psw as strong_check_with,
};
use crate::error::Result;
pub fn new(bit_length: usize) -> Result {
from_rng(bit_length, &mut OsRng)
}
pub fn check(candidate: &num_bigint::BigUint) -> bool {
check_with(candidate, &mut OsRng)
}
pub fn strong_check(candidate: &num_bigint::BigUint) -> bool {
strong_check_with(candidate, &mut OsRng)
}
#[cfg(test)]
mod tests {
use super::{check, new, strong_check};
#[test]
fn tests() {
for bits in &[128, 256, 384] {
let n = new(*bits).unwrap();
assert!(check(&n));
assert!(strong_check(&n));
}
}
}