Skip to content

Commit

Permalink
use BoxedResidueParams::new_vartime
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Dec 7, 2023
1 parent 851cbac commit 37558f6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl RsaPublicKey {
let e = e.to_u64().unwrap();

let raw_n = to_uint(n);
let n_params = BoxedResidueParams::new(raw_n.clone()).unwrap();
let n_params = BoxedResidueParams::new_vartime(raw_n.clone()).unwrap();
let n = NonZero::new(raw_n).unwrap();

let k = Self { n, e, n_params };
Expand All @@ -225,7 +225,7 @@ impl RsaPublicKey {
/// [`RsaPublicKey::new_with_max_size`] instead.
pub fn new_unchecked(n: BigUint, e: BigUint) -> Self {
let raw_n = to_uint(n);
let n_params = BoxedResidueParams::new(raw_n.clone()).unwrap();
let n_params = BoxedResidueParams::new_vartime(raw_n.clone()).unwrap();
let n = NonZero::new(raw_n).unwrap();
let e = e.to_u64().unwrap();
Self { n, e, n_params }
Expand Down Expand Up @@ -331,7 +331,7 @@ impl RsaPrivateKey {
d: BoxedUint,
mut primes: Vec<BoxedUint>,
) -> Result<RsaPrivateKey> {
let n_params = BoxedResidueParams::new(n.clone()).unwrap();
let n_params = BoxedResidueParams::new_vartime(n.clone()).unwrap();
let n_c = NonZero::new(n.clone()).unwrap();
let nbits = n_c.bits_precision();

Expand Down Expand Up @@ -435,8 +435,8 @@ impl RsaPrivateKey {

// TODO: error handling

let p_params = BoxedResidueParams::new(p.clone()).unwrap();
let q_params = BoxedResidueParams::new(q.clone()).unwrap();
let p_params = BoxedResidueParams::new_vartime(p.clone()).unwrap();
let q_params = BoxedResidueParams::new_vartime(q.clone()).unwrap();

let x = NonZero::new(p.wrapping_sub(&BoxedUint::one())).unwrap();
let dp = d.rem_vartime(&x);
Expand Down Expand Up @@ -687,7 +687,7 @@ mod tests {
pubkey_components: RsaPublicKey {
n: NonZero::new(raw_n.clone()).unwrap(),
e: 200u64,
n_params: BoxedResidueParams::new(raw_n).unwrap(),
n_params: BoxedResidueParams::new_vartime(raw_n).unwrap(),
},
d: BoxedUint::from(123u64),
primes: vec![],
Expand Down

0 comments on commit 37558f6

Please sign in to comment.