Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove clear_on_drop dependency #4848

Merged
merged 1 commit into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion base_layer/key_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ arrayvec = "0.7.1"
argon2 = { version = "0.2", features = ["std"] }
blake2 = "0.9.1"
chacha20 = "0.7.1"
clear_on_drop = "=0.2.4"
console_error_panic_hook = { version = "0.1.7", optional = true }
crc32fast = "1.2.1"
derivative = "2.2.0"
Expand All @@ -35,6 +34,7 @@ thiserror = "1.0.26"
strum_macros = "0.22"
strum = { version = "0.22", features = ["derive"] }
wasm-bindgen = { version = "0.2", features = ["serde-serialize", "nightly"], optional = true }
zeroize = "1"

[dev-dependencies]
sha2 = "0.9.8"
Expand Down
11 changes: 3 additions & 8 deletions base_layer/key_manager/src/cipher_seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use rand::{rngs::OsRng, RngCore};
use serde::{Deserialize, Serialize};
use tari_crypto::hash::blake2::Blake256;
use tari_utilities::ByteArray;
use zeroize::Zeroize;

use crate::{
error::KeyManagerError,
Expand Down Expand Up @@ -107,7 +108,8 @@ pub const CIPHER_SEED_MAC_BYTES: usize = 5;
/// only have to scan the blocks in the chain since that day for full recovery, rather than scanning the entire
/// blockchain.

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
#[zeroize(drop)]
pub struct CipherSeed {
version: u8,
birthday: u16,
Expand Down Expand Up @@ -373,13 +375,6 @@ impl CipherSeed {
}
}

impl Drop for CipherSeed {
fn drop(&mut self) {
use clear_on_drop::clear::Clear;
Clear::clear(&mut self.entropy);
}
}

impl Default for CipherSeed {
fn default() -> Self {
Self::new()
Expand Down
4 changes: 1 addition & 3 deletions base_layer/wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tari_storage = { version = "^0.38", path = "../../infrastructure/storage" }
tari_common_sqlite = { path = "../../common_sqlite" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.7" }

# Uncomment for tokio tracing via tokio-console (needs "tracing" featurs)
# Uncomment for tokio tracing via tokio-console (needs "tracing" features)
#console-subscriber = "0.1.3"
#tokio = { version = "1.20", features = ["sync", "macros", "tracing"] }
# Uncomment for normal use (non tokio-console tracing)
Expand All @@ -34,7 +34,6 @@ bincode = "1.3.1"
blake2 = "0.9.0"
sha2 = "0.9.5"
chrono = { version = "0.4.19", default-features = false, features = ["serde"] }
clear_on_drop = "=0.2.4"
derivative = "2.2.0"
diesel = { version = "1.4.8", features = ["sqlite", "serde_json", "chrono", "64-column-tables"] }
diesel_migrations = "1.4.0"
Expand All @@ -57,7 +56,6 @@ prost = "0.9"
itertools = "0.10.3"
chacha20poly1305 = "0.9.1"


[dev-dependencies]
tari_p2p = { version = "^0.38", path = "../p2p", features = ["test-mocks"] }
tari_comms_dht = { version = "^0.38", path = "../../comms/dht", features = ["test-mocks"] }
Expand Down
2 changes: 1 addition & 1 deletion comms/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ blake2 = "0.10.4"
bytes = { version = "1", features = ["serde"] }
chrono = { version = "0.4.19", default-features = false, features = ["serde", "clock"] }
cidr = "0.1.0"
clear_on_drop = "=0.2.4"
data-encoding = "2.2.0"
derivative = "2.2.0"
digest = "0.9.0"
Expand All @@ -50,6 +49,7 @@ tokio-util = { version = "0.6.7", features = ["codec", "compat"] }
tower = {version = "0.4", features = ["util"]}
tracing = "0.1.26"
yamux = "=0.10.2"
zeroize = "1"

[dev-dependencies]
tari_test_utils = { version = "^0.38", path = "../../infrastructure/test_utils" }
Expand Down
18 changes: 3 additions & 15 deletions comms/core/src/tor/control_client/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use std::{fmt, net::SocketAddr};

use serde_derive::{Deserialize, Serialize};
use zeroize::Zeroize;

#[derive(Clone, Copy, Debug)]
pub enum KeyType {
Expand Down Expand Up @@ -78,28 +79,15 @@ impl fmt::Display for KeyBlob<'_> {
}
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
#[zeroize(drop)]
pub enum PrivateKey {
/// The server should use the 1024 bit RSA key provided in as KeyBlob (v2).
Rsa1024(String),
/// The server should use the ed25519 v3 key provided in as KeyBlob (v3).
Ed25519V3(String),
}

impl Drop for PrivateKey {
fn drop(&mut self) {
use clear_on_drop::clear::Clear;
match self {
PrivateKey::Rsa1024(ref mut key) => {
Clear::clear(key);
},
PrivateKey::Ed25519V3(ref mut key) => {
Clear::clear(key);
},
}
}
}

/// Represents a mapping between an onion port and a proxied address (usually 127.0.0.1:xxxx).
/// If the proxied_address is not specified, the default `127.0.0.1:[onion_port]` will be used.
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
Expand Down