From 96db8524776892aa996001f6814bdb5b477c7a9a Mon Sep 17 00:00:00 2001 From: Sydhds Date: Fri, 12 Jan 2024 14:31:29 +0100 Subject: [PATCH] Zeroize on Wallet struct (#4624) Co-authored-by: sydhds --- Cargo.lock | 1 + Cargo.toml | 1 + massa-wallet/Cargo.toml | 1 + massa-wallet/src/lib.rs | 5 ++++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 2112753e7db..0f2c9c4b986 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3404,6 +3404,7 @@ dependencies = [ "serde_yaml", "tempfile", "thiserror", + "zeroize", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 70f293ff428..251425157aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -200,3 +200,4 @@ tracing-subscriber = "0.3" unsigned-varint = "0.8" variant_count = "1.1" walkdir = "2.3" +zeroize = { version = "1.7", features = ["derive"] } \ No newline at end of file diff --git a/massa-wallet/Cargo.toml b/massa-wallet/Cargo.toml index 342f09fc8a1..cce7950d715 100644 --- a/massa-wallet/Cargo.toml +++ b/massa-wallet/Cargo.toml @@ -19,3 +19,4 @@ massa_hash = {workspace = true} massa_models = {workspace = true} massa_signature = {workspace = true} serde_yaml = {workspace = true} +zeroize = { worksapce = true } diff --git a/massa-wallet/src/lib.rs b/massa-wallet/src/lib.rs index 6e20116bf0d..f364dee1683 100644 --- a/massa-wallet/src/lib.rs +++ b/massa-wallet/src/lib.rs @@ -19,17 +19,20 @@ use std::collections::hash_map::Entry; use std::collections::HashSet; use std::path::PathBuf; use std::str::FromStr; +use zeroize::{Zeroize, ZeroizeOnDrop}; mod error; const WALLET_VERSION: u64 = 1; /// Contains the keypairs created in the wallet. -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Serialize, Zeroize, ZeroizeOnDrop)] pub struct Wallet { /// Keypairs and addresses + #[zeroize(skip)] pub keys: PreHashMap, /// Path to the file containing the keypairs (encrypted) + #[zeroize(skip)] wallet_path: PathBuf, /// Password password: String,