Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Bump secrecy from 0.6.0 to 0.7.0 #7568

Merged
merged 2 commits into from
Nov 22, 2020
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
4 changes: 2 additions & 2 deletions Cargo.lock

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

23 changes: 7 additions & 16 deletions client/cli/src/params/keystore_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ use std::fs;
use std::path::PathBuf;
use structopt::StructOpt;
use crate::error;
use sp_core::crypto::{SecretString, Zeroize};
use std::str::FromStr;
use sp_core::crypto::SecretString;

/// default sub directory for the key store
const DEFAULT_KEYSTORE_CONFIG_PATH: &'static str = "keystore";
Expand Down Expand Up @@ -72,21 +71,15 @@ impl KeystoreParams {
let password = if self.password_interactive {
#[cfg(not(target_os = "unknown"))]
{
let mut password = input_keystore_password()?;
let secret = std::str::FromStr::from_str(password.as_str())
.map_err(|()| "Error reading password")?;
password.zeroize();
Some(secret)
let password = input_keystore_password()?;
Some(SecretString::new(password))
}
#[cfg(target_os = "unknown")]
None
} else if let Some(ref file) = self.password_filename {
let mut password = fs::read_to_string(file)
let password = fs::read_to_string(file)
.map_err(|e| format!("{}", e))?;
let secret = std::str::FromStr::from_str(password.as_str())
.map_err(|()| "Error reading password")?;
password.zeroize();
Some(secret)
Some(SecretString::new(password))
} else {
self.password.clone()
};
Expand All @@ -104,10 +97,8 @@ impl KeystoreParams {
let (password_interactive, password) = (self.password_interactive, self.password.clone());

let pass = if password_interactive {
let mut password = rpassword::read_password_from_tty(Some("Key password: "))?;
let pass = Some(FromStr::from_str(&password).map_err(|()| "Error reading password")?);
password.zeroize();
pass
let password = rpassword::read_password_from_tty(Some("Key password: "))?;
Some(SecretString::new(password))
} else {
password
};
Expand Down
2 changes: 1 addition & 1 deletion primitives/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tiny-bip39 = { version = "0.8", optional = true }
regex = { version = "1.3.1", optional = true }
num-traits = { version = "0.2.8", default-features = false }
zeroize = { version = "1.0.0", default-features = false }
secrecy = { version = "0.6.0", default-features = false }
secrecy = { version = "0.7.0", default-features = false }
lazy_static = { version = "1.4.0", default-features = false, optional = true }
parking_lot = { version = "0.10.0", optional = true }
sp-debug-derive = { version = "2.0.0", path = "../debug-derive" }
Expand Down