Skip to content

Commit c8512ee

Browse files
committed
Use A* base by default, to be compatible with FIPS
1 parent a12a63f commit c8512ee

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Fixed
1010

1111
- `Sieve::new()` now panics when `max_bit_length == 0` (which would lead to incorrect results anyway, so it is not considered a breaking change). ([#26])
12+
- Default preset now uses A* instead of A base selection method for the Lucas test. This does not change the outcomes, but is implemented as a security recommendation. ([#26])
1213

1314

1415
[#26]: https://github.com/nucypher/rust-umbral/pull/26

src/presets.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rand_core::CryptoRngCore;
55
use rand_core::OsRng;
66

77
use crate::hazmat::{
8-
lucas_test, random_odd_uint, LucasCheck, MillerRabin, Primality, SelfridgeBase, Sieve,
8+
lucas_test, random_odd_uint, AStarBase, LucasCheck, MillerRabin, Primality, Sieve,
99
};
1010

1111
/// Returns a random prime of size `bit_length` using [`OsRng`] as the RNG.
@@ -100,7 +100,7 @@ pub fn generate_safe_prime_with_rng<const L: usize>(
100100
///
101101
/// Performed checks:
102102
/// - Miller-Rabin check with base 2;
103-
/// - Strong Lucas check with Selfridge base (a.k.a. Baillie method A);
103+
/// - Strong Lucas check with A* base (see [`AStarBase`] for details);
104104
/// - Miller-Rabin check with a random base.
105105
///
106106
/// See [`MillerRabin`] and [`lucas_test`] for more details about the checks.
@@ -158,7 +158,7 @@ fn _is_prime_with_rng<const L: usize>(rng: &mut impl CryptoRngCore, num: &Uint<L
158158
return false;
159159
}
160160

161-
match lucas_test(num, SelfridgeBase, LucasCheck::Strong) {
161+
match lucas_test(num, AStarBase, LucasCheck::Strong) {
162162
Primality::Composite => return false,
163163
Primality::Prime => return true,
164164
_ => {}

0 commit comments

Comments
 (0)