Configurable keys security (#1080)
* adding options & cli flags * adding it to the key deriving * removed duplicated option
This commit is contained in:
@@ -42,6 +42,9 @@ Account Options:
|
||||
ACCOUNTS is a comma-delimited list of addresses.
|
||||
--password FILE Provide a file containing a password for unlocking
|
||||
an account.
|
||||
--keys-iterations NUM Specify the number of iterations to use when deriving key
|
||||
from the password (bigger is more secure)
|
||||
[default: 10240].
|
||||
|
||||
Networking Options:
|
||||
--port PORT Override the port on which the node should listen
|
||||
@@ -182,6 +185,7 @@ pub struct Args {
|
||||
pub flag_password: Vec<String>,
|
||||
pub flag_cache: Option<usize>,
|
||||
pub flag_keys_path: String,
|
||||
pub flag_keys_iterations: u32,
|
||||
pub flag_bootnodes: Option<String>,
|
||||
pub flag_network_id: Option<String>,
|
||||
pub flag_pruning: String,
|
||||
|
||||
@@ -117,6 +117,10 @@ impl Configuration {
|
||||
self.args.flag_keys_path.replace("$HOME", env::home_dir().unwrap().to_str().unwrap())
|
||||
}
|
||||
|
||||
pub fn keys_iterations(&self) -> u32 {
|
||||
self.args.flag_keys_iterations
|
||||
}
|
||||
|
||||
pub fn spec(&self) -> Spec {
|
||||
match self.chain().as_str() {
|
||||
"frontier" | "homestead" | "mainnet" => ethereum::new_frontier(),
|
||||
@@ -245,7 +249,7 @@ impl Configuration {
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
}).collect::<Vec<_>>();
|
||||
let account_service = AccountService::new_in(Path::new(&self.keys_path()));
|
||||
let account_service = AccountService::with_security(Path::new(&self.keys_path()), self.keys_iterations());
|
||||
if let Some(ref unlocks) = self.args.flag_unlock {
|
||||
for d in unlocks.split(',') {
|
||||
let a = Address::from_str(clean_0x(&d)).unwrap_or_else(|_| {
|
||||
|
||||
@@ -219,7 +219,7 @@ fn flush_stdout() {
|
||||
fn execute_account_cli(conf: Configuration) {
|
||||
use util::keys::store::SecretStore;
|
||||
use rpassword::read_password;
|
||||
let mut secret_store = SecretStore::new_in(Path::new(&conf.keys_path()));
|
||||
let mut secret_store = SecretStore::with_security(Path::new(&conf.keys_path()), conf.keys_iterations());
|
||||
if conf.args.cmd_new {
|
||||
println!("Please note that password is NOT RECOVERABLE.");
|
||||
print!("Type password: ");
|
||||
|
||||
Reference in New Issue
Block a user