|
3 | 3 | use alloc::vec::Vec; |
4 | 4 | use crypto_bigint::{BoxedUint, Odd}; |
5 | 5 | use crypto_primes::{ |
6 | | - hazmat::{SetBits, SmallPrimesSieveFactory}, |
7 | | - is_prime, sieve_and_find, |
| 6 | + hazmat::{SetBits, SmallFactorsSieveFactory}, |
| 7 | + is_prime, sieve_and_find, Flavor, |
8 | 8 | }; |
9 | 9 | use rand_core::CryptoRng; |
10 | 10 |
|
@@ -121,11 +121,13 @@ pub(crate) fn generate_multi_prime_key_with_exp<R: CryptoRng + ?Sized>( |
121 | 121 | } |
122 | 122 |
|
123 | 123 | fn generate_prime_with_rng<R: CryptoRng + ?Sized>(rng: &mut R, bit_length: u32) -> BoxedUint { |
124 | | - sieve_and_find( |
125 | | - rng, |
126 | | - SmallPrimesSieveFactory::new(bit_length, SetBits::TwoMsb), |
127 | | - |_rng, candidate| is_prime(candidate), |
128 | | - ) |
| 124 | + let factory = SmallFactorsSieveFactory::new(Flavor::Any, bit_length, SetBits::TwoMsb) |
| 125 | + .unwrap_or_else(|err| panic!("Error creating the sieve: {err}")); |
| 126 | + |
| 127 | + sieve_and_find(rng, factory, |_rng, candidate| { |
| 128 | + is_prime(Flavor::Any, candidate) |
| 129 | + }) |
| 130 | + .unwrap_or_else(|err| panic!("Error generating random candidates: {}", err)) |
129 | 131 | .expect("will produce a result eventually") |
130 | 132 | } |
131 | 133 |
|
|
0 commit comments