Zeroizing::clone_from now zeroizes the destination before cloning
@@ -424,7 +424,7 @@ pub trait TryZeroize {
/// `Zeroizing` is a a wrapper for any `Z: Zeroize` type which implements a
/// `Drop` handler which zeroizes dropped values.
-#[derive(Clone, Debug, Eq, PartialEq)]
+#[derive(Debug, Eq, PartialEq)]
pub struct Zeroizing<Z: Zeroize>(Z);
impl<Z> Zeroizing<Z>
@@ -438,6 +438,17 @@ where
}
}
+impl<Z: Zeroize + Clone> Clone for Zeroizing<Z> {
+ fn clone(&self) -> Self {
+ Self(self.0.clone())
+ }
+
+ fn clone_from(&mut self, source: &Self) {
+ self.0.zeroize();
+ self.0.clone_from(&source.0);
+ }
+}
+
impl<Z> From<Z> for Zeroizing<Z>
where
Z: Zeroize,
