Skip to content

Commit cba7806

Browse files
authored
Bump pin for crypto-primes (#504)
1 parent a9fcf22 commit cba7806

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/algorithms/generate.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use alloc::vec::Vec;
44
use crypto_bigint::{BoxedUint, Odd};
55
use crypto_primes::{
6-
hazmat::{SetBits, SmallPrimesSieveFactory},
7-
is_prime, sieve_and_find,
6+
hazmat::{SetBits, SmallFactorsSieveFactory},
7+
is_prime, sieve_and_find, Flavor,
88
};
99
use rand_core::CryptoRng;
1010

@@ -121,11 +121,13 @@ pub(crate) fn generate_multi_prime_key_with_exp<R: CryptoRng + ?Sized>(
121121
}
122122

123123
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))
129131
.expect("will produce a result eventually")
130132
}
131133

0 commit comments

Comments
 (0)