aboutsummaryrefslogtreecommitdiffstats
path: root/src/types/keys.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/types/keys.rs')
-rw-r--r--src/types/keys.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/types/keys.rs b/src/types/keys.rs
index c39816c..d2c4139 100644
--- a/src/types/keys.rs
+++ b/src/types/keys.rs
@@ -1,15 +1,23 @@
+use clear_on_drop::clear::Clear;
use std::time::Instant;
/* This file holds types passed between components.
* Whenever a type cannot be held local to a single module.
*/
-#[derive(Debug, Clone, Copy)]
+#[derive(Debug, Clone)]
pub struct Key {
pub key: [u8; 32],
pub id: u32,
}
+// zero key on drop
+impl Drop for Key {
+ fn drop(&mut self) {
+ self.key.clear()
+ }
+}
+
#[cfg(test)]
impl PartialEq for Key {
fn eq(&self, other: &Self) -> bool {
@@ -17,7 +25,7 @@ impl PartialEq for Key {
}
}
-#[derive(Debug, Clone, Copy)]
+#[derive(Debug, Clone)]
pub struct KeyPair {
pub birth: Instant, // when was the key-pair created
pub initiator: bool, // has the key-pair been confirmed?