diff --git a/src/modular/monty_form.rs b/src/modular/monty_form.rs index 945a8c27..54f0d1a5 100644 --- a/src/modular/monty_form.rs +++ b/src/modular/monty_form.rs @@ -158,6 +158,18 @@ impl ConstantTimeEq for MontyParams { } } +#[cfg(feature = "zeroize")] +impl zeroize::Zeroize for MontyParams { + fn zeroize(&mut self) { + self.modulus.zeroize(); + self.one.zeroize(); + self.r2.zeroize(); + self.r3.zeroize(); + self.mod_neg_inv.zeroize(); + self.mod_leading_zeros.zeroize(); + } +} + /// An integer in Montgomery form represented using `LIMBS` limbs. /// The odd modulus is set at runtime. #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -318,10 +330,10 @@ impl ConstantTimeEq for MontyForm { } } -/// NOTE: this does _not_ zeroize the parameters, in order to maintain some form of type consistency #[cfg(feature = "zeroize")] impl zeroize::Zeroize for MontyForm { fn zeroize(&mut self) { - self.montgomery_form.zeroize() + self.montgomery_form.zeroize(); + self.params.zeroize(); } }