Skip to content

Commit e9bb9ba

Browse files
dignifiedquirepinkforest
authored andcommitted
feat: bump crypto-bigint to 0.7.0-rc.1
1 parent 94f1dd1 commit e9bb9ba

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rust-version = "1.85"
1414

1515
[dependencies]
1616
const-oid = { version = "0.10", default-features = false }
17-
crypto-bigint = { version = "0.7.0-rc.0", default-features = false, features = ["zeroize", "alloc"] }
17+
crypto-bigint = { version = "0.7.0-rc.1", default-features = false, features = ["zeroize", "alloc"] }
1818
crypto-primes = { version = "0.7.0-pre.1", default-features = false }
1919
digest = { version = "0.11.0-rc.0", default-features = false, features = ["alloc", "oid"] }
2020
rand_core = { version = "0.9", default-features = false }

src/algorithms/rsa.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ pub(crate) fn compute_private_exponent_euler_totient(
348348

349349
// NOTE: `mod_inverse` checks if `exp` evenly divides `totient` and returns `None` if so.
350350
// This ensures that `exp` is not a factor of any `(prime - 1)`.
351+
let totient = NonZero::new(totient).expect("known");
351352
match exp.invert_mod(&totient).into_option() {
352353
Some(res) => Ok(res),
353354
None => Err(Error::InvalidPrime),
@@ -376,7 +377,7 @@ pub(crate) fn compute_private_exponent_carmicheal(
376377
let gcd = p1.gcd(&q1);
377378
let lcm = p1 / NonZero::new(gcd).expect("gcd is non zero") * &q1;
378379
let exp = exp.resize_unchecked(lcm.bits_precision());
379-
if let Some(d) = exp.invert_mod(&lcm).into() {
380+
if let Some(d) = exp.invert_mod(&NonZero::new(lcm).expect("non zero")).into() {
380381
Ok(d)
381382
} else {
382383
// `exp` evenly divides `lcm`

src/key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,8 @@ impl RsaPrivateKey {
545545
pub fn crt_coefficient(&self) -> Option<BoxedUint> {
546546
let p = &self.primes[0];
547547
let q = &self.primes[1];
548-
549-
Option::from(q.invert_mod(p))
548+
// TODO: maybe store primes as `NonZero`?
549+
Option::from(q.invert_mod(&NonZero::new(p.clone()).expect("prime")))
550550
}
551551

552552
/// Performs basic sanity checks on the key.

0 commit comments

Comments
 (0)