diff --git a/src/presets.rs b/src/presets.rs index 6a25cb5..bc6023e 100644 --- a/src/presets.rs +++ b/src/presets.rs @@ -192,7 +192,7 @@ fn _is_prime_with_rng(rng: &mut impl CryptoRngCore, num: #[cfg(test)] mod tests { - use crypto_bigint::{CheckedAdd, Uint, Word, U128, U64}; + use crypto_bigint::{BoxedUint, CheckedAdd, Uint, Word, U128, U64}; use num_prime::nt_funcs::is_prime64; use rand_core::OsRng; @@ -279,6 +279,15 @@ mod tests { } } + #[test] + fn prime_generation_boxed() { + for bit_length in (28..=128).step_by(10) { + let p: BoxedUint = generate_prime(bit_length, 128); + assert!(p.bits_vartime() == bit_length); + assert!(is_prime(&p)); + } + } + #[test] fn safe_prime_generation() { for bit_length in (28..=128).step_by(10) { @@ -288,6 +297,15 @@ mod tests { } } + #[test] + fn safe_prime_generation_boxed() { + for bit_length in (28..=128).step_by(10) { + let p: BoxedUint = generate_safe_prime(bit_length, 128); + assert!(p.bits_vartime() == bit_length); + assert!(is_safe_prime(&p)); + } + } + #[test] fn corner_cases_is_prime() { for num in 0u64..30 {