feat(deps): update zeroize and use derive macro

This commit is contained in:
dignifiedquire 2019-03-26 14:45:19 +01:00
parent ca8c31e097
commit a0ba8ac498
3 changed files with 11 additions and 17 deletions

View File

@ -46,7 +46,7 @@ default-features = false
features = ["std"]
[dependencies.zeroize]
version = "0.5"
version = "0.6"
optional = true
[dependencies.serde]

View File

@ -51,6 +51,14 @@ pub enum Sign {
Plus,
}
#[cfg(feature = "zeroize")]
impl Zeroize for Sign {
fn zeroize(&mut self) {
// TODO: Figure out how to better clear the sign.
*self = Sign::NoSign;
}
}
impl Neg for Sign {
type Output = Sign;
@ -118,20 +126,12 @@ impl<'de> serde::Deserialize<'de> for Sign {
/// A big signed integer type.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "zeroize", derive(Zeroize))]
pub struct BigInt {
pub(crate) sign: Sign,
pub(crate) data: BigUint,
}
#[cfg(feature = "zeroize")]
impl Zeroize for BigInt {
fn zeroize(&mut self) {
// TODO: Figure out how to better clear the sign.
self.sign = Sign::NoSign;
self.data.zeroize();
}
}
/// Return the magnitude of a `BigInt`.
///
/// This is in a private module, pseudo pub(crate)

View File

@ -48,17 +48,11 @@ use UsizePromotion;
/// A big unsigned integer type.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "zeroize", derive(Zeroize))]
pub struct BigUint {
pub(crate) data: SmallVec<[BigDigit; VEC_SIZE]>,
}
#[cfg(feature = "zeroize")]
impl Zeroize for BigUint {
fn zeroize(&mut self) {
self.data.zeroize();
}
}
impl PartialEq for BigUint {
#[inline]
fn eq(&self, other: &BigUint) -> bool {