feat(deps): update zeroize and use derive macro
This commit is contained in:
parent
ca8c31e097
commit
a0ba8ac498
@ -46,7 +46,7 @@ default-features = false
|
||||
features = ["std"]
|
||||
|
||||
[dependencies.zeroize]
|
||||
version = "0.5"
|
||||
version = "0.6"
|
||||
optional = true
|
||||
|
||||
[dependencies.serde]
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user